Microservice calling method, device, terminal device and readable storage medium

By adopting standardized application programming interfaces for registration and calling in the microservice architecture and using a declarative scheduling center to obtain the calling address, the problem of low calling efficiency between microservices is solved, and efficient microservice interaction and simplified business processes are achieved.

CN115955511BActive Publication Date: 2025-09-05HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211603357.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-13
Publication Date
2025-09-05
Estimated Expiration
2042-12-13

AI Technical Summary

Technical Problem

In the microservice architecture, the calling efficiency between microservices is low and the interaction is cumbersome, making it difficult to achieve efficient business decoupling and decoupling.

Method used

Use standardized application programming interfaces to register microservices, obtain the registration information of the microservice set through the declarative scheduling center, determine the calling address and call the microservice directly.

Benefits of technology

It improves the calling efficiency between microservices, simplifies the interaction process between microservices, and reduces the burden on developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115955511B_ABST
    Figure CN115955511B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of microservices, and in particular relates to a method, apparatus, terminal device and readable storage medium for calling a microservice. The method comprises: obtaining registration information of a microservice set, the registration information including the call address corresponding to each microservice in the microservice set registered using a standardized application programming interface; when a call request for a first microservice to call a second microservice is obtained, the call address of the second microservice is determined in the registration information according to the call request, and the second microservice is called according to the call address of the second microservice. That is, the registration information of the microservices of the present application are all registered using a standardized application programming interface, and when a call request for a first microservice to call a second microservice is obtained, the call address of the second microservice is determined in the registration information according to the call request; and the second microservice is called according to the call address of the second microservice, which can improve the calling efficiency between microservices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of microservices, and in particular to a method, apparatus, terminal device, and readable storage medium for calling a microservice. Background Art

[0002] A microservice is a service with independent business and functionality that can be independently deployed and iterated. A microservices architecture is a microservices-based architecture that enables distributed management of multiple microservices, facilitates system scalability, and can meet high concurrency requirements.

[0003] However, the microservice architecture itself is relatively complex. When a complex business is split into multiple microservices, although the functions of the microservices are decoupled, the business may not be completely decoupled, and it is still inevitable to face business coupling and interaction.

[0004] The method of calling microservices based on the existing microservice architecture is that since microservices themselves have independent functions, when microservices are used as part of a complex business, it becomes extremely cumbersome and difficult to achieve interaction between microservices, and the calling efficiency between microservices is low. Summary of the Invention

[0005] The embodiments of the present application provide a microservice calling method, apparatus, terminal device, and readable storage medium, which can improve the efficiency of calling between microservices.

[0006] In a first aspect, an embodiment of the present application provides a method for calling a microservice, including:

[0007] Obtain registration information of a microservice set, the registration information including a call address corresponding to each microservice in the microservice set registered using a standardized application programming interface;

[0008] When a call request for the first microservice to call the second microservice is obtained, the calling address of the second microservice is determined in the registration information according to the call request, and the second microservice is called according to the calling address of the second microservice.

[0009] In a possible implementation of the first aspect, before obtaining the registration information of the microservice set, the process includes:

[0010] In response to an initialization declaration instruction triggered by a user, each of the microservices in the microservice set is instructed to register using a standardized application programming interface.

[0011] The call request includes a dependency relationship, where the dependency relationship is a relationship between the second microservice and other microservices when the first microservice calls the second microservice; determining the call address of the second microservice in the registration information according to the call request, and calling the second microservice according to the call address of the second microservice, includes:

[0012] According to the call request, the call address and the dependency relationship of the second microservice are determined in the registration information, and the second microservice is called according to the call address and the dependency relationship of the second microservice.

[0013] The other microservices include a third microservice, which is a microservice in the microservice set other than the first microservice and the second microservice; the dependency relationship includes calling the third microservice before calling the second microservice; and calling the second microservice according to the calling address of the second microservice and the dependency relationship includes:

[0014] Determining a calling address of the third microservice in the registration information;

[0015] After calling the third microservice according to the calling address of the third microservice, calling the second microservice according to the calling address of the second microservice.

[0016] The other microservices include a third microservice, which is a microservice in the microservice set other than the first microservice and the second microservice; the dependency relationship includes calling the third microservice while calling the second microservice; and calling the second microservice according to the calling address of the second microservice and the dependency relationship includes:

[0017] While calling the second microservice according to the calling address of the second microservice, determining the calling address of the third microservice in the registration information;

[0018] The third microservice is called according to the calling address of the third microservice.

[0019] The step of obtaining the registration information of the microservice set includes:

[0020] When each of the microservices in the microservice set is started, registration information of the microservice set is obtained.

[0021] In a second aspect, an embodiment of the present application provides a microservice invocation device, comprising:

[0022] An acquisition module is used to obtain registration information of a microservice set, wherein the registration information includes a call address corresponding to each microservice in the microservice set registered using a standardized application programming interface;

[0023] a determination module, configured to send the registration information to a first microservice in the microservice set, and upon obtaining a call request from the first microservice to call a second microservice, determine a call address of the second microservice in the registration information according to the call request;

[0024] A calling module is used to call the second microservice according to the calling address of the second microservice.

[0025] In a possible implementation of the second aspect, the apparatus further includes:

[0026] The declaration module is configured to, in response to an initialization declaration instruction triggered by a user, instruct each of the microservices in the microservice set to register using a standardized application programming interface.

[0027] In a third aspect, an embodiment of the present application provides a terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the microservice calling method as described in any one of the first aspects is implemented.

[0028] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the microservice calling method as described in any one of the first aspects is implemented.

[0029] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the technical solution of the present application obtains the registration information of a microservice set, and the registration information includes the call address corresponding to each microservice in the microservice set registered using a standardized application programming interface; when a call request is obtained for a first microservice to call a second microservice, the call address of the second microservice is determined in the registration information according to the call request, and the second microservice is called according to the call address of the second microservice. That is, the registration information of the microservices of the present application are all registered using a standardized application programming interface, and when a call request is obtained for a first microservice to call a second microservice, the call address of the second microservice is determined in the registration information according to the call request; and the second microservice is called according to the call address of the second microservice, which can improve the call efficiency between microservices. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0031] Figure 1 This is a structural diagram of a microservice framework system provided by an embodiment of the present application;

[0032] Figure 2 This is a schematic flowchart of a microservice calling method provided in an embodiment of the present application;

[0033] Figure 3 is a schematic flowchart of a method for calling a second microservice provided in an embodiment of the present application;

[0034] Figure 4 is a schematic flowchart of another method for calling a second microservice provided in an embodiment of the present application;

[0035] Figure 5 This is a schematic diagram of the structure of a microservice calling device provided in an embodiment of the present application;

[0036] Figure 6 It is a structural diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0037] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present application with unnecessary details. In other cases, the specific technical details of the various embodiments can be referenced to each other, and specific systems not described in one embodiment can be referenced to other embodiments.

[0038] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.

[0039] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0040] References to "an embodiment of the present application" or "some embodiments" in the present specification mean that one or more embodiments of the present application include specific features, structures, or characteristics described in conjunction with the embodiment. Therefore, phrases such as "in other embodiments," "an embodiment of the present application," and "other embodiments of the present application" appearing in different places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and their variations all mean "including but not limited to," unless otherwise specifically emphasized.

[0041] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0042] A microservice is a service with independent business and functionality that can be independently deployed and iterated. A microservices architecture is a microservices-based architecture that enables distributed management of multiple microservices, facilitates system scalability, and can meet high concurrency requirements.

[0043] However, the microservice architecture itself is relatively complex. When a complex business is split into multiple microservices, although the functions of the microservices are decoupled, the business may not be completely decoupled, and it is still inevitable to face business coupling and interaction.

[0044] The method of calling microservices based on the existing microservice architecture is that since microservices themselves have independent functions, when microservices are used as part of a complex business, it becomes extremely cumbersome and difficult to achieve interaction between microservices, and the calling efficiency between microservices is low.

[0045] In order to solve the above-mentioned defects, the invention of this application is as follows:

[0046] The registration information of the microservices of this application is registered using a standardized application programming interface. When a call request is obtained from a first microservice to call a second microservice, the call address of the second microservice is determined in the registration information according to the call request; and the second microservice is called according to the call address of the second microservice, which can improve the call efficiency between microservices.

[0047] In order to illustrate the technical solution of the present application, specific embodiments are provided below.

[0048] Please refer to Figure 1 , Figure 1This is a schematic diagram of the structure of a microservice framework system provided in an embodiment of the present application. For ease of explanation, only the parts related to the present application are shown. The microservice framework system includes, but is not limited to: multiple microservices and a declarative scheduling center 10.

[0049] Microservices, also known as microservice architecture, is a software architecture approach that breaks down a single, monolithic application into smaller, interconnected, independent services. A service typically implements a set of independent features or functions and includes its own business logic and adapters. Microservices are interconnected by exposing application programming interfaces (APIs).

[0050] The microservices in the network architecture include a first microservice 201 , a second microservice 202 , and a third microservice 203 .

[0051] For example, the microservice architecture is applied to an online shopping platform. Online shopping can be called a business, which includes three sub-businesses: product management, order management, and transportation management. Each sub-business uses a microservice to implement the corresponding business function. For example, the first microservice 201 implements the function of product management, the second microservice 202 implements the function of order management, and the third microservice 203 implements the function of transportation management.

[0052] The microservices and the declarative scheduling center 10 can communicate with each other through the Hypertext Transfer Protocol (Http) or through message queues, which is not limited in the embodiment of the present application.

[0053] The declarative scheduling center 10 is a service centralized management framework for centrally managing the first microservice 201 , the second microservice 202 , and the third microservice 203 .

[0054] The first microservice 201, the second microservice 202, and the third microservice 203 register the corresponding services and addresses in the declarative scheduling center 10 to obtain registration information. The declarative scheduling center 10 is used to call the required services according to the addresses in the registration information.

[0055] In other embodiments, the Figure 1 The examples shown may have more or fewer components, or combinations of certain components, or different components. Figure 1 This is only an exemplary description and should not be interpreted as a specific limitation of this application. For example, it may also include a service gateway, service configuration, database, etc.

[0056] Please refer to Figure 2 , Figure 2 This is a schematic flowchart of a microservice calling method provided in an embodiment of the present application. Figure 2 The execution subject of the method in can be Figure 1 The declarative scheduling center in . Figure 2 As shown, the method includes: S201 to S203.

[0057] S201: The declarative scheduling center responds to an initialization declaration instruction triggered by a user and instructs each microservice in the microservice set to register using a standardized application programming interface.

[0058] Specifically, the initialization declaration instruction is used to instruct the declarative scheduling center to load basic data and then instruct each microservice in the microservice set to register using a standardized application programming interface API.

[0059] Declaration means that the declarative scheduling center tells the microservices that they need to use standardized API registration information, and the microservices figure out how to use the standardized API registration information, rather than the declarative scheduling center instructing the microservices to use standardized API registration information.

[0060] In the embodiments of the present application, the declaration content is recorded using a Yet Another Markup Language (YAML) file format. YAML is used to write configuration files, and the file extension is generally .yaml. YAML configuration files are highly readable and easy to understand. They are used to express data serialization formats and data forms such as arrays, hash tables, and scalars.

[0061] An API is a set of subroutine definitions, protocols, and tools used to build application software. In the embodiments of this application, the API clearly defines the communication method between each microservice.

[0062] In existing technologies, different microservice APIs use different protocols and formats, making interactions between them extremely complex and difficult. The protocol specifies the rules for how microservices interact, while the format defines the methods used for interaction. Furthermore, existing microservice frameworks require developers to know every business detail involved in the business process and understand the logic of each microservice within the framework, placing high demands on developer skills.

[0063] In the embodiments of the present application, a standardized API is used to make the APIs of different microservices have a unified protocol and a unified format, which simplifies the interaction between microservices. By using a standardized API to call microservices, developers do not need to know every business detail involved in the business process, and do not need to understand the logic of each microservice in the framework, thereby reducing the burden on developers.

[0064] For example, an initialization declaration instruction is input in the declarative scheduling center to initialize the platform. The declaration content includes:

[0065] Different types of microservices need to implement APIs. For example, the first microservice needs to provide create and delete APIs when registering in the declarative scheduling center. The second microservice needs to provide create, delete, and update APIs when registering. The third microservice needs to provide create and delete APIs when registering.

[0066] Declaration field, which includes the execution result of the declaration. If the initialization declaration succeeds, the corresponding execution result field is set to "ok". Correspondingly, if the initialization declaration fails, the corresponding execution result field is set to "failure".

[0067] S202: The declarative scheduling center obtains registration information of the microservice set, where the registration information includes a call address corresponding to each microservice in the microservice set registered using a standardized application programming interface.

[0068] In this embodiment of the present application, obtaining the registration information of the microservice set includes:

[0069] When each microservice in the microservice set is started, the registration information of the microservice set is obtained.

[0070] Specifically, in the embodiment of the present application, multiple microservices are referred to as a microservice set.

[0071] In the embodiment of the present application, each microservice cannot be called when it is not started, and can only be called after it is started. After each microservice is started, it is registered in the declarative scheduling center.

[0072] This embodiment of the application takes the registration of a first microservice in a declarative scheduling center as an example. For example, the registration content of the first microservice includes:

[0073] The name of the first microservice.

[0074] The declaration type of the first microservice, which is used to indicate that the registered microservice is of the first type.

[0075] The calling address of the first microservice is the access address of the first microservice.

[0076] The standardized API provided by the first microservice includes a call path and request method for creating the API of the first microservice, and a call path and request method for deleting the API of the first microservice. In the embodiment of the present application, the request method includes a Hypertext Transfer Protocol (HTTP) request method. In the embodiment of the present application, if the registration content lacks these two APIs, the registration will fail.

[0077] The declaration field contains the declaration result of the first microservice registration. If the registration is successful, the corresponding registration result field is set to "ok". If the registration fails, the corresponding registration result field is set to "failure", and the registration failure information is recorded, along with the reason for the failure.

[0078] In the embodiment of the present application, according to the above-mentioned method for registering the first microservice, each microservice is registered to obtain the registration information of the microservice set.

[0079] S203: When the declarative scheduling center obtains a call request from the first microservice to call the second microservice, it determines the call address of the second microservice in the registration information according to the call request, and calls the second microservice according to the call address of the second microservice.

[0080] Specifically, the registration information includes the call address of each microservice. The declarative scheduling center can be thought of as the "address book" of the microservice architecture, recording the mapping between microservices and their call addresses. In a distributed architecture, each microservice is registered with the declarative scheduling center. When a microservice needs to call a second microservice, it finds the call address of the second microservice in the declarative scheduling center and makes the call.

[0081] In the embodiment of the present application, the content of the call request obtained by the first microservice to call the second microservice includes:

[0082] The name of the second microservice.

[0083] The metadata of the business result output by the second microservice and the name of the output business result. For example, the business result can be product management, order management, transportation management, etc.

[0084] The parameters required by the second microservice to output business results are provided by the declarative scheduling center. These parameters include dependencies, which are the relationships between the second microservice and at least one other microservice when the first microservice calls the second microservice. For example, a dependency relationship might be the relationship between the second microservice and a third microservice when the first microservice calls the second microservice, where the third microservice is a microservice in the microservice set other than the first and second microservices. Another example might be the relationship between the second microservice and a third and fourth microservice when the first microservice calls the second microservice, where the fourth microservice is a microservice in the microservice set other than the first, second, and third microservices.

[0085] The declaration field contains the declaration result of the call request. If the business result output by the second microservice is successfully generated, the corresponding field is set to "ok". If the business result output by the second microservice is not successfully generated, the corresponding field is set to "failure". It also contains the call request identifier. If the call request is successful, the declarative scheduling center updates the identifier of the business result output by the second microservice to the database.

[0086] In this embodiment of the present application, the call request also includes deleting the business result output by the second microservice. After the deletion is complete, the declaration result of the call request is updated. Specifically, the declaration result of the call request included in the declaration field is updated. When the business result output by the second microservice is deleted, the corresponding field is updated to "deleted."

[0087] In the embodiment of the present application, the call request includes a dependency relationship; according to the call request, determining the call address of the second microservice in the registration information, and calling the second microservice according to the call address of the second microservice, including:

[0088] According to the call request, the call address and dependency relationship of the second microservice are determined in the registration information, and the second microservice is called according to the call address and dependency relationship of the second microservice.

[0089] In the embodiment of the present application, the dependency relationship includes calling the third microservice before calling the second microservice.

[0090] For the method of calling the second microservice according to its calling address and dependency, please refer to Figure 3 , Figure 3 This is a schematic flowchart of a method for calling a second microservice provided in an embodiment of the present application. Figure 3 The execution subject of the method in can be Figure 1 The declarative scheduling center in . Figure 3 As shown, the method includes: S301 to S302.

[0091] S301. The declarative scheduling center determines the calling address of the third microservice in the registration information.

[0092] Specifically, in an embodiment of the present application, after the declarative scheduling center obtains the call request from the first microservice to call the second microservice, it parses the parameters required for the second microservice to output the business results in the content of the call request, obtains the dependency relationship between the second microservice and the third microservice, and calls the third microservice before calling the second microservice.

[0093] The declarative scheduling center searches for the registration information of the third microservice in the registration information, and specifically searches for the metadata of the business result output by the third microservice and the name of the output business result.

[0094] If the search is successful, the declarative scheduling center calls the third microservice according to the calling address of the third microservice to output the business result of the third microservice, and then calls the second microservice according to the calling address of the second microservice to output the business result of the second microservice.

[0095] If the search fails, the declarative scheduling center creates a third microservice registration and creates a business result output by the third microservice. It then updates the identifier of the business result output by the third microservice in the declaration field of the third microservice's registration. The declarative scheduling center continues searching the registration center for the business result output by the third microservice. If the search is successful, the declarative scheduling center calls the third microservice according to its call address to output the business result of the third microservice. It then calls the second microservice according to its call address to output the business result of the second microservice.

[0096] S302: After the declarative scheduling center calls the third microservice according to the calling address of the third microservice, it calls the second microservice according to the calling address of the second microservice.

[0097] In the embodiment of the present application, when Figure 3 After the dependency in the second microservice calls the business result output by the second microservice, there are two ways for the declarative scheduling center to delete the second microservice:

[0098] 1. Deleting the second microservice has nothing to do with the third microservice, that is, there is no need to delete the third microservice.

[0099] 2. Deleting the second microservice is related to the third microservice, that is, the third microservice must be deleted before deleting the second microservice.

[0100] In the embodiment of the present application, the dependency relationship includes calling the third microservice while calling the second microservice.

[0101] For the method of calling the second microservice according to its calling address and dependency, please refer to Figure 4 , Figure 4 This is a schematic flowchart of another method for calling a second microservice provided in an embodiment of the present application. Figure 4 The execution subject of the method in can be Figure 1 The declarative scheduling center in . Figure 4 As shown, the method includes: S401 to S402.

[0102] S401. The declarative scheduling center calls the second microservice according to the calling address of the second microservice, and determines the calling address of the third microservice in the registration information.

[0103] In an embodiment of the present application, after the declarative scheduling center obtains the call request from the first microservice to call the second microservice, it parses the parameters required by the second microservice in the content of the call request when outputting the business result, obtains the dependency relationship between the second microservice and the third microservice, and calls the third microservice at the same time as calling the second microservice.

[0104] The declarative scheduling center searches for the registration information of the third microservice in the registration information, and specifically searches for the metadata of the business result output by the third microservice and the name of the output business result.

[0105] If the search is successful, the declarative scheduling center calls the second microservice according to the calling address of the second microservice to output the business result of the second microservice, and calls the third microservice according to the calling address of the third microservice to output the business result of the third microservice.

[0106] If the search fails, the declarative scheduling center creates a third microservice registration and creates a business result output by the third microservice. It then updates the identifier of the business result output by the third microservice in the declaration field of the third microservice's registration. The declarative scheduling center continues searching the registration center for the business result output by the third microservice. If the search is successful, the declarative scheduling center calls the second microservice based on the second microservice's call address to output the second microservice's business result. At the same time, the declarative scheduling center calls the third microservice based on the third microservice's call address to output the third microservice's business result.

[0107] S402: The declarative scheduling center calls the third microservice according to the calling address of the third microservice.

[0108] In some embodiments, the dependency relationship includes calling a third microservice and a fourth microservice before calling the second microservice.

[0109] The method for calling the second microservice according to the calling address and dependency relationship of the second microservice also includes:

[0110] The declarative scheduling center determines the calling addresses of the third microservice and the fourth microservice in the registration information; after calling the third microservice and the fourth microservice according to the calling addresses of the third microservice and the fourth microservice, the second microservice is called according to the calling address of the second microservice.

[0111] Specifically, the method for determining the calling address of the fourth microservice is the same as the method for determining the calling address of the third microservice, and will not be repeated here.

[0112] It can be understood that when calling the third microservice and the fourth microservice according to the calling addresses of the third microservice and the fourth microservice, the third microservice can be called first and then the fourth microservice, or the fourth microservice can be called first and then the third microservice, or the third microservice and the fourth microservice can be called at the same time. This embodiment of the present application is not limited to this.

[0113] In some embodiments, the dependency relationship includes calling a third microservice and a fourth microservice while calling the second microservice.

[0114] The method for calling the second microservice according to the calling address and dependency relationship of the second microservice also includes:

[0115] The declarative scheduling center calls the second microservice according to the calling address of the second microservice, and at the same time determines the calling addresses of the third microservice and the fourth microservice in the registration information; and calls the third microservice according to the calling addresses of the third microservice and the fourth microservice.

[0116] It can be understood that in the embodiment of the present application, calling the third microservice according to the calling addresses of the third microservice and the fourth microservice is calling the third microservice and the fourth microservice at the same time.

[0117] In summary, in the technical solution of the present application, by obtaining the registration information of a microservice set, the registration information includes the call address corresponding to each microservice in the microservice set registered using a standardized application programming interface; when a call request is obtained for a first microservice to call a second microservice, the call address of the second microservice is determined in the registration information according to the call request, and the second microservice is called according to the call address of the second microservice. That is, the registration information of the microservices of the present application are all registered using a standardized application programming interface. When a call request is obtained for a first microservice to call a second microservice, the call address of the second microservice is determined in the registration information according to the call request; and the second microservice is called according to the call address of the second microservice, which can improve the calling efficiency between microservices.

[0118] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0119] Please refer to Figure 5 , Figure 5 This is a schematic diagram of the structure of a microservice calling device provided in an embodiment of the present application, which includes:

[0120] The acquisition module 51 is used to acquire registration information of the microservice set, where the registration information includes a call address corresponding to each microservice in the microservice set registered using a standardized application programming interface.

[0121] The calling module 52 is configured to, when receiving a calling request from the first microservice to call the second microservice, determine the calling address of the second microservice in the registration information according to the calling request, and call the second microservice according to the calling address of the second microservice.

[0122] The device also includes:

[0123] The declaration module 53 is configured to respond to an initialization declaration instruction triggered by a user and instruct each microservice in the microservice set to register using a standardized application programming interface.

[0124] The call request includes a dependency relationship, which is the relationship between the second microservice and other microservices when the first microservice calls the second microservice. The calling module 52 is further used to determine the call address of the second microservice and the dependency relationship of the second microservice in the registration information according to the call request, and call the second microservice according to the call address and dependency relationship of the second microservice.

[0125] The other microservices include a third microservice, which is a microservice in the microservice set other than the first microservice and the second microservice; the dependency relationship includes calling the third microservice before calling the second microservice; the calling module 52 is further used to determine the calling address of the third microservice in the registration information;

[0126] After calling the third microservice according to the calling address of the third microservice, the second microservice is called according to the calling address of the second microservice.

[0127] The other microservices include a third microservice, which is a microservice in the microservice set other than the first microservice and the second microservice; the dependency relationship includes calling the third microservice while calling the second microservice, and the calling module 52 is further configured to determine the calling address of the third microservice in the registration information while calling the second microservice according to the calling address of the second microservice;

[0128] The third microservice is called according to the calling address of the third microservice.

[0129] The acquisition module 51 is further configured to acquire registration information of the microservice set when each microservice in the microservice set is started.

[0130] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0131] like Figure 6 As shown, an embodiment of the present application also provides a terminal device 200, including a memory 21, a processor 22, and a computer program 23 stored in the memory 21 and executable on the processor 22. When the processor 22 executes the computer program 23, the calling method of the microservices of the above-mentioned embodiments is implemented.

[0132] The processor 22 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0133] The memory 21 may be an internal storage unit of the terminal device 200. The memory 21 may also be an external storage device of the terminal device 200, such as a plug-in hard disk, a SmartMedia Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. equipped on the terminal device 200. Furthermore, the memory 21 may include both an internal storage unit of the terminal device 200 and an external storage device. The memory 21 is used to store computer programs and other programs and data required by the terminal device 200. The memory 21 may also be used to temporarily store data that has been output or is about to be output.

[0134] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the microservice calling method of each of the above embodiments.

[0135] An embodiment of the present application provides a computer program product. When the computer program product is run on a mobile terminal, the mobile terminal implements the microservice calling method of each of the above embodiments when executing the computer program product.

[0136] If the integrated unit is implemented as a software functional unit and sold or used as a standalone product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process steps in the above-mentioned method embodiments by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable storage medium may include at least: any entity or device capable of carrying computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. Examples include USB flash drives, removable hard drives, magnetic disks, or optical disks. In some jurisdictions, based on legislation and patent practice, computer-readable storage media cannot be electric carrier signals or telecommunication signals.

[0137] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0138] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0139] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0140] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.

Claims

1. A method for calling a microservice, characterized in that: include: Obtain registration information of a microservice set, the registration information including a call address corresponding to each microservice in the microservice set registered using a standardized application programming interface; When a call request is received from the first microservice to call a second microservice, determining the call address of the second microservice in the registration information according to the call request, and calling the second microservice according to the call address of the second microservice; wherein the call request also includes deleting the business result output by the second microservice; The call request includes a dependency relationship, where the dependency relationship is a relationship between the second microservice and other microservices when the first microservice calls the second microservice; determining, according to the call request, a call address of the second microservice in the registration information, and calling the second microservice according to the call address of the second microservice, includes: According to the call request, the call address and the dependency relationship of the second microservice are determined in the registration information, and the second microservice is called according to the call address and the dependency relationship of the second microservice.

2. The calling method according to claim 1, characterized in that: Before obtaining the registration information of the microservice set, the following steps are included: In response to an initialization declaration instruction triggered by a user, each of the microservices in the microservice set is instructed to register using a standardized application programming interface.

3. The calling method according to claim 1, characterized in that: The other microservices include a third microservice, which is a microservice in the microservice set other than the first microservice and the second microservice; the dependency relationship includes calling the third microservice before calling the second microservice; The calling of the second microservice according to the calling address of the second microservice and the dependency relationship includes: Determining a calling address of the third microservice in the registration information; After calling the third microservice according to the calling address of the third microservice, calling the second microservice according to the calling address of the second microservice.

4. The calling method according to claim 1, characterized in that: The other microservices include a third microservice, which is a microservice in the microservice set other than the first microservice and the second microservice; the dependency relationship includes calling the third microservice while calling the second microservice; The calling of the second microservice according to the calling address of the second microservice and the dependency relationship includes: While calling the second microservice according to the calling address of the second microservice, determining the calling address of the third microservice in the registration information; The third microservice is called according to the calling address of the third microservice.

5. The calling method according to any one of claims 1 to 4, characterized in that: The step of obtaining the registration information of the microservice set includes: When each of the microservices in the microservice set is started, registration information of the microservice set is obtained.

6. A microservice calling device, characterized in that: include: An acquisition module is used to obtain registration information of a microservice set, wherein the registration information includes a call address corresponding to each microservice in the microservice set registered using a standardized application programming interface; a calling module configured to, upon receiving a call request from the first microservice to call the second microservice, determine, based on the call request, a call address of the second microservice in the registration information, and call the second microservice based on the call address of the second microservice; wherein the call request further includes deleting a business result output by the second microservice; The call request includes a dependency relationship. When the first microservice calls the second microservice, the calling module is further configured to determine, according to the call request, a call address of the second microservice and the dependency relationship in the registration information, and call the second microservice according to the call address of the second microservice and the dependency relationship.

7. The calling device according to claim 6, characterized in that: Also includes: The declaration module is configured to, in response to an initialization declaration instruction triggered by a user, instruct each of the microservices in the microservice set to register using a standardized application programming interface.

8. A terminal device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the microservice calling method according to any one of claims 1 to 5 when executing the computer program.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the microservice calling method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Business process processing method and business process processing device

    CN107888681A

  • Infinite micro-services architecture

    US20180309802A1