A service calling method and device
By dynamically adjusting the routing rules, the service call efficiency reduction caused by LH packet instance failure in the prior art is solved, and efficient service call without manual intervention and application restart is achieved.
Patent Information
- Application Number
- CN202010333542.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-24
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2040-04-24
AI Technical Summary
In the prior art, when an LH packet instance fails, it is necessary to manually modify the routing rules and restart the application, resulting in a reduced efficiency of service calls.
Provide a service calling method and device, by obtaining information about calling services, determining dependent service packets and instances based on pre-configured routing rules, realizing dynamic adjustment of routing rules to avoid manual intervention and application restart.
Improve the efficiency of service calls, ensure the stability and reliability of the service, and adjust the dependency service grouping without modifying the code and restarting the application.
Smart Images

Figure CN113556370B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a service calling method and device. Background Art
[0002] In Internet applications, more and more applications use microservice architecture design to cope with the growing demand. Applications designed with microservice architecture often need to call dependent services through cross-process, cross-server, etc. In actual application scenarios, the application provides service A to the outside world. Service A depends on the LH group instance of the address service. Then service A needs to call the LH group instance of the address service to provide external services.
[0003] In the prior art, the routing rules are fixed. If an LH grouping instance fails, the LH grouping instance is adjusted to an MJQ grouping instance. This requires manual modification of the routing rules and restarting the application to make the modification effective.
[0004] However, restarting the application in the existing technology will reduce the efficiency of service calling. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a service calling method and device, which can improve the efficiency of service calling.
[0006] In a first aspect, an embodiment of the present invention provides a service calling method, comprising:
[0007] Get information about calling services;
[0008] Determine, according to a plurality of pre-configured routing rules, whether there is a dependent service group matching the information;
[0009] If there is a dependent service group matching the information, determining the dependent service instance corresponding to the information according to a preset corresponding relationship between the dependent service group and the dependent service instance;
[0010] Call the dependent service instance corresponding to the information.
[0011] Optionally,
[0012] The information includes: the IP address of the server where the calling service is located;
[0013] The routing rules include: the corresponding relationship between the IP address of the server and the dependent service group.
[0014] Optionally,
[0015] The information includes: a calling service group corresponding to the calling service;
[0016] The routing rules include: a corresponding relationship between a calling service group and a dependent service group.
[0017] Optionally,
[0018] Further including:
[0019] If there is no dependent service group matching the information, then the dependent service instance corresponding to the preset default dependent service group is determined according to the correspondence between the preset dependent service group and the dependent service instance, and the call to the dependent service instance corresponding to the information is executed; wherein the dependent service instance corresponding to the information is the dependent service instance corresponding to the default dependent service group.
[0020] Optionally,
[0021] The routing rules are configured by ZooKeeper.
[0022] Optionally,
[0023] The information also includes: dependent service identification;
[0024] The determining, according to a plurality of pre-configured routing rules, whether there is a dependent service group matching the information comprises:
[0025] Determine a routing rule corresponding to the dependent service identifier from among a plurality of pre-configured routing rules;
[0026] According to the routing rule corresponding to the dependent service identifier, it is determined whether there is a dependent service group matching the information.
[0027] In a second aspect, an embodiment of the present invention provides a service calling method, including:
[0028] Get information about calling services;
[0029] Determining, according to a plurality of pre-configured routing rules, whether there is a first dependent service group matching the information;
[0030] If the first dependent service group exists, determining the dependent service instance corresponding to the first dependent service group according to a preset correspondence relationship between the dependent service group and the dependent service instance;
[0031] Calling the dependent service instance corresponding to the first dependent service group;
[0032] If the call fails, determining whether there is a second dependent service group matching the information according to the plurality of routing rules;
[0033] If the second dependent service group exists, determining the dependent service instance corresponding to the second dependent service group according to the corresponding relationship between the dependent service group and the dependent service instance;
[0034] Call the dependent service instance corresponding to the second dependent service group.
[0035] In a third aspect, an embodiment of the present invention provides a service invoking device, including:
[0036] An acquisition module, configured to acquire information of a calling service;
[0037] A determination module is configured to determine whether there is a dependent service group matching the information according to a plurality of pre-configured routing rules; if there is a dependent service group matching the information, determine the dependent service instance corresponding to the information according to a preset correspondence between the dependent service group and the dependent service instance;
[0038] The calling module is configured to call the dependent service instance corresponding to the information.
[0039] In a fourth aspect, an embodiment of the present invention provides a service invoking device, including:
[0040] An acquisition module, configured to acquire information of a calling service;
[0041] a determination module configured to determine whether there is a first dependent service grouping matching the information according to a plurality of pre-configured routing rules; if the first dependent service grouping exists, determine the dependent service instance corresponding to the first dependent service grouping according to a preset correspondence between the dependent service grouping and the dependent service instance, and trigger the calling module; determine whether there is a second dependent service grouping matching the information according to the plurality of routing rules; if the second dependent service grouping exists, determine the dependent service instance corresponding to the second dependent service grouping according to the correspondence between the dependent service grouping and the dependent service instance, and trigger the calling module
[0042] The calling module is configured to call the dependent service instance corresponding to the first dependent service group, and if the calling fails, trigger the determining module; and call the dependent service instance corresponding to the second dependent service group.
[0043] In a fifth aspect, an embodiment of the present invention provides an electronic device, including:
[0044] one or more processors;
[0045] a storage device for storing one or more programs,
[0046] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0047] In a sixth aspect, an embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the above embodiments.
[0048] An embodiment of the above invention has the following advantages or beneficial effects: the routing rules are configurable, and if the dependent service group corresponding to the calling service needs to be adjusted, the configured routing rules can be updated. In the embodiment of the present invention, there is no need to manually modify the routing rules in the code, and there is no need to restart the application, which can improve the efficiency of service calling and ensure the stability of the service.
[0049] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0051] Figure 1 is a flow chart of a service calling method provided by an embodiment of the present invention;
[0052] Figure 2 is a flow chart of a service calling method provided by another embodiment of the present invention;
[0053] Figure 3 is a class diagram of a service calling method provided by an embodiment of the present invention;
[0054] Figure 4 is a flow chart of a service calling method provided by another embodiment of the present invention;
[0055] Figure 5 is a flow chart of a service calling method provided by another embodiment of the present invention;
[0056] Figure 6 is a schematic diagram of a routing configuration provided by an embodiment of the present invention;
[0057] Figure 7 is a schematic diagram of a service calling device provided by an embodiment of the present invention;
[0058] Figure 8 is a schematic diagram of a service calling device provided by another embodiment of the present invention;
[0059] Fig. 9is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0060] Fig.10 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0061] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0062] like Figure 1 As shown, an embodiment of the present invention provides a service calling method, including:
[0063] Step 101: Obtain information for calling a service.
[0064] The calling service may depend on one or different dependent services, for example, calling service A depends on the address service, and calling service B depends on the query service and the address service. Since the processing process for each dependent service is the same, the following embodiments will only be described by taking the dependent service as the address service as an example.
[0065] The information of the calling service includes: any one or more of the IP address of the server where the calling service is located, the calling service group corresponding to the calling service, the dependent service identifier and the computer room corresponding to the calling service.
[0066] Step 102: According to a number of pre-configured routing rules, determine whether there is a dependent service group matching the information. If so, execute step 103; otherwise, terminate the current process.
[0067] In the embodiment of the present invention, the information of calling the service may be matched with each routing rule in sequence to determine whether there is a dependent service group matching the information.
[0068] If there is no dependent service group matching the information, information such as call failure may also be prompted.
[0069] Step 103: Determine the dependent service instance corresponding to the information according to the preset corresponding relationship between the dependent service group and the dependent service instance.
[0070] Step 104: Call the dependent service instance corresponding to the information.
[0071] In the embodiment of the present invention, the routing rules are configurable. If the dependent service group corresponding to the calling service needs to be adjusted, the configured routing rules can be updated. In the embodiment of the present invention, there is no need to manually modify the routing rules in the code, and there is no need to restart the application, which can improve the efficiency of service calling and ensure the stability of the service.
[0072] In one embodiment of the present invention, the dependent service group to which the dependent service instance belongs can be determined based on the computer room and city where the dependent service instance is located. A dependent service group can include one dependent service instance or multiple dependent service instances. The dependent service group can achieve load balancing through multiple dependent service instances and improve the stability and reliability of the service.
[0073] For example, the address service includes: an LH group and an MJQ group; the LH group includes an address service instance 1, and the MJQ group includes an address service instance 2 and an address service instance 3.
[0074] In one embodiment of the present invention, the information includes: the IP address of the server where the calling service is located;
[0075] Routing rules include: the correspondence between the server's IP address and the dependent service grouping.
[0076] The correspondence between the server's IP address and the dependent service group is different, and the routing rules to which they belong are different.
[0077] For example, in routing rule 1, the corresponding relationship between the IP address of the server and the dependent service group is shown in Table 1.
[0078] Table 1
[0079] The IP address of the server Dependency Service Grouping 192.168.129.106 LH Grouping 192.168.129.107 LH Grouping 192.168.129.108 MJQ Grouping
[0080] In routing rule 2, the correspondence between the server IP address and the dependent service group is shown in Table 1.
[0081] Table 2
[0082] The IP address of the server Dependency Service Grouping 192.168.129.106 MJQ Grouping 192.168.129.107 LH Grouping 192.168.129.108 LH Grouping
[0083] The embodiment of the present invention determines the dependent service group corresponding to the calling service based on the IP address of the server, so that the calling services on different servers can call the same dependent service group, and can also make the calling services on different servers call different dependent service groups to provide services externally. The calling services on different servers call different dependent service groups, which can avoid the influence on the calling service after the dependent service group fails.
[0084] In one embodiment of the present invention, the information includes: a call service group corresponding to the call service;
[0085] Routing rules include: the correspondence between calling service groups and dependent service groups.
[0086] In actual application scenarios, the calling service group to which the calling service belongs can be determined based on the city where the calling service is located, the computer room, the merchant number corresponding to the calling service, and other information. For example, calling service A is divided into Beijing service group, Shanghai service group, and Nanjing service group. Calling service B is divided into computer room 1 group and computer room 2 group. In an embodiment of the present invention, the calling service group in the routing rule can be identified by the name (or alias), number, etc. of the calling service group, and the dependent service group is similar.
[0087] In routing rule 3, the correspondence between the calling service group and the dependent service group is shown in Table 3.
[0088] Table 3
[0089] Calling Service Group Dependency Service Grouping lf_pc LH Grouping pc_mjq MJQ Grouping
[0090] In the embodiment of the present invention, the calling services belonging to different calling service groups can call the same dependent service group or different dependent service groups. The calling service can call the dependent service instance in the dependent service group in the same computer room or across computer rooms or cities. For example, the calling service in computer room 1 calls the dependent service instance in computer room 1 or the dependent service instance in computer room 2.
[0091] In one embodiment of the present invention, the method also includes: if there is no dependent service group matching the information, then according to the correspondence between the preset dependent service group and the dependent service instance, the dependent service instance corresponding to the preset default dependent service group is determined, and the dependent service instance corresponding to the call information is executed; wherein the dependent service instance corresponding to the information is the dependent service instance corresponding to the default dependent service group.
[0092] In order to ensure the stability of calling services, the present invention determines the dependent service instance corresponding to the information of calling services according to the preset default dependent service grouping, so as to ensure that stable calling services can still be provided when the routing rules corresponding to the information cannot be found.
[0093] In the embodiment of the present invention, the routing rules can be configured through the ZooKeeper service. Specifically, when monitoring configuration changes, the ZooKeeper client can monitor whether the routing rules in the ZooKeeper cluster are updated, and if so, update the local configuration.
[0094] The ZooKeeper service can be used to dynamically update routing rules. The updated routing rules can take effect immediately without restarting the application, reducing the impact on the calling process and ensuring the stability of the calling service.
[0095] In one embodiment of the present invention, the information further includes: a dependent service identifier;
[0096] According to several pre-configured routing rules, determine whether there is a dependent service group that matches the information, including:
[0097] Determine a routing rule corresponding to the dependent service identifier from among a plurality of pre-configured routing rules;
[0098] According to the routing rule corresponding to the dependent service identifier, it is determined whether there is a dependent service group matching the information.
[0099] Considering that there may be multiple dependent services, the embodiment of the present invention pre-configures routing rules corresponding to various dependent services, and the number of routing rules corresponding to each dependent service may be one or more. For example, the address service identifier is G, the search service identifier is H, the routing rules corresponding to G are G1, G2 and G3, and the routing rules corresponding to H are H1 and H2. If the dependent service identifier included in the information is G, then according to G1, G2 and G3, it is determined whether there is a dependent service group matching the information.
[0100] like Figure 2 As shown, an embodiment of the present invention provides a service calling method, including:
[0101] Step 201: Obtain the IP address of the server where the calling service is located.
[0102] In the embodiment of the present invention, the IP address of the server where the service is called is 192.168.129.106.
[0103] Step 202: Based on the correspondence between the preset server IP address and the dependent service group, determine whether there is a dependent service group that matches the IP address of the server where the calling service is located. If so, execute step 203; otherwise, execute step 204.
[0104] The correspondence between the server IP address and the dependent service group is shown in Table 1. The IP addresses of the servers where the calling services are located are matched one by one with the IP addresses of the servers in Table 1, and it is determined that the dependent service group corresponding to 192.168.129.106 is the LH group.
[0105] Step 203: According to the preset correspondence between the dependent service group and the dependent service instance, determine the dependent service instance corresponding to the IP address of the server where the calling service is located, and execute step 205.
[0106] Table 4
[0107] Dependency Service Grouping Dependent service instances LH Grouping E1, E2 MJQ Grouping F1, F2, F3
[0108] The corresponding relationship between dependent service groups and dependent service instances is shown in Table 4. The dependent service instances corresponding to 192.168.129.106 are E1 and E2.
[0109] Step 204: Determine the dependent service instance corresponding to the preset default dependent service group according to the correspondence between the preset dependent service group and the dependent service instance, and execute step 205; wherein, the dependent service instance corresponding to the default dependent service group is the dependent service instance corresponding to the IP address of the server where the calling service is located.
[0110] In the embodiment of the present invention, the default dependent service grouping may be an LH grouping or an MJQ grouping.
[0111] Step 205: Call the dependent service instance corresponding to the IP address of the server where the calling service is located.
[0112] It should be noted that the embodiment of the present invention only takes one routing rule as an example for explanation. If there are multiple routing rules, that is, the correspondence between multiple groups of server IP addresses and dependent service groups, then before obtaining the dependent service group that matches the IP address of the server where the calling service is located, it is necessary to match the IP address of the server where the calling service is located with the IP addresses of the servers in each corresponding relationship in turn.
[0113] like Figure 3 As shown, it is a class diagram of the service calling method provided by an embodiment of the present invention, wherein RPCFactory depends on RPCDefaultService and RPCMapService, and provides a method for obtaining dependent service instances.
[0114] RPCMapService encapsulates the dependent service instances of each dependent service group, where the key is the dependent service group and the value is the corresponding dependent service instance. In addition, other services can create attribute maps on their own.
[0115] RPCDefaultService provides a default dependency service grouping. The example provides a default dependency service grouping for the address service, and other services can create their own properties. RouterPowerConfig and RouterServerConfig encapsulate several routing rules.
[0116] In actual application scenarios, calling a service can call dependent service instances across processes or servers. During the calling process, the dependent service instance may be unavailable due to network problems. In view of this, an embodiment of the present invention provides a service calling method, such as Figure 4 As shown, including:
[0117] Step 401: Obtain information for calling a service.
[0118] Step 402: According to a number of pre-configured routing rules, determine whether there is a first dependent service group matching the information; if so, execute step 403; otherwise, terminate the current process.
[0119] Step 403: Determine the dependent service instance corresponding to the first dependent service group according to the preset corresponding relationship between the dependent service group and the dependent service instance.
[0120] Step 404: call the dependent service instance corresponding to the first dependent service group. If the call fails, execute step 405.
[0121] Step 405: According to a number of routing rules, determine whether there is a second dependent service group matching the information; if so, execute step 406; otherwise, terminate the current process.
[0122] Step 406: Determine the dependent service instance corresponding to the second dependent service group according to the correspondence between the dependent service group and the dependent service instance.
[0123] Step 407: Call the dependent service instance corresponding to the second dependent service group.
[0124] In the embodiment of the present invention, at least two dependent service groups matching the information can be determined by routing rules, and if a dependent service instance in one of the dependent service groups cannot be called, a dependent service instance in another matching dependent service group can be called. This method can ensure the stability of the service.
[0125] like Figure 5 As shown, an embodiment of the present invention provides a service calling method, including:
[0126] Step 501: Acquire information about a calling service, wherein the information about the calling service includes: an IP address of a server where the calling service is located, and a calling service group corresponding to the calling service.
[0127] The IP address of the server where the calling service is located is 192.168.129.106, and the calling service group corresponding to the calling service is qtrade_lf.
[0128] Step 502: According to a number of pre-configured routing rules, determine whether there is a first dependent service group matching the information; if so, execute step 503; otherwise, execute step 504.
[0129] The routing configuration of the present invention is as follows Figure 6 As shown, the configuration includes two routing rules, as shown in Table 5 and Table 6.
[0130] In an embodiment of the present invention, the priority of the IP address of the server where the calling service is located is higher than the priority of the calling service group corresponding to the calling service. Therefore, 192.168.129.106 is first matched one by one with the IP addresses of the servers in Table 5, and the first dependent service group matching 192.168.129.106 is obtained as a B2B group.
[0131] Table 5
[0132] The IP address of the server Dependency Service Grouping 192.168.129.106 B2B Grouping 192.168.129.107 B2B Grouping 172.17.23.28 YZ Grouping 172.17.23.27 YZ Grouping
[0133] Table 6
[0134] Calling Service Group Dependency Service Grouping lf_pc LF Grouping qtrade_lf LF Grouping pc_mjq MJQ Grouping qtrade_mjq MJQ Grouping
[0135] Step 503: According to the preset correspondence between the dependent service group and the dependent service instance, determine the dependent service instance corresponding to the first dependent service group, and execute step 505.
[0136] Table 7
[0137]
[0138]
[0139] According to Table 7, the dependent service instances corresponding to the B2B group are determined to be E1 and E2.
[0140] Step 504: Determine the dependent service instance corresponding to the preset first default dependent service grouping according to the correspondence between the preset dependent service grouping and the dependent service instance, and execute step 505; wherein the dependent service instance corresponding to the first default dependent service grouping is the dependent service instance corresponding to the first dependent service grouping.
[0141] The first default dependent service group is the SH group.
[0142] Step 505: Call the dependent service instance corresponding to the first dependent service group. If the call fails, execute step 506.
[0143] Step 506: According to a number of routing rules, determine whether there is a second dependent service group matching the information; if so, execute step 507; otherwise, execute step 508.
[0144] Match qtrade_lf with the calling service groups in Table 6 one by one to obtain the dependent service group LF corresponding to qtrade_lf.
[0145] Step 507 : According to the correspondence between the dependent service group and the dependent service instance, determine the dependent service instance corresponding to the second dependent service group, and execute step 509 .
[0146] According to Table 7, it is determined that the dependent service instance corresponding to the LF group is M1.
[0147] Step 508: Determine the dependent service instance corresponding to the preset second default dependent service grouping according to the correspondence between the preset dependent service grouping and the dependent service instance, and execute step 505; wherein the dependent service instance corresponding to the second default dependent service grouping is the dependent service instance corresponding to the second dependent service grouping.
[0148] The second default dependent service grouping is the BJ grouping.
[0149] Step 509: Call the dependent service instance corresponding to the second dependent service group.
[0150] In the embodiment of the present invention, the routing rules provide two routing methods, one is based on the IP address of the server where the calling service is located, and the other is based on the calling service group corresponding to the calling service. Therefore, when the network fails and the dependent service group in the first dependent service group cannot be called, the dependent service group in the second dependent service group can be called according to the routing rules. This method can ensure the stability and reliability of the service.
[0151] like Figure 7 As shown, an embodiment of the present invention provides a service calling device, including:
[0152] The acquisition module 701 is configured to acquire information of calling a service;
[0153] The determination module 702 is configured to determine whether there is a dependent service group matching the information according to a plurality of pre-configured routing rules; if there is a dependent service group matching the information, determine the dependent service instance corresponding to the information according to a preset correspondence between the dependent service group and the dependent service instance;
[0154] The calling module 703 is configured to call the dependent service instance corresponding to the calling information.
[0155] In one embodiment of the present invention, the information includes: the IP address of the server where the calling service is located;
[0156] Routing rules include: the correspondence between the server's IP address and the dependent service grouping.
[0157] In one embodiment of the present invention, the information includes: a call service group corresponding to the call service;
[0158] Routing rules include: the correspondence between calling service groups and dependent service groups.
[0159] In one embodiment of the present invention, the determination module 702 is configured to determine the dependent service instance corresponding to the preset default dependent service group based on the correspondence between the preset dependent service group and the dependent service instance if there is no dependent service group matching the information, and execute the dependent service instance corresponding to the call information; wherein the dependent service instance corresponding to the information is the dependent service instance corresponding to the default dependent service group.
[0160] In one embodiment of the present invention, several routing rules are configured by ZooKeeper.
[0161] In one embodiment of the present invention, the information further includes: a dependent service identifier;
[0162] The determination module 702 is configured to determine a routing rule corresponding to the dependent service identifier from among several pre-configured routing rules; and determine whether there is a dependent service group matching the information according to the routing rule corresponding to the dependent service identifier.
[0163] like Figure 8 As shown, an embodiment of the present invention provides a service calling device, including:
[0164] The acquisition module 801 is configured to acquire information of calling a service;
[0165] Determination module 802 is configured to determine whether there is a first dependent service grouping that matches the information based on a number of pre-configured routing rules; if there is a first dependent service grouping, determine the dependent service instance corresponding to the first dependent service grouping based on the preset correspondence between the dependent service grouping and the dependent service instance, and trigger the calling module 803; determine whether there is a second dependent service grouping that matches the information based on a number of routing rules; if there is a second dependent service grouping, determine the dependent service instance corresponding to the second dependent service grouping based on the correspondence between the dependent service grouping and the dependent service instance, and trigger the calling module 803.
[0166] The calling module 803 is configured to call the dependent service instance corresponding to the first dependent service group. If the calling fails, the determining module 802 is triggered to call the dependent service instance corresponding to the second dependent service group.
[0167] An embodiment of the present invention provides an electronic device, including:
[0168] one or more processors;
[0169] a storage device for storing one or more programs,
[0170] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0171] Fig. 9 An exemplary system architecture 900 to which the service invocation method or service invocation apparatus according to the embodiment of the present invention can be applied is shown.
[0172] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0173] Users can use terminal devices 901, 902, 903 to interact with server 905 through network 904 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 901, 902, 903, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0174] The terminal devices 901 , 902 , and 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0175] The server 905 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 901, 902, and 903. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0176] It should be noted that the service calling method provided in the embodiment of the present invention is generally executed by the server 905 , and accordingly, the service calling device is generally arranged in the server 905 .
[0177] It should be understood that Fig. 9 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0178] Reference below Fig.10, which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present invention. Fig.10 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0179] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0180] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0181] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present invention are executed.
[0182] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0183] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0184] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a sending module, an acquisition module, a determination module, and a first processing module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the sending module may also be described as a "module for sending a picture acquisition request to the connected server."
[0185] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device.
[0186] The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the device includes:
[0187] Get information about calling services;
[0188] Determine, according to a plurality of pre-configured routing rules, whether there is a dependent service group matching the information;
[0189] If there is a dependent service group matching the information, determining the dependent service instance corresponding to the information according to a preset corresponding relationship between the dependent service group and the dependent service instance;
[0190] Call the dependent service instance corresponding to the information.
[0191] The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the device includes:
[0192] Get information about calling services;
[0193] Determining, according to a plurality of pre-configured routing rules, whether there is a first dependent service group matching the information;
[0194] If the first dependent service group exists, determining the dependent service instance corresponding to the first dependent service group according to a preset correspondence relationship between the dependent service group and the dependent service instance;
[0195] Calling the dependent service instance corresponding to the first dependent service group;
[0196] If the call fails, determining whether there is a second dependent service group matching the information according to the plurality of routing rules;
[0197] If the second dependent service group exists, determining the dependent service instance corresponding to the second dependent service group according to the corresponding relationship between the dependent service group and the dependent service instance;
[0198] Call the dependent service instance corresponding to the second dependent service group.
[0199] According to the technical solution of the embodiment of the present invention, the routing rules are configurable. If the dependent service group corresponding to the calling service needs to be adjusted, the configured routing rules can be updated. In the embodiment of the present invention, there is no need to manually modify the routing rules in the code, and there is no need to restart the application, which can improve the efficiency of service calling and ensure the stability of the service.
[0200] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A service calling method, characterized in that: include: Get information about calling services; Determine, according to a plurality of pre-configured routing rules, whether there is a dependent service group matching the information; If there is a dependent service group matching the information, determining the dependent service instance corresponding to the information according to a preset corresponding relationship between the dependent service group and the dependent service instance; Calling the dependent service instance corresponding to the information; If there is no dependent service group matching the information, then the dependent service instance corresponding to the preset default dependent service group is determined according to the correspondence between the preset dependent service group and the dependent service instance, and the call to the dependent service instance corresponding to the information is executed; wherein the dependent service instance corresponding to the information is the dependent service instance corresponding to the default dependent service group.
2. The method according to claim 1, characterized in that The information includes: the IP address of the server where the calling service is located; The routing rules include: the corresponding relationship between the IP address of the server and the dependent service group.
3. The method according to claim 1, characterized in that The information includes: a calling service group corresponding to the calling service; The routing rules include: a corresponding relationship between a calling service group and a dependent service group.
4. The method according to claim 1, characterized in that The routing rules are configured by ZooKeeper.
5. The method according to claim 2 or 3, characterized in that: The information also includes: dependent service identification; The determining, according to a plurality of pre-configured routing rules, whether there is a dependent service group matching the information comprises: Determine a routing rule corresponding to the dependent service identifier from among a plurality of pre-configured routing rules; According to the routing rule corresponding to the dependent service identifier, it is determined whether there is a dependent service group matching the information.
6. A service calling method, characterized in that: include: Get information about calling services; Determining, according to a plurality of pre-configured routing rules, whether there is a first dependent service group matching the information; If the first dependent service group exists, determining the dependent service instance corresponding to the first dependent service group according to a preset correspondence relationship between the dependent service group and the dependent service instance; Calling the dependent service instance corresponding to the first dependent service group; If the call fails, determining whether there is a second dependent service group matching the information according to the plurality of routing rules; If the second dependent service group exists, determining the dependent service instance corresponding to the second dependent service group according to the corresponding relationship between the dependent service group and the dependent service instance; Call the dependent service instance corresponding to the second dependent service group.
7. A service calling device, characterized in that: include: An acquisition module, configured to acquire information of a calling service; A determination module is configured to determine whether there is a dependent service group matching the information according to a plurality of pre-configured routing rules; if there is a dependent service group matching the information, determine the dependent service instance corresponding to the information according to a preset correspondence between the dependent service group and the dependent service instance; A calling module configured to call a dependent service instance corresponding to the information; A determination module is configured to determine the dependent service instance corresponding to the preset default dependent service group according to the correspondence between the preset dependent service group and the dependent service instance if there is no dependent service group matching the information, and execute the call to the dependent service instance corresponding to the information; wherein the dependent service instance corresponding to the information is the dependent service instance corresponding to the default dependent service group.
8. A service calling device, characterized in that: include: An acquisition module, configured to acquire information of a calling service; a determination module configured to determine whether there is a first dependent service group matching the information according to a plurality of pre-configured routing rules; if the first dependent service group exists, determine the dependent service instance corresponding to the first dependent service group according to a preset correspondence between the dependent service group and the dependent service instance, and trigger the calling module; Determine, according to the plurality of routing rules, whether there is a second dependent service group matching the information; if the second dependent service group exists, determine, according to the correspondence between the dependent service group and the dependent service instance, the dependent service instance corresponding to the second dependent service group, and trigger the calling module; The calling module is configured to call the dependent service instance corresponding to the first dependent service group, and if the calling fails, trigger the determining module; Call the dependent service instance corresponding to the second dependent service group.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Service instance determination method and device, storage medium and electronic equipment
CN110837424A