Error code processing method, device and equipment of microservice and storage medium

By building independent error code microservices and using the SDK toolkit, error code information of microservices is decoupled, which solves the problems of lack of constraints in the development process and high maintenance costs in existing technologies, simplifies the development process of microservices and reduces maintenance costs.

CN116192963BActive Publication Date: 2026-03-20CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-27
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies lack constraints and simplifications in the development and implementation of microservices, resulting in excessively high maintenance costs.

Method used

An independent error code microservice is built using a dual-code mechanism, and the development of the first microservice is simplified using an SDK toolkit. The error code information is encapsulated and mapped through the SDK toolkit, thereby decoupling the internal error code information from the unified error code information.

Benefits of technology

It plays a constraining and simplifying role in the development and implementation of error codes, reducing subsequent maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116192963B_ABST
    Figure CN116192963B_ABST
Patent Text Reader

Abstract

The application provides an error code processing method, device and equipment of microservice and a storage medium, and belongs to the technical fields of computer, information and financial technology. The method comprises the following steps: acquiring calling exception information of a terminal device calling a first microservice, wherein the calling exception information comprises first internal error code information corresponding to the first microservice and an identifier of the terminal device, and the plurality of microservices comprises the first microservice; acquiring an error code list, wherein the error code list comprises a plurality of internal error code information and a mapping relationship between a plurality of unified error code information corresponding to a microservice platform; determining first unified error code information according to the first internal error code information and the error code list; and sending the first unified error code information to the terminal device according to the identifier of the terminal device. The method of the application realizes the decoupling of the internal error code information and the unified error code information, plays a role of constraint and simplification in the error code development and implementation process, and reduces the subsequent maintenance cost.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, information and financial technology, and particularly relates to a micro-service error code processing method and device, equipment and a storage medium. BACKGROUND

[0002] With the development and maturity of micro-service technology, enterprises have introduced this technology and landed it in actual business.

[0003] Micro-service is an architectural style, and a large and complex software application is composed of one or more micro-services. Each micro-service in the system can be independently deployed, and each micro-service is loosely coupled. Although each service in the micro-service architecture can maintain its own independence, in order to provide unified services to users, such as unified error (exception) processing and other platform public parts, the functions and manifestations of each service need to be unified. The current mature unified error code design specification mainly constrains the logical level through the unified design specification in the early stage.

[0004] The prior art does not play a role in constraining and simplifying the specific development and implementation process. In addition, the maintenance cost is too high when the micro-service is modified and optimized subsequently. SUMMARY

[0005] The present application provides a micro-service error code processing method, device, equipment and storage medium, which solves the problem that the prior art does not play a role in constraining and simplifying the specific development and implementation process, and the maintenance cost is too high when the micro-service is modified and optimized subsequently.

[0006] In one aspect, the present application provides a micro-service error code processing method, comprising:

[0007] Obtaining calling exception information of a terminal device calling a first micro-service, the calling exception information comprising: first internal error code information corresponding to the first micro-service and an identifier of the terminal device, and the plurality of micro-services comprising the first micro-service;

[0008] Obtaining an error code list, the error code list comprising a plurality of internal error code information and a mapping relationship between a plurality of unified error code information corresponding to the micro-service platform;

[0009] Determining first unified error code information according to the first internal error code information and the error code list;

[0010] According to the identifier of the terminal device, the first unified error code information is sent to the terminal device.

[0011] Optionally, obtaining an error code list comprises:

[0012] determining whether the error code list exists in the cache;

[0013] if yes, obtaining the error code list in the cache;

[0014] if no, obtaining a configuration file of the first microservice, and performing mapping processing on a plurality of internal error code information in the configuration file to obtain uniform error code information corresponding to each internal error code information, and generating the error code list according to the uniform error code information corresponding to each internal error code information.

[0015] Optionally, for any one of the plurality of internal error code information; performing mapping processing on the internal error code information to obtain uniform error code information corresponding to the internal error code information, comprising:

[0016] performing analysis processing on the internal error code information to obtain detail information corresponding to the internal error code information, the detail information comprising at least one of the following: component code, service identifier, internal code, error description, operation instruction, and flag bit;

[0017] determining the uniform error code information corresponding to the internal error code information according to the detail information.

[0018] Optionally, after generating the error code list according to the uniform error code information corresponding to each internal error code information, the method further comprises:

[0019] storing the error code list into the cache of the first microservice.

[0020] Optionally, the method further comprises:

[0021] receiving an error code update request for the first microservice, the error code update request comprising second internal error code information and an operation instruction for the second internal error code information, the operation instruction being any one of the following: an adding operation, a modifying operation, or a deleting operation;

[0022] performing update processing on the error code list according to the error code update request.

[0023] Optionally, the management of the error code list according to the error code update request comprises:

[0024] if the operation instruction is the adding operation, determining to-be-added uniform error code information corresponding to the second internal error code information, and adding the second internal error code information and the to-be-added uniform error code information to the error code list;

[0025] If the operation instruction is the modification operation, the second internal error code information corresponding to to-be-updated uniform error code information is determined in the error code list, and the uniform error code information corresponding to the second internal error code information in the error code list is updated to the to-be-updated uniform error code information.

[0026] If the operation instruction is the deletion operation, the first mapping relationship corresponding to the second internal error code information is determined in the error code list, and the flag bit of the first mapping relationship is set to invalid.

[0027] In another aspect, the application provides an error code processing apparatus of a microservice, applied to a microservice platform, the microservice platform comprising a plurality of microservices, comprising:

[0028] An obtaining module is configured to obtain calling exception information of a terminal device calling a first microservice, the calling exception information comprising first internal error code information corresponding to the first microservice and an identifier of the terminal device, and the plurality of microservices comprising the first microservice;

[0029] The obtaining module is further configured to obtain an error code list, the error code list comprising a plurality of internal error code information and a plurality of mapping relationships between uniform error code information corresponding to the microservice platform;

[0030] A determining module is configured to determine first uniform error code information according to the first internal error code information and the error code list;

[0031] A sending module is configured to send the first uniform error code information to the terminal device according to the identifier of the terminal device.

[0032] In a possible implementation manner, the obtaining module is specifically configured to:

[0033] determine whether the error code list exists in a cache;

[0034] If yes, the error code list is obtained in the cache;

[0035] If no, a configuration file of the first microservice is obtained, a plurality of internal error code information in the configuration file is mapped and processed to obtain uniform error code information corresponding to each internal error code information, and the error code list is generated according to the uniform error code information corresponding to each internal error code information.

[0036] In a possible implementation manner, the obtaining module is specifically configured to:

[0037] The internal error code information is parsed to obtain detail information corresponding to the internal error code information, the detail information including at least one of component code, service identifier, internal code, error description, operation instruction, and flag bit.

[0038] According to the detail information, unified error code information corresponding to the internal error code information is determined.

[0039] In a possible implementation manner, the obtaining module is specifically configured to:

[0040] The error code list is stored in the cache of the first microservice.

[0041] In a possible implementation manner, the obtaining module is specifically configured to:

[0042] An error code update request for the first microservice is received, the error code update request including second internal error code information and an operation instruction for the second internal error code information, the operation instruction being any one of an adding operation, a modifying operation, or a deleting operation.

[0043] According to the error code update request, the error code list is updated.

[0044] In a possible implementation manner, the obtaining module is specifically configured to:

[0045] If the operation instruction is the adding operation, the second internal error code information corresponds to to-be-added unified error code information, and the second internal error code information and the to-be-added unified error code information are added to the error code list;

[0046] If the operation instruction is the modifying operation, the second internal error code information corresponds to to-be-updated unified error code information in the error code list, and the unified error code information corresponding to the second internal error code information in the error code list is updated to the to-be-updated unified error code information.

[0047] If the operation instruction is the deleting operation, the second internal error code information corresponds to a first mapping relationship in the error code list, and a flag bit of the first mapping relationship is set to be invalid.

[0048] In a third aspect, an electronic device is provided, including:

[0049] a processor and a memory;

[0050] the memory stores computer execution instructions;

[0051] The processor executes computer-executed instructions stored in the memory, so that the electronic device executes the method of any one of the first aspect.

[0052] In a fourth aspect of the present application, a computer-readable storage medium is provided, and the computer-readable storage medium stores computer-executed instructions. When the computer-executed instructions are executed by a processor, the computer-executed instructions are used to implement the determination method of the driver of the hardware peripheral according to any one of the first aspect.

[0053] In a fifth aspect of the present application, a computer program product is provided, and the computer program product includes a computer program. When the computer program is executed by a processor, the computer program implements the method according to any one of the first aspect.

[0054] The embodiment provides a microservice error code processing method, device, equipment and storage medium. The method acquires calling exception information of a terminal device calling a first microservice; acquires an error code list, the error code list including a plurality of internal error code information and a mapping relationship between a plurality of unified error code information corresponding to the microservice platform; determines first unified error code information according to the first internal error code information and the error code list; and sends the first unified error code information to the terminal device according to the identifier of the terminal device. The method uses a double-code mechanism, constructs an independent error code microservice, uses an SDK to simplify development of the first microservice, realizes decoupling of internal error code information and unified error code information, plays a role of constraint and simplification in the development and implementation process of error codes, and reduces subsequent maintenance cost. BRIEF DESCRIPTION OF DRAWINGS

[0055] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.

[0056] Figure 1 A specific application scenario diagram of the microservice error code processing method provided in the present application is shown in the following figure:

[0057] Figure 2 A microservice error code processing method flow provided in the embodiment of the present application is shown in the following figure: Figure One

[0058] Figure 3 A microservice error code processing method flow provided in the embodiment of the present application is shown in the following figure: Figure Two

[0059] Figure 4 A microservice error code processing method flow provided in the embodiment of the present application is shown in the following figure: Figure Three

[0060] Figure 5 ​​​The microservice error code processing method flow provided for the embodiments of the present application Figure Four ;

[0061] Figure 6 The structural schematic diagram of a microservice error code processing device provided for the embodiments of the present application

[0062] Figure 7 The structural schematic diagram of an electronic device provided for the embodiments of the present application

[0063] The specific embodiments of the present application have been shown in the above-described drawings, and will be described in more detail hereinafter. These drawings and the written description are not intended to restrict the scope of the present application in any way, but to illustrate the concept of the present application for the technical personnel in the art by referring to the specific embodiments. DETAILED DESCRIPTION

[0064] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The same numbers are used in different drawings to represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all the implementations consistent with the present application. Instead, they only represent examples of apparatus and methods consistent with some aspects of the present application, as detailed in the appended claims.

[0065] Figure 1 The specific application scenario diagram of the microservice error code processing method provided for the present application. As shown in Figure 1 the application scenario includes a microservice platform 120 including microservice A 121, microservice B 122, and microservice C 123, and a terminal device 101. For example, when the terminal device 101 calls the microservice B 122 in the microservice platform 120, the microservice B 122 generates an exception, and sends error code information to the terminal device 101. The error code refers to a group of numbers (or a combination of numbers and letters), which is associated with error information and can be used to quickly know the source of error and the type of problem. The error code is easy to remember and compare, and can achieve the purpose of offline lightweight free communication without documents and system platforms. The error code information refers to the information related to the error code, including the error code and user operation prompts.

[0066] For a micro-service platform, usually includes a plurality of micro-services, each micro-service is used to provide different services for users. Therefore, when users call different micro-services, a certain number of exceptions will be generated by a micro-service, and different micro-services will generate different exceptions, thereby generating a large amount of error code information. In the existing technical solution, usually at the beginning of the development of different micro-services, all error code information in the micro-service platform is specified to make the error code information of different micro-services have a unified format during the development process. However, this approach lacks constraints in the implementation process, and the time and effort consumed in the later micro-service optimization and modification will continue to increase.

[0067] The application provides a micro-service error code processing method, which uses a double code mechanism to construct an independent error code micro-service, and uses an SDK to simplify the development of the first micro-service, realizes the decoupling of internal error code information and unified error code information, and plays a role of constraint and simplification in the development and implementation process of error codes, and reduces the cost of subsequent maintenance.

[0068] The micro-service error code processing method provided by the application aims to solve the above technical problems of the prior art.

[0069] The technical solutions of the application and how the technical solutions of the application solve the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of the application will be described below with reference to the drawings.

[0070] Figure 2 The micro-service error code processing method provided by the embodiment of the application Figure One . As shown in Figure 2 , the method of the embodiment is applied to a micro-service platform, and the micro-service platform includes a plurality of micro-services, including:

[0071] S201, acquiring calling exception information of a terminal device calling a first micro-service, the calling exception information including: first internal error code information corresponding to the first micro-service and an identifier of the terminal device, and the plurality of micro-services including the first micro-service;

[0072] In this embodiment, the first microservice refers to a microservice in the microservice platform that responds to a terminal device. The call exception information is response information formed after the microservice generates an exception after the terminal device calls the first microservice. Therefore, the call exception information includes first internal error code information corresponding to the first microservice and an identifier of the terminal device. The exception refers to an abnormal event occurring during program execution, which is usually caused by external problems (such as hardware errors, input errors). The terminal device includes but is not limited to a mobile phone, a tablet computer, a television, and a notebook computer, etc. The first internal error code information usually includes the cause and location of the exception and related information for providing the user of the terminal with operation guidance after the exception, including internal code, component code, service identifier, internal code, error description, operation guidance, and flag bit information. The internal code is the error code of the first microservice.

[0073] The application first unifies error codes by constructing an independent basic microservice, that is, uniformly processing error codes of the platform. At the same time, a double code mechanism is adopted, that is, the error code inside the first microservice and the error code displayed outside the user are decoupled. The error code inside the first microservice is defined and developed by the service itself and does not need to change with the business.

[0074] At the same time, the application introduces an SDK toolkit to simplify the development of error codes of the microservice and constrain the implementation of error codes during development. The SDK is the full name of Software Development Kit, which is a collection of development tools established by some software engineers for a specific software package, software framework, hardware platform, operating system, etc. when developing application software. The SDK toolkit is a lib library based on SpringBoot-starter. The SDK toolkit listens to the microservice startup event and actively loads the error code information of the service after the microservice startup is completed. Therefore, the service itself does not need to maintain error code information and only needs to define its own error code in the exception logic.

[0075] In addition, in order to simplify the development of the service, the application realizes the interception and encapsulation of the exception information by using AOP aspect programming based on SpringBoot. When the program executes abnormally, the SDK toolkit maps the error code information defined by the service to the terminal error code information and encapsulates the error information, and returns the result to the terminal. AOP is the abbreviation of Action Oriented Programming, which refers to aspect-oriented programming, a program design paradigm. It is a derivative paradigm of functional programming, which flattens computer operations into a series of changes, simplifies the analysis and runtime processing of the program itself by the computer, and improves the compatibility, evolution, and other characteristics of the system.

[0076] In this embodiment, the first microservice introduces the SDK toolkit into the processing process of the error code information by referencing and defining the SDK toolkit during development. The SDK toolkit mainly has error code encapsulation, exception interception, error code loading, and error code caching functions. Therefore, the calling exception information of the terminal device calling the first microservice can be automatically obtained by the SDK toolkit.

[0077] Those skilled in the art can understand that the manner of obtaining the calling exception information of the first microservice includes but is not limited to active acquisition by a specific toolkit.

[0078] S202, obtaining an error code list, the error code list including a plurality of internal error code information and a mapping relationship between a plurality of uniform error code information corresponding to a microservice platform;

[0079] In this embodiment, a double-code mechanism is used to implement the processing of error codes. The double-code mechanism refers to the coexistence of internal error code information in a plurality of microservices and uniform error code information of a microservice platform. The internal error code information in the microservices is defined by the microservices themselves, and the uniform error code information of the microservice platform is uniformly specified by the platform. The two are mapped through an error code microservice, thereby decoupling the error code information of the microservices and the platform, ensuring the stability of the microservices themselves, and at the same time, the microservice platform uniformly processes the error code information. In the error code microservice, there is a mapping relationship between a plurality of internal error code information and a plurality of uniform error code information corresponding to a microservice platform. In this application, the error code list can be obtained by the SDK toolkit.

[0080] Those skilled in the art can understand that the manner of obtaining the error code list includes but is not limited to active acquisition by a specific toolkit.

[0081] S203, determining first uniform error code information according to the first internal error code information and the error code list;

[0082] In this embodiment, after obtaining the first internal error code information corresponding to the first microservice in the calling exception, the first uniform error code information corresponding to the first internal error code information can be determined by querying the error code list.

[0083] S204, sending the first uniform error code information to the terminal device according to the identifier of the terminal device.

[0084] In this embodiment, the first unified error code information corresponding to the first internal error code information of the first microservice is obtained for sending to the terminal device that generates the call exception information. The application determines the terminal device to which the first unified error code information needs to be sent according to the identifier of the terminal device in the call exception information, and then sends the first unified error code information to the terminal device.

[0085] The embodiment provides a microservice error code processing method. The method includes the following steps: obtaining call exception information of a terminal device calling a first microservice; obtaining an error code list, the error code list including a plurality of internal error code information and a mapping relationship between the plurality of internal error code information and a plurality of unified error code information corresponding to a microservice platform; determining first unified error code information according to the first internal error code information and the error code list; and sending the first unified error code information to the terminal device according to an identifier of the terminal device. The method uses a double-code mechanism to construct an independent error code microservice, and uses an SDK to simplify development of the first microservice, thereby decoupling the internal error code information and the unified error code information, and playing a role of constraint and simplification in the development and implementation process of the error code, while reducing the cost of subsequent maintenance.

[0086] Figure 3 The microservice error code processing method provided in the embodiment Figure Two . As shown in Figure 3 , the method provided in the embodiment is described in detail in the process of obtaining the error code list. Figure 2

[0087] S301, it is judged whether the error code list exists in the cache, if yes, S302 is performed, if not, S303 is performed;

[0088] In this embodiment, the error code list is stored in the cache of the microservice after the microservice is started. Because the storage space occupied by the error code list is small, if the unified error code information needs to be obtained every time, the database needs to be accessed through the error code microservice, which needs a long time and consumes a large amount of resources. It is necessary to judge whether the error code list exists in the cache. Because the error code list is loaded after the microservice is started, and the error code list needs to be reloaded when the error code list is updated subsequently, there is a case that the error code list does not exist in the cache.

[0089] S302, the error code list is obtained in the cache;

[0090] S303, the configuration file of the first microservice is obtained;

[0091] ​In this embodiment, if the error code list is not present in the cache, the error code microservice needs to obtain the configuration file from the first microservice. In fact, the first microservice registers the error code information with the error code microservice using the configuration file. The configuration file can be in JSON format. The configuration file includes multiple internal error code information entries from the first microservice. After obtaining the configuration file, the error code microservice determines the error code list based on it.

[0092] Those skilled in the art will understand that the method by which the first microservice registers with the error code microservice is not limited to using a configuration file. Furthermore, the format of the configuration file may include, but is not limited to, JSON.

[0093] S304. Parse the internal error code information to obtain the detailed information corresponding to the internal error code information. The detailed information includes at least one of the following: component code, service identifier, internal code, error description, operation instructions, and flag bits.

[0094] In this embodiment, the error code microservice maps any one of the multiple internal error code messages to obtain a unified error code message corresponding to that internal error code message. The error code microservice retrieves the internal error code messages from the configuration file and parses them. After parsing, it obtains the detailed information corresponding to the internal error code message. The detailed information typically includes the following items: component code, service identifier, internal code, error description, operation guidance, and flag bits. Here, the component is a component within the microservice; the service identifier is the microservice identifier; the internal code is the error code defined by the microservice; the error description briefly informs the end user of the error; the operation guidance guides the end user's subsequent operations; and the flag bits indicate the current status of the error code message. The format of the detailed information at this time follows the specification defined by the first microservice.

[0095] The error code microservice can only proceed to the next step, namely, obtaining the corresponding unified error code information, after obtaining the detailed information corresponding to the internal error code.

[0096] S305. Based on the detailed information, determine the unified error code information corresponding to the internal error code information;

[0097] In this embodiment, after obtaining the detailed information based on the format defined by the first microservice, the error code microservice assigns an error code based on the microservice platform and encapsulates the detailed information according to the specifications of the microservice platform to obtain unified error code information. The unified error code information includes the detailed information from the corresponding internal error code information, as shown in Table 1. Here, the primary key refers to a unique field in the database, meaning that the unified error code information can be located based on this field; nullability refers to whether the field can be absent.

[0098] Table 1

[0099]

[0100] S306, generating an error code list according to the unified error code information corresponding to each internal error code information.

[0101] In this embodiment, the error code list is a table storing the mapping relationship between the internal error code information and the unified error code information, and the error code microservice generates the error code list according to the unified error code information corresponding to each internal error code information, and then sends it to the database for storage.

[0102] S307, storing the error code list into the cache of the first microservice.

[0103] In this embodiment, after the first microservice installs the SDK tool package, it will request the error code list from the error code microservice through the SDK tool package when starting itself. After receiving the request, the error code microservice will obtain the corresponding error code list from the database and transmit it to the first microservice. At this time, the SDK tool package of the first microservice will divide a space in the cache of the first microservice for storing the error code list. In this way, the SDK tool package of the first microservice does not need to send a request to the error code microservice every time the error code list is used.

[0104] The embodiment provides a microservice error code processing method. The method includes the following steps: determining whether the error code list exists in the cache, if yes, obtaining the error code list in the cache, if not, obtaining the configuration file of the first microservice; performing analysis and processing on the internal error code information to obtain the detail information corresponding to the internal error code information; determining the unified error code information corresponding to the internal error code information according to the detail information; generating an error code list according to the unified error code information corresponding to each internal error code information; and storing the error code list into the cache of the first microservice. The method uses the configuration file to complete the registration of the first microservice to the error microservice, and then determines the error code list and stores it in the cache of the first microservice, which simplifies the process of using the error code microservice by the first microservice and improves the conversion efficiency of the double code mechanism.

[0105] Figure 4 The microservice error code processing method provided in the embodiment of the application Figure Three As shown in Figure 4 , the method of the embodiment, on the basis of the embodiment shown in Figure 2 , is described in detail for the process of updating the error code list according to the error code update request.

[0106] S401, receiving an error code update request for the first microservice, the error code update request comprising second internal error code information and an operation instruction for the second internal error code information, the operation instruction being any one of the following: an addition operation, a modification operation or a deletion operation;

[0107] In this embodiment, the error code microservice is responsible for centralized processing of all error information of the microservice platform, including adding error code information, modifying existing error code information and deleting error code information. The error code microservice provides API interfaces for the above three functions, and only needs the first microservice to send a corresponding request to the interface of the error code microservice to complete the above operations. The request is an error code update request. The request includes an operation instruction and an object corresponding to the operation instruction, i.e., the second internal error code information, which can be a JSON format configuration file. The operation instruction is any one of the following: an addition operation, a modification operation or a deletion operation.

[0108] Thereafter, the error code microservice updates the error code list according to the error code update request.

[0109] S402, if the operation instruction is an addition operation, determining the uniform error code information corresponding to the second internal error code information to be added, and adding the second internal error code information and the uniform error code information to be added to the error code list;

[0110] In this embodiment, after the error code microservice receives the error code update request and determines that the operation instruction is an addition operation, it first allocates corresponding uniform error code information to the second internal error code information. Then the error code microservice downloads the error code list from the database to the cache of the error code microservice. Subsequently, the error code microservice adds the mapping relationship between the second internal error code information and the uniform error code information to be added to the error code list. The SDK toolkit of the first microservice will load the updated error code list into its cache, i.e., perform subsequent operations according to the latest error code list.

[0111] S403, if the operation instruction is a modification operation, determining the uniform error code information corresponding to the second internal error code information to be updated in the error code list, and updating the uniform error code information corresponding to the second internal error code information in the error code list to the uniform error code information to be updated;

[0112] In this embodiment, after the error code microservice receives the error code update request and determines that the operation instruction is a modification operation, the error code microservice first downloads the error code list from the database to the cache of the error code microservice. Subsequently, the error code microservice finds the uniform error code information to be updated corresponding to the second internal error code information in the error code list and updates it, i.e., obtains the updated latest error code list.

[0113] S404, if the operation instruction is a deletion operation, determining a first mapping relationship corresponding to the second internal error code information in the error code list, and setting a flag bit of the first mapping relationship to be invalid.

[0114] In this embodiment, after the error code microservice receives the error code update request and determines that the operation instruction is a deletion operation, the error code microservice first downloads the error code list from the database to the cache of the error code microservice. Then, the error code microservice determines the first mapping relationship corresponding to the second internal error code information in the error code list, and sets the flag bit of the first mapping relationship to be invalid. The mapping relationship will not be deleted, and the purpose is to ensure the backward compatibility of the first microservice.

[0115] The error code processing method of the microservice provided in this embodiment receives an error code update request for a first microservice. If the operation instruction is an addition operation, the second internal error code information corresponding to the to-be-added uniform error code information is determined, and the second internal error code information and the to-be-added uniform error code information are added to the error code list. If the operation instruction is a modification operation, the second internal error code information corresponding to the to-be-updated uniform error code information is determined in the error code list, and the uniform error code information corresponding to the second internal error code information in the error code list is updated to the to-be-updated uniform error code information. If the operation instruction is a deletion operation, the first mapping relationship corresponding to the second internal error code information in the error code list is determined, and the flag bit of the first mapping relationship is set to be invalid. This method sets an interface in the error code microservice to receive the error code update request of the first microservice, and updates the error code information accordingly, so that the error code update is more convenient, and the maintenance cost of the microservice platform is reduced.

[0116] The technical solutions of the present application will be described in detail below with reference to a specific embodiment.

[0117] Figure 5 The error code processing method of the microservice provided in this embodiment Figure Four . As shown in Figure 5 , the SDK tool kit is used on the first microservice. In the starting stage of the first microservice, the SDK tool kit loads the error code list from the error code microservice. After the error code microservice obtains the error code list from the database, it is transmitted to the SDK tool kit, which stores it in the cache of the first microservice. The terminal device sends a front-end request to the first microservice, at which time an exception occurs. The SDK tool kit automatically intercepts the call exception information generated by the first microservice, determines the corresponding uniform error code information according to the first internal error code information therein, encapsulates it and sends it to the terminal device.

[0118] Figure 6A structural diagram of an error code processing apparatus of a microservice is provided in an embodiment of the present application. The apparatus in the embodiment can be in the form of software and / or hardware. As shown in the figure, the error code processing apparatus 600 of a microservice provided in the embodiment is applied to a microservice platform and includes a detection module 601, an estimation module 602, and a control module 603, Figure 6

[0119] The acquisition module 601 is configured to acquire calling exception information of a terminal device for calling a first microservice, the calling exception information including first internal error code information corresponding to the first microservice and an identifier of the terminal device, and the plurality of microservices including the first microservice.

[0120] The acquisition module 601 is further configured to acquire an error code list, the error code list including a plurality of internal error code information and a mapping relationship between a plurality of uniform error code information corresponding to the microservice platform.

[0121] The determination module 602 is configured to determine first uniform error code information according to the first internal error code information and the error code list.

[0122] The sending module 603 is configured to send the first uniform error code information to the terminal device according to the identifier of the terminal device.

[0123] In a possible implementation manner, the acquisition module is specifically configured to:

[0124] determine whether the error code list exists in the cache;

[0125] if yes, acquire the error code list in the cache;

[0126] if no, acquire a configuration file of the first microservice, perform mapping processing on the plurality of internal error code information in the configuration file to obtain uniform error code information corresponding to each internal error code information, and generate the error code list according to the uniform error code information corresponding to each internal error code information.

[0127] In a possible implementation manner, the acquisition module is specifically configured to:

[0128] perform analysis processing on the internal error code information to obtain detail information corresponding to the internal error code information, the detail information including at least one of the following: component code, service identifier, internal code, error description, operation instruction, and flag bit;

[0129] determine uniform error code information corresponding to the internal error code information according to the detail information.

[0130] In a possible implementation manner, the acquisition module is specifically configured to:

[0131] store the error code list into the cache of the first microservice.​

[0132] In a possible implementation, the obtaining module is specifically configured to:

[0133] receive an error code updating request for the first microservice, the error code updating request comprising second internal error code information and an operation instruction for the second internal error code information, the operation instruction being any one of an adding operation, a modifying operation, or a deleting operation;

[0134] update the error code list according to the error code updating request.

[0135] In a possible implementation, the obtaining module is specifically configured to:

[0136] if the operation instruction is the adding operation, determine the uniform error code information to be added corresponding to the second internal error code information, and add the second internal error code information and the uniform error code information to be added corresponding to each other to the error code list;

[0137] if the operation instruction is the modifying operation, determine the uniform error code information to be updated corresponding to the second internal error code information in the error code list, and update the uniform error code information corresponding to the second internal error code information in the error code list to the uniform error code information to be updated;

[0138] if the operation instruction is the deleting operation, determine the first mapping relationship corresponding to the second internal error code information in the error code list, and set a flag of the first mapping relationship to be invalid.

[0139] The device for processing error codes of microservices provided in this embodiment can be used to execute the method embodiments, and has similar implementation principles and technical effects, which will not be described here again.

[0140] An example of the structure of an electronic device is provided in this embodiment, please refer to Figure 7 The electronic device 20 can include a processor 21 and a memory 22. Exemplarily, the processor 21, the memory 22, and parts thereof are connected to each other through a bus 23.

[0141] The memory 22 stores computer execution instructions.

[0142] The processor 21 executes the computer execution instructions stored in the memory 22, so that the electronic device executes the method for processing error codes of microservices as described above.

[0143] It should be appreciated that the processor 21 described above can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the application can be directly embodied as hardware processor execution, or executed by a combination of hardware and software modules in the processor. The memory 22 can include a high-speed random access memory (RAM), and can also include a non-volatile memory (NVM), such as at least one disk memory, and can also be a U disk, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0144] The embodiments of the application correspondingly also provide a computer readable storage medium, the computer readable storage medium stores computer execution instructions, and the computer execution instructions are used to implement the error code processing method of the microservice when executed by the processor.

[0145] The embodiments of the application correspondingly also provide a computer program product, including a computer program, and the computer program is used to implement the error code processing method of the microservice when executed by the processor.

[0146] In the technical solutions of the application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data all comply with the relevant legal regulations and do not violate public order and good customs.

[0147] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. The application is intended to cover any variations, uses or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice in the art to which the application pertains. The specification and examples are to be regarded as exemplary only, and the true scope and spirit of the application are indicated by the following claims.

[0148] It should be understood that the application is not limited to the precise construction that has been described above and illustrated in the accompanying drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the application is limited only by the claims that follow.

Claims

1. A method for handling error codes in microservices, characterized in that, Applied to a microservice platform, which includes multiple microservices, the method includes: Obtain call exception information when a terminal device calls a first microservice. The call exception information includes: a first internal error code information corresponding to the first microservice and the identifier of the terminal device. The plurality of microservices includes the first microservice. Obtain an error code list, which includes multiple internal error code information and a mapping relationship between multiple unified error code information corresponding to the microservice platform; wherein, the internal error code information is the error code information customized within the microservice, and the unified error code information is the error code information uniformly standardized by the microservice platform; Based on the first internal error code information and the error code list, the first unified error code information is determined; Based on the identifier of the terminal device, the first unified error code information is sent to the terminal device.

2. The method according to claim 1, characterized in that, Get the list of error codes, including: Check if the error code list exists in the cache; If so, retrieve the error code list from the cache; If not, the configuration file of the first microservice is obtained, and the multiple internal error code information in the configuration file is mapped to obtain the unified error code information corresponding to each internal error code information. The error code list is generated based on the unified error code information corresponding to each internal error code information.

3. The method according to claim 2, characterized in that, For any one of the plurality of internal error code information; perform mapping processing on the internal error code information to obtain the unified error code information corresponding to the internal error code information, including: The internal error code information is parsed to obtain the detailed information corresponding to the internal error code information. The detailed information includes at least one of the following: component code, service identifier, internal code, error description, operation instructions, and flag bits. Based on the detailed information, determine the unified error code information corresponding to the internal error code information.

4. The method according to claim 2, characterized in that, After generating the error code list based on the unified error code information corresponding to each internal error code information, it also includes: The error code list is stored in the cache of the first microservice.

5. The method according to any one of claims 1-4, characterized in that, The method further includes: Receive an error code update request for the first microservice. The error code update request includes second internal error code information and operation instructions for the second internal error code information. The operation instructions are any one of the following: add operation, modify operation, or delete operation. The error code list is updated according to the error code update request.

6. The method according to claim 5, characterized in that, The step of managing the error code list according to the error code update request includes: If the operation instruction is the new operation, then determine the unified error code information to be added corresponding to the second internal error code information, and add the second internal error code information and the unified error code information to be added to the error code list accordingly; If the operation instruction is the modification operation, then the unified error code information to be updated corresponding to the second internal error code information is determined in the error code list, and the unified error code information corresponding to the second internal error code information in the error code list is updated to the unified error code information to be updated. If the operation instruction is the deletion operation, then the first mapping relationship corresponding to the second internal error code information is determined in the error code list, and the flag bit of the first mapping relationship is set to invalid.

7. An error code handling device for microservices, characterized in that, This is applied to a microservices platform, which includes multiple microservices, including: The acquisition module is used to acquire call exception information of the terminal device calling the first microservice. The call exception information includes: the first internal error code information corresponding to the first microservice and the identifier of the terminal device. The plurality of microservices includes the first microservice. The acquisition module is also used to acquire an error code list, which includes a mapping relationship between multiple internal error code information and multiple unified error code information corresponding to the microservice platform; wherein, the internal error code information is the error code information customized within the microservice, and the unified error code information is the error code information uniformly standardized by the microservice platform; The determining module is used to determine the first unified error code information based on the first internal error code information and the error code list; The sending module is used to send the first unified error code information to the terminal device according to the identifier of the terminal device.

8. An electronic device, comprising: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the electronic device to perform the method of any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement a microservice error code handling method as described in any one of claims 1 to 6.

10. A computer program product comprising a computer program that, when executed by a processor, implements the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Information feedback method, device, system and equipment and storage medium

    CN114510408A

  • Method and device for processing error codes among multiple modules

    CN115408193A