A service calling method, device, electronic device, and storage medium

By deploying updated services in the microservice architecture and distinguishing user requests, the online system stability problem during service upgrades is solved, and the diversion of non-test and test user requests is realized, ensuring the stability and rapid debugging of the service.

CN114221996BActive Publication Date: 2024-11-08HANGZHOU BSOFT CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111362496.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-17
Publication Date
2024-11-08
Estimated Expiration
2041-11-17

AI Technical Summary

Technical Problem

In the microservice architecture, it is difficult to ensure the stable operation of online systems during service upgrades, affecting users' use.

Method used

By deploying the updated target service while providing the target service before the update, and distinguishing test requests from non-test requests based on user requests, the request is automatically diverted, ensuring that non-test users continue to use the service before the update, and at the same time, the test users can Use updated services.

Benefits of technology

It realizes diversion of user requests during service upgrades, ensures normal use of non-test users and rapid debugging of test users, and ensures the stability of the service.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114221996B_ABST
    Figure CN114221996B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a service calling method, device, electronic device and medium. The method includes: while providing the target service before the update, deploying the updated target service, receiving a user request for the target service, determining whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the updated target service, and calling the requested target service according to the path of the service requested by the user request, so that when the service is upgraded, the updated target service and the target service before the update are provided at the same time, and the requests of non-test users and test users are automatically diverted, so as to ensure that the non-test users continue to use the service before the update normally while the test users can also use the updated service normally, so as to quickly debug the upgraded service and ensure the stability of the service provision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a service calling method, a service calling device, an electronic device, and a readable storage medium. Background Art

[0002] Microservice is a software development technology, a variant of the service-oriented architecture style. It advocates dividing a single application into a group of small services, which coordinate and cooperate with each other to provide ultimate value to users. Each service runs in its own independent process, and services communicate with each other using lightweight communication mechanisms. Each service is built around a specific business and can be independently deployed to a production environment, a production-like environment, etc. In addition, a unified and centralized service management mechanism should be avoided as much as possible. For a specific service, it should be built using the appropriate language and tools according to the context.

[0003] In a microservice architecture, service upgrades can affect the normal operation of existing services. If you want to upgrade services while ensuring the stability of existing services, you need to prepare multiple environments. When upgrading existing services, it is difficult to ensure that the online system can provide services stably, which affects online users. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a service calling method, device, electronic device, and storage medium, so as to solve the technical problem that when upgrading the original service, it is difficult to ensure that the online system can provide services stably, which affects the use of online users.

[0005] In order to solve the above problem, in a first aspect of the implementation of the present invention, a service calling method is first provided, comprising:

[0006] Deploy the updated target service while providing the target service before the update;

[0007] receiving a user request for a target service;

[0008] Determine whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the target service after the update;

[0009] The requested target service is called according to the path of the service requested by the user.

[0010] Optionally, the determining whether the user request is a test request or a non-test request, and a path of the service requested by the user request includes:

[0011] If the user request carries the preset identifier corresponding to the updated target service, the user request is a test request, and the identification information and version information of the updated target service corresponding to the preset identifier of at least one service requested by the user request are determined;

[0012] A path for the at least one service is generated according to the user request, the identification information and the version information.

[0013] Optionally, before deploying the updated target service while providing the target service before the update, the method further includes:

[0014] The preset identifier and the corresponding identifier information and version information of the updated target service are configured.

[0015] Optionally, calling the requested target service according to the path of the service requested by the user comprises:

[0016] Determine the path of the target service node corresponding to each service according to the path of the service requested by the user request;

[0017] According to the paths of the target service nodes corresponding to the respective services, the user request is forwarded to the target service node corresponding to the target service for processing.

[0018] Optionally, determining the path of the target service node corresponding to each service according to the path of the service requested by the user request includes:

[0019] Obtaining, from the first cache, service nodes registered corresponding to services other than the target service;

[0020] According to the identification information and the version information, obtaining, from the second cache, a service node registered corresponding to the target service;

[0021] Allocating a target service node corresponding to each service to the user request from the service nodes registered corresponding to each service;

[0022] According to the path of the service requested by the user request and the target service node corresponding to each service, the path of the target service node corresponding to each service is generated.

[0023] Optionally, the determining whether the user request is a test request or a non-test request, and a path of the service requested by the user request includes:

[0024] If the user request does not carry the preset identifier corresponding to the updated target service, the user request is a non-test request, and at least one service requested by the user request is determined;

[0025] A path for the at least one service is generated according to the user request.

[0026] In a second aspect of the present invention, a service invocation device is provided, comprising:

[0027] A service deployment module, used to deploy the updated target service while providing the target service before the update;

[0028] A request receiving module, used for receiving a user request for a target service;

[0029] a path determination module, used to determine whether the user request is a test request or a non-test request, and a path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the target service after the update;

[0030] The service calling module is used to call the requested target service according to the path of the service requested by the user.

[0031] Optionally, the path determination module includes:

[0032] A first service determination submodule, configured to determine, if the user request carries a preset identifier corresponding to the updated target service, that the user request is a test request, and to determine at least one service requested by the user request, identification information and version information of the updated target service corresponding to the preset identifier;

[0033] The first path generation submodule is used to generate a path for the at least one service according to the user request, the identification information and the version information.

[0034] Optionally, the device further comprises:

[0035] A configuration module is used to configure the preset identifier and the corresponding identifier information and version information of the updated target service before deploying the updated target service while providing the target service before the update.

[0036] Optionally, the service calling module includes:

[0037] A path determination submodule, used to determine the path of the target service node corresponding to each service according to the path of the service requested by the user request;

[0038] The forwarding submodule is used to forward the user request to the target service node corresponding to the target service for processing according to the path of the target service node corresponding to each service.

[0039] Optionally, the path determination submodule includes:

[0040] A first node acquisition unit, configured to acquire, from a first cache, service nodes registered corresponding to services other than the target service;

[0041] A second node acquisition unit, configured to acquire, from a second cache, a service node registered corresponding to the target service according to the identification information and the version information;

[0042] an allocating unit, configured to allocate a target service node corresponding to each service for the user request from the service nodes registered corresponding to each service;

[0043] The path generation unit is used to generate a path of a target service node corresponding to each service according to the path of the service requested by the user request and the target service node corresponding to each service.

[0044] Optionally, the path determination module includes:

[0045] A second service determination submodule, configured to determine, if the user request does not carry a preset identifier corresponding to the updated target service, that the user request is a non-test request, and determine at least one service requested by the user request;

[0046] The second path generation submodule is used to generate a path for the at least one service according to the user request.

[0047] In a third aspect of the present invention, an electronic device is provided, characterized in that it includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0048] Memory, used to store computer programs;

[0049] The processor is used to implement any of the method steps described above when executing the program stored in the memory.

[0050] In a fourth aspect of the implementation of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the program is executed by a processor, any of the methods described above is implemented.

[0051] According to an embodiment of the present invention, by deploying the updated target service while providing the target service before the update, receiving a user request for the target service, determining whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the updated target service, and calling the requested target service according to the path of the service requested by the user request, so that when the service is upgraded, the updated target service and the target service before the update are provided at the same time, and the requests of non-test users and test users are automatically diverted, thereby ensuring that non-test users continue to use the service before the update normally while test users can also use the updated service normally, so as to quickly debug the upgraded service and ensure the stability of service provision. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0053] Figure 1 A flow chart showing the steps of an embodiment of a service calling method of the present invention is shown;

[0054] Figure 2 A schematic diagram showing the paths of services requested by different user requests;

[0055] Figure 3 A flow chart showing the steps of an embodiment of a service calling method of the present invention is shown;

[0056] Figure 4 A schematic diagram showing request diversion during service invocation;

[0057] Figure 5 A structural block diagram showing an embodiment of a service calling device of the present invention is shown;

[0058] Figure 6 A schematic diagram of an electronic device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0059] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0060] Reference Figure 1 , shows a flow chart of the steps of a service calling method according to an embodiment of the present invention, which may specifically include the following steps:

[0061] Step 101 , deploying the updated target service while providing the target service before the update.

[0062] In the embodiment of the present invention, the target service is a service that needs to be updated. Each update can upgrade one or more target services. In order to achieve both service updates and ensure the stability of the original service, during the update process, the target service before the update continues to be provided, and the updated target service is deployed at the same time, so that the target service before the update and the updated target service are provided at the same time.

[0063] In an embodiment of the present invention, one implementation method for deploying services is to inject services in the form of plug-ins. Each service component provides services to the outside world, and the calling program depends on the interface service, not on the service implementation. The service implementation can be specified during integration, that is, the service interface and its implementation are bound during deployment or runtime, rather than being connected during compile time. Plug-ins are a mechanism for implementing binding, which can not only eliminate dependencies, but also postpone the decision of which implementation class to use until configuration or deployment. When injecting services based on plug-in methods, the interface and implementation of the service are separated first, and then at runtime, the interface and implementation are bound according to the deployment or configuration.

[0064] Step 102: Receive a user request for a target service.

[0065] In the embodiment of the present invention, user requests can be divided into test requests and non-test requests, wherein non-test requests are normal requests, and test requests are requests specifically for testing services. User requests for target services refer to services requested by user requests including target services, which can be updated target services or pre-updated target services.

[0066] Step 103, determining whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the target service after the update.

[0067] In the embodiment of the present invention, for the target service, the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the target service after the update.

[0068] In an embodiment of the present invention, after receiving a user request for a target service, different user requests are automatically distinguished. The specific implementation methods for determining whether a user request is a test request or a non-test request may include multiple methods. For example, a preset identifier is configured for the updated target service in advance, and it is agreed that if a user request is a test request, the user request must carry the preset identifier. After receiving the user request for the target service, the user request is parsed. If the user request carries the preset identifier, it is determined that the user request is a test request. If the user request does not carry the preset identifier, it is determined that the user request is a non-test request. Any applicable implementation method may be used, and the embodiment of the present invention does not limit this.

[0069] In the embodiment of the present invention, the service requested by the user request includes one or more. The path of the service requested by the user request is used to indicate the services that are passed in sequence when processing the user request. When the user request is subsequently processed and each service is called, the path of the service requested by the user request needs to be carried, so that the user request is forwarded to each service in sequence according to the path of the service requested by the user request.

[0070] If the service requested by the user request includes one, and the user request is a test request, the service requested by the user request includes the updated target service. At this time, the path of the service requested by the user request is only the updated target service.

[0071] If the service requested by the user request includes one, and the user request is a non-test request, the service requested by the user request includes the target service before the update. At this time, the path of the service requested by the user request is only the target service before the update.

[0072] If the service requested by the user request includes multiple services, if the user request is a test request, then the service requested by the user request includes at least one updated target service. At this time, the path of the service requested by the user request is multiple services and their processing order, among which one or more services are updated target services.

[0073] If the service requested by the user request includes multiple services, if the user request is not a test request, then the service requested by the user request includes at least one target service before the update. At this time, the path of the service requested by the user request is multiple services and their processing order, among which one or more services are the target services before the update.

[0074] For example, Figure 2The diagram shows the paths of services requested by different user requests. User requests sent by formal users are non-test requests, and user requests sent by test users are test requests. The services that non-test requests pass through and the services that test requests pass through have different paths. Specifically, the paths of services requested by non-test requests are server01, server02, and server03, respectively, while the paths of services requested by test requests are server01, server02 v2, and server03, respectively. Among them, server02 is the target service before the update, and server02 v2 is the target service after the update.

[0075] Step 104: Call the requested target service according to the path of the service requested by the user.

[0076] In the embodiment of the present invention, when processing a user request, the user request is forwarded according to the path of the service requested by the user request, and each service is called, including the target service. According to the path of the service requested by the user request, the specific implementation method of calling the requested target service may include multiple methods. For example, according to the path of the service requested by the user request, the path of the target service node corresponding to each service is determined, and according to the path of the target service node corresponding to each service, the user request is forwarded to the target service node corresponding to the target service for processing. Any applicable implementation method can be used, and the embodiment of the present invention does not limit this.

[0077] According to an embodiment of the present invention, by deploying the updated target service while providing the target service before the update, receiving a user request for the target service, determining whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the updated target service, and calling the requested target service according to the path of the service requested by the user request, so that when the service is upgraded, the updated target service and the target service before the update are provided at the same time, and the requests of non-test users and test users are automatically diverted, thereby ensuring that non-test users continue to use the service before the update normally while test users can also use the updated service normally, so as to quickly debug the upgraded service and ensure the stability of service provision.

[0078] Reference Figure 3 , shows a flow chart of the steps of a service calling method according to an embodiment of the present invention, which may specifically include the following steps:

[0079] Step 201 : deploying the updated target service while providing the target service before the update.

[0080] In the embodiment of the present invention, the specific implementation method of this step can refer to the description in the above embodiment and will not be repeated here.

[0081] Step 202: Receive a user request for a target service.

[0082] In the embodiment of the present invention, the specific implementation method of this step can refer to the description in the above embodiment and will not be repeated here.

[0083] In the embodiment of the present invention, after executing step 202, step 203 or step 205 is executed.

[0084] Step 203: If the user request carries a preset identifier corresponding to the updated target service, the user request is a test request, and the identification information and version information of the updated target service corresponding to the preset identifier of at least one service requested by the user request are determined;

[0085] In an embodiment of the present invention, in order to distinguish between non-test requests and test requests, a corresponding preset identifier is pre-configured for the updated target service. If the user request carries a preset identifier, the user request is a test request. At the same time, at least one service requested by the user request is determined, and based on the preset identifier, the identification information and version information of the updated target service corresponding to the preset identifier can be determined. Among them, the identification information includes but is not limited to the service name, or any other applicable information that uniquely marks the target service, which is not limited by the embodiment of the present invention. The version information includes but is not limited to the version number, or any other applicable information that uniquely marks the version of the target service, which is not limited by the embodiment of the present invention.

[0086] For example, Figure 4The diagram of request diversion during the service call process shown in the figure. The user first initiates a request through the nginx / rpc service. Among them, nginx (engine x, an open source software) is a high-performance HTTP (HyperText Transfer Protocol) and reverse proxy web (World Wide Web) server, and also provides IMAP (Internet Message Access Protocol) / POP3 (Post Office Protocol-Version 3) / SMTP (Simple Mail Transfer Protocol) services. rpc (Remote Procedure Call, remote procedure call) is a communication technology used by programs and processes running between multi-tasking operating systems or networked computers. The request is handed over to the service version selection component SeviceVersionGrayStrategy in the grayscale upgrade module GrayBunny implemented by the present invention, and the service version selection component includes a test request selector SpecifyCaseSelector and a non-test request selector TrafficSelector. When it is determined that the user request is a test request, the local storage method localStore or the remote storage method remoteStore is used to query the corresponding service name and service version according to the preset identifier in the request. If the preset identifier is queried, the user request is selected by the test request selector SpecifyCaseSelector. Among them, the local storage method localStore can use Caffeine (a high-performance cache library), and the remote storage method remoteStore can use mysql (a relational database management system), mongo (a database based on distributed file storage), redis (Remote Dictionary Server, i.e., remote dictionary service), oracle (Oracle Database, a relational database management system) or sqlserver (a relational database management system).

[0087] Step 204: Generate a path for the at least one service according to the user request, the identification information and the version information.

[0088] In an embodiment of the present invention, the calling order of at least one service can be determined according to a user request. Since at least one service includes an updated target service, for the target service, the path of at least one service is no longer the path of the target service before the update, and it is necessary to generate a path of the updated target service according to the identification information and version information. For the target service, the generated path carries the identification information and version information of the configuration corresponding to the preset identification.

[0089] In the embodiment of the present invention, after executing step 204, step 207 is executed.

[0090] In an optional embodiment of the present invention, before the updated target service is deployed while providing the target service before the update, the method may further include: configuring the preset identifier, and the corresponding identifier information and version information of the updated target service.

[0091] A preset identifier and the corresponding identifier information and version information of the updated target service are used as a piece of configuration information. Multiple preset identifiers can also be configured as needed, and the embodiment of the present invention does not limit this. For example, according to the target service update requirements, the version number of the target service is configured, and the special identification code DescID (i.e., the preset identifier), the requested service name and the service version of the test request are configured in the database. Then the updated target service is put online.

[0092] Step 205: If the user request does not carry the preset identifier corresponding to the updated target service, the user request is a non-test request, and at least one service requested by the user request is determined.

[0093] In the embodiment of the present invention, if the user request does not carry a preset identifier, the user request is a non-test request. At the same time, at least one service requested by the user request is determined.

[0094] For example, Figure 4 As shown, when determining whether the user request is a non-test request, the local storage method localStore or the remote storage method remoteStore is used. If the user request does not carry a preset identifier, the user request is selected by the non-test request selector TrafficSelector.

[0095] Step 206: Generate a path for the at least one service according to the user request.

[0096] In the embodiment of the present invention, the calling order of at least one service can be determined according to the user request. The path of the target service before the update is generated in the original manner.

[0097] In the embodiment of the present invention, after executing step 206, step 207 is executed.

[0098] Step 207: Determine the path of the target service node corresponding to each service according to the path of the service requested by the user.

[0099] In the embodiment of the present invention, the service is provided by a service node, which may be a server providing the service, etc. For each requested service, a corresponding target service node is allocated respectively. Then, according to the path of the requested service, the path of the target service node corresponding to each service is determined.

[0100] For example, Figure 4 As shown, the grayscale upgrade module GrayBunny also includes a service registration node management component DefaultGrayServiceManager, which can obtain the service nodes corresponding to each service from the registration center and monitor the service nodes corresponding to each service. According to the service nodes corresponding to each service, a target service node is allocated to each service, and then the path of the target service node is determined.

[0101] In an optional embodiment of the present invention, a specific implementation method of determining the path of the target service node corresponding to each service according to the path of the service requested by the user request may include: obtaining the registered service nodes corresponding to services other than the target service from the first cache; obtaining the registered service nodes corresponding to the target service from the second cache according to the identification information and version information; allocating the target service nodes corresponding to each service to the user request from the registered service nodes corresponding to each service; and generating the path of the target service nodes corresponding to each service according to the path of the service requested by the user request and the target service nodes corresponding to each service.

[0102] The first cache stores the service nodes registered for the services before the update, and the second cache stores the service nodes registered for the services after the update. Therefore, the service nodes registered for services other than the target service can be obtained from the first cache, and the service nodes registered for the target service can be searched and obtained from the second cache based on the identification information and version information. From the service nodes registered for each service, the target service nodes corresponding to each service are respectively allocated for the user request. Specifically, any applicable existing method can be used to allocate the target service nodes, and the embodiments of the present invention do not limit this. According to the order of the paths of the services requested by the user request and the target service nodes corresponding to each service, the paths of the target service nodes corresponding to each service are generated so that the paths of the target service nodes are consistent with the paths of the services in order.

[0103] For example, Figure 4As shown in the figure, the service registration node management component DefaultGrayServiceManager caches the service nodes corresponding to the service registration through the default cache defaultCache and the gray cache grayCache. The service registration node management component DefaultGrayServiceManager listens to the registration center and obtains the latest service nodes corresponding to each service from the registration center. Among them, the registration center supports zookeeper (zoo manager), nacos (DynamicNaming and Configuration Service), eureka (a service discovery framework), etc.

[0104] Step 208: forward the user request to the target service node corresponding to the target service for processing according to the path of the target service node corresponding to each service.

[0105] In the embodiment of the present invention, the user request is forwarded according to the path of the target service node corresponding to each service, so that the user request is forwarded to the target service node corresponding to the target service for processing. When the user request is a test request, the user request is forwarded to the target service node corresponding to the updated target service for processing. When the user request is a non-test request, the user request is forwarded to the target service node corresponding to the target service before the update for processing.

[0106] For example, Figure 4 As shown, after passing through the graybunny module, user requests are diverted, some of the services passed through are online services, that is, the target services before the update, and some of the services passed through include services that need to be released, that is, the target services after the update.

[0107] According to an embodiment of the present invention, by deploying an updated target service while providing a target service before the update, receiving a user request for the target service, if the user request carries a preset identifier corresponding to the updated target service, the user request is a test request, and at least one service requested by the user request, identification information and version information of the updated target service corresponding to the preset identifier are determined, and a path for the at least one service is generated according to the user request, the identification information and the version information, if the user request does not carry the preset identifier corresponding to the updated target service, the user request is a non-test request, and at least one service requested by the user request is determined. A service generates a path of at least one service according to the user request, determines the path of the target service node corresponding to each service according to the path of the service requested by the user request, and forwards the user request to the target service node corresponding to the target service for processing according to the path of the target service node corresponding to each service, so that when the service is upgraded, the updated target service and the target service before the update are provided at the same time, and the requests of non-test users and test users are automatically diverted, so as to ensure that the non-test users continue to use the service before the update normally while the test users can also use the updated service normally, so as to quickly debug the upgraded service and ensure the stability of the service provision.

[0108] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0109] Reference Figure 5 , shows a structural block diagram of a service calling device according to an embodiment of the present invention, which may specifically include the following steps:

[0110] A service deployment module 301, used to deploy the updated target service while providing the target service before the update;

[0111] A request receiving module 302, used to receive a user request for a target service;

[0112] A path determination module 303, used to determine whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the target service after the update;

[0113] The service calling module 304 is used to call the requested target service according to the path of the service requested by the user.

[0114] In an optional embodiment of the present invention, the path determination module includes:

[0115] A first service determination submodule, configured to determine, if the user request carries a preset identifier corresponding to the updated target service, that the user request is a test request, and to determine at least one service requested by the user request, identification information and version information of the updated target service corresponding to the preset identifier;

[0116] The first path generation submodule is used to generate a path for the at least one service according to the user request, the identification information and the version information.

[0117] In an optional embodiment of the present invention, the device further includes:

[0118] A configuration module is used to configure the preset identifier and the corresponding identifier information and version information of the updated target service before deploying the updated target service while providing the target service before the update.

[0119] In an optional embodiment of the present invention, the service calling module includes:

[0120] A path determination submodule, used to determine the path of the target service node corresponding to each service according to the path of the service requested by the user request;

[0121] The forwarding submodule is used to forward the user request to the target service node corresponding to the target service for processing according to the path of the target service node corresponding to each service.

[0122] In an optional embodiment of the present invention, the path determination submodule includes:

[0123] A first node acquisition unit, configured to acquire, from a first cache, service nodes registered corresponding to services other than the target service;

[0124] A second node acquisition unit, configured to acquire, from a second cache, a service node registered corresponding to the target service according to the identification information and the version information;

[0125] an allocating unit, configured to allocate a target service node corresponding to each service for the user request from the service nodes registered corresponding to each service;

[0126] The path generation unit is used to generate a path of a target service node corresponding to each service according to the path of the service requested by the user request and the target service node corresponding to each service.

[0127] In an optional embodiment of the present invention, the path determination module includes:

[0128] A second service determination submodule, configured to determine, if the user request does not carry a preset identifier corresponding to the updated target service, that the user request is a non-test request, and determine at least one service requested by the user request;

[0129] The second path generation submodule is used to generate a path for the at least one service according to the user request.

[0130] According to an embodiment of the present invention, by deploying the updated target service while providing the target service before the update, receiving a user request for the target service, determining whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the updated target service, and calling the requested target service according to the path of the service requested by the user request, so that when the service is upgraded, the updated target service and the target service before the update are provided at the same time, and the requests of non-test users and test users are automatically diverted, thereby ensuring that non-test users continue to use the service before the update normally while test users can also use the updated service normally, so as to quickly debug the upgraded service and ensure the stability of service provision.

[0131] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it includes a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904.

[0132] Memory 903, used for storing computer programs;

[0133] The processor 901 is used to implement the steps described in any of the above method embodiments when executing the program stored in the memory 903.

[0134] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0135] The communication interface is used for communication between the above terminal and other devices.

[0136] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0137] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0138] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions. When the instructions are executed on a computer, the computer executes the service calling method described in any one of the above embodiments.

[0139] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the service calling method described in any one of the above embodiments.

[0140] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0141] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0142] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0143] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A service calling method, It is characterized in that include: Deploy the updated target service while providing the target service before the update; receiving a user request for a target service; Determine whether the user request is a test request or a non-test request, and the path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the target service after the update; Invoke the requested target service according to the path of the service requested by the user; The determining whether the user request is a test request or a non-test request, and the path of the service requested by the user request includes: If the user request carries the preset identifier corresponding to the updated target service, the user request is a test request, and the identification information and version information of the updated target service corresponding to the preset identifier of at least one service requested by the user request are determined; generating a path for the at least one service according to the user request, the identification information and the version information; If the user request does not carry the preset identifier corresponding to the updated target service, the user request is a non-test request, and at least one service requested by the user request is determined; A path for the at least one service is generated according to the user request.

2. The method according to claim 1, It is characterized in that Before deploying the updated target service while providing the target service before the update, the method further includes: The preset identifier and the corresponding identifier information and version information of the updated target service are configured.

3. The method according to claim 1, It is characterized in that The calling of the requested target service according to the path of the service requested by the user comprises: Determine the path of the target service node corresponding to each service according to the path of the service requested by the user request; According to the paths of the target service nodes corresponding to the respective services, the user request is forwarded to the target service node corresponding to the target service for processing.

4. The method according to claim 3, It is characterized in that Determining the path of the target service node corresponding to each service according to the path of the service requested by the user request includes: Obtaining, from the first cache, service nodes registered corresponding to services other than the target service; According to the identification information and the version information, obtaining, from the second cache, a service node registered corresponding to the target service; Allocating a target service node corresponding to each service to the user request from the service nodes registered corresponding to each service; According to the path of the service requested by the user request and the target service node corresponding to each service, the path of the target service node corresponding to each service is generated.

5. A service calling device, It is characterized in that include: A service deployment module, used to deploy the updated target service while providing the target service before the update; A request receiving module, used for receiving a user request for a target service; a path determination module, used to determine whether the user request is a test request or a non-test request, and a path of the service requested by the user request; wherein the service requested by the non-test request includes the target service before the update, and the service requested by the test request includes the target service after the update; A first service determination submodule, configured to determine, if the user request carries a preset identifier corresponding to the updated target service, that the user request is a test request, and to determine at least one service requested by the user request, identification information and version information of the updated target service corresponding to the preset identifier; A first path generation submodule, configured to generate a path for the at least one service according to the user request, the identification information and the version information; A second service determination submodule, configured to determine, if the user request does not carry a preset identifier corresponding to the updated target service, that the user request is a non-test request, and determine at least one service requested by the user request; A second path generation submodule, configured to generate a path for the at least one service according to the user request; The service calling module is used to call the requested target service according to the path of the service requested by the user.

6. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-4 when executing a program stored in a memory.

7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Micro-service test method and device

    CN107979508A

  • Micro-service publishing method, device and equipment and medium

    CN110032393A

  • Test automation system for distributed heterogenous environments

    US20190324897A1