Service invocation method, apparatus, device, and medium

By determining the invocation method through grayscale switches and filters within the interceptor, service invocation without a unified gateway is realized, solving the problem of large workload in interface rewriting, reducing costs, and improving security and efficiency.

CN115421857BActive Publication Date: 2026-02-06INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211067717.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-01
Publication Date
2026-02-06
Estimated Expiration
2042-09-01

AI Technical Summary

Technical Problem

During the upgrade of business systems, existing technologies require the use of a unified gateway or rewriting of service request paths to implement routing for multiple versions of business services, resulting in a large workload and high cost for interface rewriting.

Method used

By using grayscale switches and filters within the interceptor, the invocation method is determined based on request tags and container tags, thus implementing a grayscale routing mechanism. This eliminates the need to rewrite the implementation path or call interface of the target service, and utilizes the filters within the interceptor to determine the grayscale routing mechanism.

Benefits of technology

It reduces equipment costs during business system upgrades and improves the security and efficiency of service calls. Users can directly call services, and the entire process is transparent to users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115421857B_ABST
    Figure CN115421857B_ABST
Patent Text Reader

Abstract

The present disclosure provides a service calling method, device, equipment and medium, which can be applied to the field of big data technology. The service calling method comprises: in response to intercepting a first calling request from a calling party, determining the state of an interceptor internal gray switch, the gray switch being used to determine whether to start a gray routing mechanism; in the case of determining that the state of the gray switch is started, determining the calling mode corresponding to the first calling request according to the request label in the first calling request; and calling the target service based on the calling mode.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of big data, and in particular, to a service calling method and device, electronic equipment, storage medium and program product. BACKGROUND

[0002] In the process of upgrading a business system, service requests of multiple users generally need to be routed to multiple versions of business services, and then the service requests of the multiple users are implemented through the multiple versions of business services.

[0003] At present, in the related art, multiple service requests are generally routed to multiple versions of business services through a unified gateway; for business services without a unified gateway, the routing of service requests is implemented by rewriting service request paths. Therefore, there is a technical problem of large interface rewriting workload and high upgrading device cost in the related art. SUMMARY

[0004] In view of the above problems, the present disclosure provides a service calling method and device, equipment, medium method, device, equipment, medium and program product.

[0005] According to a first aspect of the present disclosure, a service calling method is provided, comprising:

[0006] In response to intercepting a first calling request from a calling party, determining the state of a gray switch in the interceptor, the gray switch being used to determine whether to start a gray routing mechanism;

[0007] In a case where it is determined that the state of the gray switch is started, determining a calling mode corresponding to the first calling request according to a request label in the first calling request; and

[0008] Calling a target service based on the calling mode.

[0009] According to an embodiment of the present disclosure, in a case where it is determined that the state of the gray switch is started, the calling mode of the first calling request is determined according to the request label of the first calling request, comprising:

[0010] Obtaining the request label in the first calling request;

[0011] Determining a marking state of the first calling request according to the request label, the marking state being determined by a dyeing label included in the request label; and

[0012] Determining the calling mode of the first calling request according to the marking state.

[0013] According to an embodiment of the present disclosure, wherein the calling mode includes local calling; determining the calling mode of the first calling request according to the marking state, comprising:

[0014] In a case where it is determined that the marking state of the first invocation request is dyed, it is determined that the invocation manner is local invocation.

[0015] According to an embodiment of the present disclosure, the determination of the invocation manner of the first invocation request according to the marking state comprises:

[0016] The container label corresponding to the interceptor is obtained, and the container label is used to represent the container type of the interceptor.

[0017] The gray policy corresponding to the first invocation request is obtained from the configuration center, and the gray policy is used to determine the publishing server of the target service.

[0018] The marking method and the invocation manner corresponding to the first invocation request are determined according to the container label and the gray policy.

[0019] According to an embodiment of the present disclosure, the invocation manner comprises generalized forwarding; and the determination of the marking method and the invocation manner corresponding to the first invocation request according to the container label and the gray policy comprises:

[0020] In a case where the container type of the interceptor is a gray container, the first matching information of the target service and the gray policy is determined according to the first invocation request.

[0021] In a case where the first matching information indicates that the target service matches the gray policy, the dyeing label of the first invocation request is set as a first gray label, and the invocation manner is determined as local invocation.

[0022] In a case where the first matching information indicates that the target service does not match the gray policy, the dyeing label is set as a second gray label, and the invocation manner is determined as generalized forwarding.

[0023] According to an embodiment of the present disclosure, in a case where the container type of the interceptor is a non-gray container, the second matching information of the target service and the gray policy is determined according to the first invocation request.

[0024] In a case where the second matching information indicates that the target service matches the gray policy, the dyeing label of the first invocation request is set as a first gray label, and the invocation manner is determined as generalized forwarding.

[0025] In a case where the second matching information indicates that the target service does not match the gray policy, the dyeing label is set as a second gray label, and the invocation manner is determined as local invocation.

[0026] According to an embodiment of the present disclosure, the target service is invoked based on the invocation manner, comprising:

[0027] In a case where it is determined that the calling manner is the generalization forwarding, a second calling request is constructed, and the second calling request is sent to the publishing server, where the second calling request is used to call the target service through the publishing server, and the tint label of the second calling request includes the first gray label or the second gray label.

[0028] A second aspect of the present disclosure provides a service calling apparatus, comprising: a first determination module configured to determine a state of a gray switch in an interceptor in response to intercepting a first calling request from a caller, the gray switch being configured to determine whether to start a gray routing mechanism;

[0029] A second determination module configured to determine a calling manner of the first calling request according to a request label in the first calling request in a case where it is determined that the state of the gray switch is started.

[0030] A calling module configured to call a target service based on the calling manner.

[0031] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the service calling method.

[0032] A fourth aspect of the present disclosure further provides a computer-readable storage medium having stored executable instructions, which, when executed by a processor, cause the processor to perform the service calling method.

[0033] A fifth aspect of the present disclosure further provides a computer program product comprising a computer program, which, when executed by a processor, implements the service calling method.

[0034] The present disclosure acquires the first calling request from the caller through the interceptor, and determines whether to start the gray routing mechanism based on the interceptor. In a case where it is determined that the state of the gray switch is started, the calling manner is determined according to the request label in the first calling request, and the calling of the target service is implemented based on the calling manner. The present disclosure determines the gray routing mechanism based on the filter inside the interceptor by intercepting the first calling request, without rewriting the implementation path or calling interface of the target service, thereby realizing the service calling without the unified gateway, and reducing the equipment cost in the process of upgrading the business system. In addition, the calling manner provided by the present disclosure can process the first calling request in the interceptor, realize the service calling, and the whole process is not shown to the user, so that the user can directly call the service, which helps to improve the security of the service calling. BRIEF DESCRIPTION OF DRAWINGS

[0035] The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure, taken in conjunction with the accompanying drawings, in which:

[0036] Figure 1 An application scenario of a service calling method according to an embodiment of the present disclosure is schematically shown;

[0037] Figure 2 A flowchart of a service calling method according to an embodiment of the present disclosure is schematically shown;

[0038] Figure 3 A flowchart of a method for determining a calling mode according to an embodiment of the present disclosure is schematically shown;

[0039] Figure 4 A flowchart of a method for determining a calling mode according to a tag state according to an embodiment of the present disclosure is schematically shown;

[0040] Figure 5 A schematic diagram of a service calling method according to a specific embodiment of the present disclosure is schematically shown;

[0041] Figure 6 A schematic diagram of a service calling scenario according to a specific embodiment of the present disclosure is schematically shown;

[0042] Figure 7 A structural block diagram of a service calling apparatus according to an embodiment of the present disclosure is schematically shown; and

[0043] Figure 8 A block diagram of an electronic device suitable for a service calling method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0044] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood, however, that the description is merely for illustration, and is not intended to limit the scope of the present disclosure. In the following detailed description of embodiments of the present disclosure, numerous specific details are set forth in order to provide a thorough understanding of the embodiments. However, it would be apparent to those skilled in the art that the embodiments, or portions thereof, can be practiced without such specific details. In other instances, well-known structures and features have been omitted in order to avoid obscuring the present disclosure.

[0045] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the present disclosure. As used herein, the term "includes" and "including" means the inclusion without limitation of the stated features, steps, operations, and / or components.

[0046] All terms used herein, including technical and scientific terms, have the meanings commonly understood by one of ordinary skill in the art unless otherwise defined. It should be further noted that the use of terms such as first, second, etc. are used herein to merely designate one element from another without necessarily implying any actual such relationship or order.

[0047] In the case of using expressions similar to "at least one of A, B, and C, etc.", it should generally be interpreted to include any of them, more than one of them, or a combination thereof, unless otherwise defined. For example, "a system having at least one of A, B, and C" should be interpreted to include a system having A alone, a system having B alone, a system having C alone, a system having A and B together, a system having A and C together, a system having B and C together, and / or a system having A, B, and C together, etc.

[0048] In the technical solutions of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure, and application of user personal information comply with relevant laws and regulations, necessary security measures are taken, and the public order and good customs are not violated.

[0049] In the technical solutions of the present disclosure, the authorization or consent of the user is obtained before the user's personal information is acquired or collected.

[0050] Embodiments of the present disclosure provide a service calling method, including: in response to intercepting a first calling request from a calling party, determining the state of a gray-scale switch in an interceptor, the gray-scale switch being used to determine whether to start a gray-scale routing mechanism; in a case where it is determined that the state of the gray-scale switch is started, determining a calling mode corresponding to the first calling request according to a request label in the first calling request; and calling a target service based on the calling mode.

[0051] Figure 1 An application scenario of a service calling method according to an embodiment of the present disclosure is schematically shown.

[0052] As shown in Figure 1 The application scenario 100 according to this embodiment can include server clusters 101, 102, and a network 103. The network 103 is a medium for providing a communication link between the server cluster 101 and the server cluster 102, and can also provide a communication link between multiple servers within the server cluster 101 or the server cluster 102. The network 103 can include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0053] The plurality of servers in the server clusters 101 and 102 can be servers that provide various services, such as making a call to a service initiated by a user, supporting a specific function of the called service (e.g., querying a balance, obtaining a recommended financial product, generating a query report, etc.). The servers in the server clusters 101 and 102 can provide the same services, and can also provide different services.

[0054] It should be noted that the service calling method provided by the embodiments of the present disclosure can generally be executed by the servers in the server clusters 101 and 102. Accordingly, the service calling apparatus provided by the embodiments of the present disclosure can generally be arranged in the server clusters 101 and 102. The service calling method provided by the embodiments of the present disclosure can also be executed by a server or a server cluster different from the server clusters 101 and 102 and capable of intercepting a user call request. Accordingly, the service calling apparatus provided by the embodiments of the present disclosure can also be arranged in a server or a server cluster different from the server clusters 101 and 102 and capable of intercepting a user call request.

[0055] It should be understood that Figure 1 The number of server clusters and the number of servers in the server clusters are merely illustrative. According to the needs of implementation, there can be any number of server clusters and any number of servers in the server clusters.

[0056] The service calling method according to the embodiments of the present disclosure will be described in detail below based on the scenario described above. Figure 1 Figures 2-6 The service calling method according to the embodiments of the present disclosure will be described in detail below based on the scenario described above.

[0057] Figure 2 A flowchart of a service calling method according to an embodiment of the present disclosure is schematically shown.

[0058] As shown in Figure 2 , the method includes operations S210-S230.

[0059] At operation S210, in response to intercepting a first call request from a caller, a state of a gray switch in an interceptor is determined, the gray switch being used to determine whether to start a gray routing mechanism.

[0060] According to an embodiment of the present disclosure, a caller can initiate a first call request to obtain a target service to be called. For the first call request initiated by the caller, the distributed service framework can intercept the first call request through a self-configured interceptor, and then determine, in the interceptor, the target service corresponding to the first call request and a manner of calling the target service.

[0061] ​For example, taking the distributed service framework dubbo as an example. After the first invocation request is initiated by the calling party, the first invocation request is intercepted by the native filter interceptor in the dubbo framework, and then the call of the target service corresponding to the first invocation request is implemented in the filter interceptor.

[0062] According to an embodiment of the present disclosure, the form of the first invocation request comprises a Remote Procedure Call (RPC) request.

[0063] According to an embodiment of the present disclosure, a gray switch is configured in the interceptor, which is used to determine whether to start the gray routing mechanism. After intercepting the first invocation request, the interceptor can determine the state of the gray switch.

[0064] The state of the gray switch includes starting and stopping. When the state of the gray switch is starting, it indicates that the target service corresponding to the first invocation request is in the gray publishing stage; when the state of the gray switch is stopping, it indicates that the target service corresponding to the first invocation request is in the normal invocation stage. Gray publishing can ensure the stability of the overall system during version switching. Among them, gray publishing refers to a publishing method that smoothly transitions between black and white, for example, a publishing method that smoothly transitions between two versions of business services.

[0065] Specifically, the interceptor can be configured with a filter inside, which is used to determine the state of the gray switch. In response to intercepting the first invocation request from the calling party, the filter connects the configuration center through an interface, and obtains configuration information from the configuration center according to the first invocation request to determine the state of the gray switch.

[0066] For example, the configuration information indicates that the current target service is in the version switching stage, and the filter determines that the state of the gray switch is starting; the configuration information indicates that the current target service is in the normal invocation stage, and the filter determines that the state of the gray switch is stopping.

[0067] In operation S220, in a case where it is determined that the state of the gray switch is starting, the invocation mode corresponding to the first invocation request is determined according to the request tag in the first invocation request.

[0068] According to an embodiment of the present disclosure, in a case where it is determined that the state of the gray switch is starting, the distributed service framework obtains the request tag of the first invocation request through a function. For example, the request tag of the first invocation request is obtained through the getTag() function under the CocoaUtils class.

[0069] According to an embodiment of the present disclosure, the request label can comprise a dyeing label. In a case where it is determined that the state of the grayscale switch is turned on, a filter within the distributed service framework can determine whether there is a routing strategy for the target service corresponding to the first invocation request according to the dyeing label. Specifically, the request label with the dyeing label indicates that the target service has established a routing strategy, and the invocation manner is local invocation; the request label without the dyeing label indicates that the target service has not established a routing strategy, and the filter performs marking processing on the first invocation request to obtain a dyeing label, so that the filter determines the invocation manner of the target service according to the dyeing.

[0070] In operation S230, the target service is invoked based on the invocation manner.

[0071] According to an embodiment of the present disclosure, after determining the invocation manner corresponding to the first invocation request, the target service can be invoked according to the invocation manner.

[0072] For example, for grayscale release, server A can support the function of the target service corresponding to the first invocation request, and server B can also support the function of the target service. Different users initiate invocation requests which are executed by server A or server B according to different invocation manners. Specifically, after determining the invocation manner, server A supporting the filter can invoke the target service; or the processed first invocation request can be forwarded to server B so that server B invokes the target service.

[0073] The present disclosure considers that in the related art, the method for implementing the grayscale routing strategy by the service group comprises: uniform gateway interception forwarding or drainage layer interception forwarding. Specifically, the uniform gateway implements interception forwarding by building a gateway layer. For the services that have been deployed, a front gateway layer needs to be added to implement interception forwarding. However, when the front gateway layer is added to all services, the security risk of all services is increased; and when the front gateway layer fails or has a security risk, the normal operation of all service requests is affected, the influence range is large, and the maintenance cost is high.

[0074] For the drainage layer interception forwarding, the service invocation is implemented by building a uniform drainage layer. Specifically, the interception forwarding by the drainage layer needs to rewrite all service request paths, and the original request path is changed from “request->service A” to “request->drainage layer service A’->service A”. The rewriting workload increases linearly with the number of service interfaces, and the rewriting workload and cost are high. Moreover, for the invoker, the invoked service is the drainage layer service A’, and service A is transparent to the invoker.

[0075] The present disclosure acquires a first call request from a calling party by an interceptor, and determines whether to start a gray-scale routing mechanism based on the interceptor. In a case where it is determined that the state of a gray-scale switch is started, a calling mode is determined according to a request tag in the first call request, and the calling of a target service is implemented based on the calling mode. The present disclosure determines the gray-scale routing mechanism based on a filter inside the interceptor by intercepting the first call request, without rewriting the implementation path or calling interface of the target service, so as to implement the service calling without a unified gateway, and reduce the equipment cost in the process of upgrading the business system.

[0076] In addition, considering that the service called when the drainage layer is built is the drainage layer service A', rather than the service A, and the service A is transparent to the calling party. The calling mode provided by the present disclosure can process the first call request in the interceptor, implement the service calling, and the whole process is not exhibited to the user, so that the user can directly call the service, which helps to improve the security of the service calling.

[0077] Figure 3 A method flowchart for determining a calling mode according to an embodiment of the present disclosure is schematically shown.

[0078] As shown in Figure 3 In a case where it is determined that the state of the gray-scale switch is started, the calling mode of the first call request is determined according to the request tag of the first call request, including operation S321 to operation S323. Operation S321 to operation S323 can be one specific embodiment of operation S220.

[0079] In operation S321, the request tag in the first call request is acquired.

[0080] According to an embodiment of the present disclosure, after the distributed service framework intercepts the first call request, the request tag of the first call request can be acquired by a function. For example, the request tag of the first call request is acquired by a getTag() function under the CocoaUtils class.

[0081] In operation S322, the marking state of the first call request is determined according to the request tag, and the marking state is determined by the dyeing tag included in the request tag.

[0082] According to an embodiment of the present disclosure, when the request tag includes the dyeing tag, the marking state of the first call request is dyed, indicating that the calling mode can be directly determined according to the first call request; when the request tag does not include the dyeing tag, the marking state of the first call request is not dyed, indicating that the first call request is dyed first, and the calling mode is determined according to the dyed first call request after the dyeing tag is configured.

[0083] In operation S323, the calling mode of the first call request is determined according to the marking state.

[0084] According to an embodiment of the present disclosure, after determining the marking state of the first invocation request according to the request tag, the specific invocation manner can be determined according to the marking state.

[0085] According to an embodiment of the present disclosure, the invocation manner includes local invocation. In a case where the marking state of the first invocation request is determined to be dyed, the invocation manner is determined to be local invocation. The local server can execute the processing logic according to the first invocation request to obtain an execution result, so as to realize the invocation of the target service.

[0086] According to an embodiment of the present disclosure, in a case where the state of the grayscale switch is determined to be off, the invocation manner corresponding to the first invocation request is local invocation, and at this time, the grayscale routing mechanism does not take effect. Specifically, the local invocation can be realized through an invoker.

[0087] Figure 4 A method flowchart for determining the invocation manner according to the marking state according to an embodiment of the present disclosure is schematically shown;

[0088] As shown in Figure 4 The method of this embodiment includes operation S4231 to operation S4233, which can be a specific embodiment of operation S323.

[0089] According to an embodiment of the present disclosure, the marking state of the first invocation request is undyed, indicating that the first invocation request is intercepted for the first time. In combination with the grayscale policy corresponding to the interface of the first invocation request, it can be determined whether the first invocation request needs to be forwarded to other servers for operation. For example, the first invocation request can be dyed first, and then the invocation manner of the first invocation request is determined according to the grayscale policy.

[0090] In operation S4231, a container tag corresponding to the interceptor is obtained, and the container tag is used to indicate the container type of the interceptor.

[0091] According to an embodiment of the present disclosure, the distributed service framework can include multiple containers, and the container type of the interceptor can be determined according to the container tag. Specifically, the container type includes a grayscale container and a non-grayscale container. The grayscale container and the non-grayscale container can both dye the first invocation request. After dyeing, the grayscale container locally invokes the first invocation request with the grayscale tag; and generalizes and forwards the first invocation request with the non-grayscale tag, so as to be locally invoked by the non-grayscale container. Similarly, after dyeing, the non-grayscale container locally invokes the first invocation request with the non-grayscale tag; and generalizes and forwards the first invocation request with the grayscale tag, so as to be locally invoked by the grayscale container.

[0092] According to an embodiment of the present disclosure, the container tag can be obtained through a function in a system management class. For example, the container tag is obtained through a getenv function in a system class, and the calling instruction can be getenv(“Tag”). The container tag is attribute information configured in a service cluster application configuration file.

[0093] In operation S4232, a gray-scale policy corresponding to the first calling request is obtained from the configuration center, and the gray-scale policy is used to determine a release server of the target service.

[0094] According to an embodiment of the present disclosure, the gray-scale policy stored in the configuration center is in the form of a json string. After connecting the configuration center through a preset method such as apollo, the gray-scale policy corresponding to the first calling request is obtained through an SDK interface of the configuration center. In the process of intercepting the first calling request to return the calling result of the target service, the dynamic configuration item is separated from the target service and the deployment program, and the gray-scale policy and the like can be updated through hot loading, so as to facilitate quick and convenient adjustment of whether to start the gray-scale routing mechanism, whether to perform dyeing, and the like.

[0095] According to an embodiment of the present disclosure, the gray-scale policy can also be stored in a local database, so as to directly call the gray-scale policy for operation. Specifically, the method for obtaining the gray-scale policy or other dynamic configuration items can be determined according to actual conditions.

[0096] In operation S4233, a marking method and a calling mode corresponding to the first calling request are determined according to the container tag and the gray-scale policy.

[0097] According to an embodiment of the present disclosure, after obtaining the gray-scale policy, the marking method and the calling mode corresponding to the first calling request can be determined according to the container tag and the gray-scale policy. The calling mode includes local calling, and also includes generalized forwarding.

[0098] For ease of description, the gray-scale container determines whether the target service matches the gray-scale policy through first matching information, and the non-gray-scale container determines whether it matches the gray-scale policy through second matching information. The first matching information and the second information are the same or similar.

[0099] The dyeing tag includes two types of gray-scale tags and non-gray-scale tags, which are different types of tags under the gray-scale routing mechanism. For ease of description, the gray-scale tag is referred to as a first gray-scale tag, and the non-gray-scale tag is referred to as a second gray-scale tag.

[0100] According to an embodiment of the present disclosure, in a case where it is determined that the container type of the interceptor is a gray container, first matching information of the target service and the gray policy is determined according to the first invocation request. The first matching information includes matching and non-matching. In a case where the first matching information indicates that the target service matches the gray policy, a dyeing label of the first invocation request is set as a first gray label, and the invocation mode is determined as local invocation.

[0101] In a case where the first matching information indicates that the target service does not match the gray policy, the dyeing label is set as a second gray label, and the invocation mode is determined as generalized forwarding. Specifically, in a case where it is determined that the invocation mode is generalized forwarding, a server corresponding to the non-gray container is invoked to obtain the target service according to the updated first invocation request.

[0102] According to an embodiment of the present disclosure, the implementation can be achieved by using the generalized forwarding mechanism of the distributed service framework dubbo. The service invocation can be implemented without obtaining the API interface and model class of the provider.

[0103] According to an embodiment of the present disclosure, in a case where it is determined that the container type of the interceptor is a non-gray container, second matching information of the target service and the gray policy is determined according to the first invocation request. In a case where the second matching information indicates that the target service matches the gray policy, a dyeing label of the first invocation request is set as a first gray label, and the invocation mode is determined as generalized forwarding. In a case where the second matching information indicates that the target service does not match the gray policy, the dyeing label is set as a second gray label, and the invocation mode is determined as local invocation.

[0104] According to an embodiment of the present disclosure, the invocation method can also be determined as local invocation or generalized forwarding by other methods. In a case where the container label and the gray policy match, the local invocation is performed after dyeing; in a case where the container label and the gray policy do not match, the invocation is performed in another type of container after forwarding.

[0105] According to an embodiment of the present disclosure, as a micro-service gray implementation, services are invoked through rpc requests, and whether dyeing forwarding is needed is determined by analyzing the gray label of the implicit parameter in the request rpcContext and the container label of the first invocation request. The micro-service routing forwarding according to the gray policy is implemented, and the gray release is implemented.

[0106] The present disclosure determines the labeling method and invocation mode of the target service through the container label and the gray policy, automatically determines the dyeing, forwarding and invocation under the gray routing mechanism, and does not need manual participation in the labeling process, so that the gray routing of the existing service is implemented, and the efficiency of the gray invocation is improved.

[0107] Figure 5 A schematic diagram of a service calling method according to an embodiment of the present disclosure is shown.

[0108] As shown in Figure 5 , as an embodiment, the service calling method includes operations S501-S512. In operation S501, a request is intercepted. Specifically, after the calling party initiates a first calling request, the interceptor intercepts the first calling request. In operation S502, it is determined whether a gray scale switch is on. Specifically, the gray scale switch can be a CMC global switch, and the CMC configuration center is connected through apollo to determine the state of the switch.

[0109] In the case where it is determined that the gray scale switch is on, operation S503 is entered to determine whether a dyeing label is included. Specifically, before determining whether the dyeing label is included, the dyeing label is obtained through a function. The dyeing label is an in-application label, including a gray scale label and a non-gray scale label. Determining that the dyeing label is included can be a case where it is determined that the gray scale label and / or the non-gray scale label is included. In the case where it is determined that the dyeing label is included, operation S512 is entered, it is determined that the calling mode is local calling, and the calling result is returned through local calling.

[0110] In the case where it is determined that the dyeing label is not included, operation S504 is entered to determine whether it is a gray scale container. Specifically, the container label can be obtained, and then it is determined whether the current container is a gray scale container according to the container label. In the case where it is determined that the current container is a gray scale container, operation S505 is entered to determine whether the gray scale policy matches the target service, and then dyeing processing under the gray scale container is performed. In the case where it is determined that the current container is a non-gray scale container, operation S509 is entered to determine whether the gray scale policy matches the target service, and then dyeing processing under the non-gray scale container is performed. Specifically, the gray scale policy can be obtained from the configuration center, and then it is determined whether the gray scale policy matches the target service.

[0111] In operation S506, when it is determined that the gray scale policy matches the target service, the dyeing label is set to a first gray scale label. Similarly, in operation S510, when it is determined that the gray scale policy matches the target service, the dyeing label is set to a first gray scale label. At this time, the request label includes the dyeing label, and the type of the dyeing label is a gray scale label.

[0112] In operation S507, when it is determined that the gray scale policy does not match the target service, the dyeing label is set to a second gray scale label. Similarly, in operation S511, when it is determined that the gray scale policy does not match the target service, the dyeing label is set to a second gray scale label. At this time, the request label includes the dyeing label, and the type of the dyeing label is a non-gray scale label.

[0113] For the gray container, after the dyeing label is set as the second gray label in operation S507, it enters operation S508 generalization forwarding; for the non-gray container, after the dyeing label is set as the first gray label in operation S510, it enters operation S508 generalization forwarding. Specifically, after the dyeing label is set, it indicates that the first calling request has been dyed, and the first calling request is forwarded to the non-gray container for processing.

[0114] For the gray container, after the dyeing label is set as the first gray label in operation S506, it enters operation S512 local calling. Specifically, the first calling request is processed by the gray container. For the non-gray container, after the dyeing label is set as the second gray label in operation S511, it enters operation S512 local calling. Specifically, the first calling request is processed by the non-gray container.

[0115] According to an embodiment of the present disclosure, in the case of determining that the calling mode is generalization forwarding, the dyed first calling request needs to be forwarded to another type of container for processing. Specifically, a second calling request can be constructed based on the dyed first calling request and forwarded.

[0116] The gray container and the non-gray container can be set in the same server, and can also be set in different servers. When generalization forwarding is performed, the second calling request is forwarded to the server where the container of another type is located, and the target service is called through the publishing server. The dyeing label of the second calling request includes the first gray label or the second gray label obtained by dyeing during processing the first calling request.

[0117] For example, for the convenience of description, the request received by the container of the current type is called the first calling request, and the request received by the container of another type is called the second calling request. Specifically, server A includes a gray container and a non-gray container, the request received by the gray container is called the first calling request, and the request received by the non-gray container after generalization forwarding is called the second calling request. Or, the request received by the non-gray container is called the first calling request, and the request received by the gray container after generalization forwarding is called the second calling request. Or, server A includes a gray container, and server B includes a non-gray container, the request received by the gray container in server A is called the first calling request, and the request received by the non-gray container in server B after generalization forwarding is called the second calling request. Or, server A includes a non-gray container, and server B includes a gray container, the request received by the non-gray container in server A is called the first calling request, and the request received by the gray container in server B after generalization forwarding is called the second calling request.

[0118] Figure 6 A schematic diagram of a service calling scenario according to an embodiment of the present disclosure is schematically shown.

[0119] AsFigure 6 As shown, as one specific embodiment, the distributed service framework intercepts the rpc call request 601 from the calling party through the interceptor, and then transmits the rpc call request 601 to the first filter 603 and / or the second filter 604 inside the interceptor. The number of filters can be one, or two or more, which are used to determine the target service corresponding to the first call request. According to an embodiment of the present disclosure, in order to facilitate understanding, one filter is arranged in the microservice non-gray cluster and the microservice gray cluster respectively to process the rpc call request 601.

[0120] For the microservice non-gray cluster, the first filter 603 receives the rpc call request 601, and then determines the state of the gray switch according to the rpc call request 601. In the case that the state of the gray switch is off, the service A1 is called locally 605, and the call result is returned. In the case that the state of the gray switch is on, it is determined whether the request label of the rpc call request 601 includes the dyeing label. In the case that the request label includes the dyeing label, the service A1 is called locally 605, and the call result is returned.

[0121] Similarly, for the microservice gray cluster, the second filter 604 receives the rpc call request 601, and then determines the state of the gray switch according to the rpc call request 601. In the case that the state of the gray switch is off, the service A2 is called locally 606, and the call result is returned. In the case that the state of the gray switch is on, it is determined whether the request label of the rpc call request 601 includes the dyeing label. In the case that the request label includes the dyeing label, the service A2 is called locally 606, and the call result is returned.

[0122] In the case that the request label does not include the dyeing label, the type of the container label is determined.

[0123] For the microservice non-gray cluster, it is determined that the container type is a non-gray container. In the case that the target service matches the gray policy, the dyeing label is set to the first gray label, and it is determined that the calling mode is general forwarding. The first filter 603 forwards the first call request to the second filter 604 after dyeing, so that the second filter 604 returns the call result by calling the service A2 locally. In the case that the target service does not match the gray policy, the dyeing label is set to the second gray label, and it is determined that the calling mode is local calling; then the service A1 is called 605 to return the call result.

[0124] Similarly, for the micro-service gray-scale cluster, the container type is determined as a gray-scale container. In the case that the target service matches the gray-scale policy, the dyeing label is set as the first gray-scale label, the calling mode is determined as a local call, and then the service A2 is called 606 through the local function, and the calling result is returned. In the case that the target service does not match the gray-scale policy, the dyeing label is set as the second gray-scale label, and the calling mode is determined as a generalization forwarding. The first calling request is forwarded to the first filter 603 after dyeing by the second filter 604, so that the first filter 603 returns the calling result by calling the service A1 locally.

[0125] The present disclosure determines the gray-scale routing mechanism based on the filters inside the interceptor by intercepting the first calling request, without rewriting the implementation path or calling interface of the target service, to realize service calling without a unified gateway, and reduce the service calling cost in the process of upgrading the business system.

[0126] According to the embodiments of the present disclosure, the gray-scale routing can be realized by intercepting the generalization forwarding. The generalization forwarding and the unified drainage layer can also be combined. Specifically, the stock service realizes the gray-scale routing by intercepting the generalization forwarding, the incremental service realizes the service calling without a unified gateway through the double-flow gray-scale scheme by realizing the routing through the drainage layer service.

[0127] Figure 7 A structural block diagram of a service calling apparatus according to an embodiment of the present disclosure is schematically shown.

[0128] As shown in Figure 7 the service calling apparatus 700 of the embodiment includes a first determination module 710, a second determination module 720 and a calling module 730.

[0129] The first determination module 710 is configured to determine the state of a gray-scale switch inside the interceptor in response to intercepting a first calling request from a calling party, the gray-scale switch being used to determine whether to start the gray-scale routing mechanism. In an embodiment, the first determination module 710 can be configured to perform the operation S210 described in the foregoing, and details are not described herein again.

[0130] The second determination module 720 is configured to determine the calling mode of the first calling request according to the request label in the first calling request in the case that the state of the gray-scale switch is determined to be started. In an embodiment, the second determination module 720 can be configured to perform the operation S220 described in the foregoing, and details are not described herein again.

[0131] The calling module 730 is configured to call the target service based on the calling mode. In an embodiment, the calling module 730 can be configured to perform the operation S230 described in the foregoing, and details are not described herein again.

[0132] According to an embodiment of the present disclosure, the second determining module 720 comprises a first determining sub-module, a second determining sub-module and a third determining sub-module.

[0133] The first determining sub-module is configured to obtain the request label in the first calling request. In an embodiment, the first determining sub-module can be configured to perform the operation S321 described above, and details are not repeated here.

[0134] The second determining sub-module is configured to determine the marking state of the first calling request according to the request label, the marking state being determined by the dyeing label included in the request label. In an embodiment, the second determining sub-module can be configured to perform the operation S322 described above, and details are not repeated here.

[0135] The third determining sub-module is configured to determine the calling mode of the first calling request according to the marking state. In an embodiment, the third determining sub-module can be configured to perform the operation S323 described above, and details are not repeated here.

[0136] According to an embodiment of the present disclosure, the third determining sub-module comprises a first determining unit, a second determining unit and a third determining unit.

[0137] The first determining unit is configured to obtain a container label corresponding to the interceptor, the container label being used to represent a container type of the interceptor. In an embodiment, the first determining unit can be configured to perform the operation S4231 described above, and details are not repeated here.

[0138] The second determining unit is configured to obtain a gray-scale policy corresponding to the first calling request from a configuration center, the gray-scale policy being used to determine a publishing server of the target service. In an embodiment, the second determining unit can be configured to perform the operation S4232 described above, and details are not repeated here.

[0139] The third determining unit is configured to determine a marking method and a calling mode corresponding to the first calling request according to the container label and the gray-scale policy. In an embodiment, the third determining unit can be configured to perform the operation S4233 described above, and details are not repeated here.

[0140] According to an embodiment of the present disclosure, the third determining sub-module further comprises a fourth determining unit.

[0141] The fourth determining unit is configured to determine that the calling mode is local calling in a case where the marking state of the first calling request is dyed.

[0142] According to an embodiment of the present disclosure, the third determining unit comprises a first determining sub-unit, a second determining sub-unit, a third determining sub-unit, a fourth determining sub-unit, a fifth determining sub-unit and a sixth determining sub-unit.

[0143] The first determining sub-unit is configured to determine, according to the first calling request, first matching information of the target service and the gray policy in a case where the container type of the interceptor is determined as the gray container.

[0144] The second determining sub-unit is configured to set a dye label of the first calling request as a first gray label and determine the calling mode as local calling in a case where the first matching information indicates that the target service matches the gray policy.

[0145] The third determining sub-unit is configured to set the dye label as a second gray label and determine the calling mode as generalized forwarding in a case where the first matching information indicates that the target service does not match the gray policy.

[0146] The fourth determining sub-unit is configured to determine, according to the first calling request, second matching information of the target service and the gray policy in a case where the container type of the interceptor is determined as the non-gray container.

[0147] The fifth determining sub-unit is configured to set a dye label of the first calling request as a first gray label and determine the calling mode as generalized forwarding in a case where the second matching information indicates that the target service matches the gray policy.

[0148] The sixth determining sub-unit is configured to set the dye label as a second gray label and determine the calling mode as local calling in a case where the second matching information indicates that the target service does not match the gray policy.

[0149] According to an embodiment of the present disclosure, the calling module 730 comprises a first calling unit configured to construct a second calling request and send the second calling request to the publishing server in a case where the calling mode is determined as generalized forwarding, wherein the second calling request is used to call the target service through the publishing server, and a dye label of the second calling request comprises the first gray label or the second gray label.

[0150] Figure 8 A block diagram of an electronic device suitable for the service calling method according to an embodiment of the present disclosure is schematically shown.

[0151] As Figure 8As shown, the electronic device 800 according to embodiments of the present disclosure includes a processor 801, which can perform various appropriate actions and processes according to programs stored in a read only memory (ROM) 802 or loaded into a random access memory (RAM) 803 from a storage section 808. The processor 801 can include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor, and / or a related chip set, and / or a dedicated microprocessor (e.g., an application specific integrated circuit (ASIC)), and so on. The processor 801 can also include an on-board memory for cache use. The processor 801 can include a single processing unit or multiple processing units for executing different actions of the method processes according to embodiments of the present disclosure.

[0152] In the RAM 803, various programs and data required for the operation of the electronic device 800 are stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. The processor 801 performs various operations of the method processes according to embodiments of the present disclosure by executing the programs in the ROM 802 and / or the RAM 803. Note that the programs can also be stored in one or more memories other than the ROM 802 and the RAM 803. The processor 801 can also perform various operations of the method processes according to embodiments of the present disclosure by executing the programs stored in the one or more memories.

[0153] According to embodiments of the present disclosure, the electronic device 800 can further include an input / output (I / O) interface 805, which is also connected to the bus 804. The electronic device 800 can further include one or more of the following components connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as necessary. A removable recording medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 810 as necessary, so that a computer program read therefrom is installed into the storage section 808 as necessary.

[0154] The present disclosure also provides a computer readable storage medium, which can be included in the device / apparatus / system described in the above embodiments; or can exist separately without being assembled into the device / apparatus / system. The above computer readable storage medium carries one or more programs, which when executed, implement the method according to embodiments of the present disclosure.

[0155] According to an embodiment of the present disclosure, the computer readable storage medium can be a nonvolatile computer readable storage medium, for example, can include but not limited to: a portable computer diskette, a hard disk, a random access memory (RAM), a read only memory (ROM), an erasable programmable read only memory (EPROM or flash memory), a portable compact disc read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination thereof. In the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, the computer readable storage medium can include the ROM 802 and / or the RAM 803 described above and / or one or more memory other than the ROM 802 and the RAM 803.

[0156] Embodiments of the present disclosure also include a computer program product, which includes a computer program containing program codes for executing the methods shown in the flowcharts. When the computer program product is run in a computer system, the program codes are used to make the computer system implement the service calling method provided by the embodiments of the present disclosure.

[0157] The above functions defined in the system / device of the embodiments of the present disclosure are performed when the computer program is executed by the processor 801. According to an embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by computer program modules.

[0158] In one embodiment, the computer program can rely on tangible storage media such as optical storage media, magnetic storage media, etc. In another embodiment, the computer program can also be transmitted, distributed, and downloaded in the form of signals on network media, and be downloaded and installed through the communication part 809, and / or installed from the detachable medium 811. The program codes contained in the computer program can be transmitted by any appropriate network media, including but not limited to: wireless, wired, etc., or any appropriate combination thereof.

[0159] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the detachable medium 811. When the computer program is executed by the processor 801, the above functions defined in the system of the embodiments of the present disclosure are performed. According to an embodiment of the present disclosure, the system, device, apparatus, module, unit, etc. described above can be implemented by computer program modules.

[0160] According to embodiments of the present disclosure, program code of the computer programs provided by embodiments of the present disclosure can be written in any combination of one or more programming languages, and specifically, these computer programs can be implemented using a high-level procedural and / or object-oriented programming language, and / or an assembly / machine language. The programming language includes, but is not limited to, a programming language such as Java, C++, Python, "C" language, or a similar programming language. The program code can be executed entirely on a user computing device, partially on a user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case involving a remote computing device, the remote computing device can be connected to the user computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, connected through the Internet by using an Internet service provider).

[0161] The flow diagrams and the block diagrams in the drawings are illustrations of possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flow diagrams, and combinations thereof, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.

[0162] Those skilled in the art can understand that the features described in various embodiments of the present disclosure and / or claims can be combined or / and integrated, even if such combinations or integrations are not explicitly described in the present disclosure. In particular, the features described in various embodiments of the present disclosure and / or claims can be combined and / or integrated in various combinations, without departing from the spirit and teachings of the present disclosure. All such combinations and / or integrations are within the scope of the present disclosure.

[0163] The specific embodiments described above are intended to be illustrative of the present disclosure and its best mode known to the inventors at the time of filing the application. It is understood that the present disclosure is not limited to the specific embodiments described above, but includes any and all alternatives falling within the scope of the present disclosure.

Claims

1. A service calling method, comprising: determining a state of a gray-scale switch in an interceptor in response to intercepting a first calling request from a caller, the gray-scale switch being used to determine whether to start a gray-scale routing mechanism; determining a calling mode corresponding to the first calling request according to a request label in the first calling request in a case where the state of the gray-scale switch is determined to be started; and calling a target service based on the calling mode; wherein, in a case where the state of the gray-scale switch is determined to be started, determining the calling mode of the first calling request according to the request label of the first calling request comprises: obtaining the request label in the first calling request; determining a marking state of the first calling request according to the request label, the marking state being determined by a dyeing label included in the request label, the request label existing a dyeing label indicating that the target service has established a routing strategy, and the calling mode being local calling; the request label not existing a dyeing label indicating that the target service has not established a routing strategy, and a dyeing label being obtained by marking processing of the first calling request through a filter; and determining the calling mode of the first calling request according to the marking state. The determining the calling mode of the first calling request according to the marking state comprises, in a case where the marking state of the first calling request is determined to be un-dyed, 2. The method of claim 1, wherein, obtaining a container label corresponding to the interceptor, the container label being used to indicate a container type of the interceptor; obtaining a gray-scale strategy corresponding to the first calling request from a configuration center, the gray-scale strategy being used to determine a publishing server of the target service; and determining a marking method and a calling mode corresponding to the first calling request according to the container label and the gray-scale strategy. The calling mode comprises generalized forwarding; and the determining the marking method and the calling mode corresponding to the first calling request according to the container label and the gray-scale strategy comprises:

3. The method of claim 2, wherein, determining first matching information of the target service and the gray-scale strategy according to the first calling request in a case where the container type of the interceptor is determined to be a gray-scale container; setting a dyeing label of the first calling request to a first gray-scale label and determining the calling mode to be local calling in a case where the first matching information indicates that the target service matches the gray-scale strategy; and setting the dyeing label to a second gray-scale label and determining the calling mode to be generalized forwarding in a case where the first matching information indicates that the target service does not match the gray-scale strategy. 4.The method of claim 3, further comprising: determining second matching information of the target service and the gray-scale strategy according to the first calling request in a case where the container type of the interceptor is determined to be a non-gray-scale container; setting the dyeing label of the first calling request to the first gray-scale label and determining the calling mode to be generalized forwarding in a case where the second matching information indicates that the target service matches the gray-scale strategy; and ​ ​ In a case where the second matching information indicates that the target service does not match the gray-scale policy, the dyeing label is set as a second gray-scale label, and the calling mode is determined as local calling.

5. The method of claim 3, wherein, Based on the calling mode, the target service is called, including: In a case where it is determined that the calling mode is the generalized forwarding, a second calling request is constructed, and the second calling request is sent to the publishing server, where the second calling request is used to call the target service through the publishing server, and the dyeing label of the second calling request includes the first gray-scale label or the second gray-scale label.

6. A service calling apparatus, comprising: a first determination module configured to determine a state of a gray-scale switch in an interceptor in response to intercepting a first calling request from a caller, the gray-scale switch being used to determine whether to start a gray-scale routing mechanism; a second determination module configured to determine a calling mode of the first calling request according to a request label in the first calling request in a case where it is determined that the state of the gray-scale switch is started; and a calling module configured to call a target service based on the calling mode; the second determination module is further configured to acquire the request label in the first calling request; determine a marking state of the first calling request according to the request label, the marking state being determined by a dyeing label included in the request label, the request label including the dyeing label indicating that a routing policy of the target service has been established, and the calling mode being local calling; and the request label not including the dyeing label indicating that the routing policy of the target service has not been established, and the first calling request being marked by a filter to obtain the dyeing label; and determine the calling mode of the first calling request according to the marking state.

7. An electronic device, comprising: one or more processors; a storage device configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method according to any one of claims 1-5.

8. A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method according to any one of claims 1-5.

9. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-5. ​

Citation Information

Patent Citations

  • PaaS platform service scheduling method and device and PaaS platform

    CN113452776A