Service processing method, system, computer device and storage medium

By introducing the cache server in the service finding center, the script execution interface is provided, the single -threaded atomic operation of service registration and application is realized, the problem of low efficiency caused by the existing technology in the existing technology, improvement of service registration and application for application registration and application. Efficiency and accuracy.

CN115550440BActive Publication Date: 2025-01-24SHENZHEN ZHUIYI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210543777.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-19
Publication Date
2025-01-24
Estimated Expiration
2042-05-19

AI Technical Summary

Technical Problem

The existing service registration and publication methods require application for locks when executing registration and query instructions, resulting in complex and inefficient operations.

Method used

Introduce the cache server in the service finding center, provide the script execution interface, the service and call terminal call the interface, the single -threaded atomic running or application script, updating the service registration information or matching target services.

Benefits of technology

It improves the efficiency of service registration and service application, avoids data processing exceptions caused by concurrent calls, ensures the accuracy of cache server processing, and improves the compatibility and application breadth of service registration and application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115550440B_ABST
    Figure CN115550440B_ABST
Patent Text Reader

Abstract

The present application relates to a service processing method, system, computer device and storage medium. The method comprises: a plurality of services each call a script execution interface provided by a cache server in a service discovery registration center, and instruct to execute a registration script using respective service registration parameters; the service registration parameters include the service name of the service and the connection information of the connection service; the cache server runs the registration script atomically in a single thread to update the service registration parameters to the service registration information bound to the service name; a plurality of callers each call a script execution interface, and instructs in the script execution interface to execute the service application script using respective service application parameters; the cache server runs the service application script atomically in a single thread to match the target service registration information related to the service application parameters, update the target service registration information, and return the connection information to the corresponding caller. The use of this method can improve the service processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software technology, and in particular to a service processing method, system, computer device and storage medium. Background Art

[0002] With the rapid development of service technology and the increasing maturity of service usage, the research on service registration and discovery technology has become a hot topic in enterprise application integration systems. The service discovery registration center provides service registration and discovery functions and needs to handle concurrent service registration events and service discovery events.

[0003] The current service registration and publishing method can complete the registration and publishing of services through the specified registration instructions and query instructions. However, since these two instructions need to modify the same data, when executing the registration and query instructions, it is necessary to apply for related locks before executing the registration and query instructions, and release the related locks after the instructions are completed. This leads to complex operations and low efficiency. Summary of the invention

[0004] Based on this, it is necessary to provide a service processing method, system, computer device, storage medium and computer program product that can improve efficiency in response to the above technical problems.

[0005] In a first aspect, the present application provides a service processing method. The method comprises:

[0006] In the case where multiple services register services with a service discovery registration center, the multiple services each call a script execution interface provided by a cache server in the service discovery registration center, and indicate in the script execution interface to execute a registration script using respective service registration parameters; the service registration parameters include a service name of the service and connection information for connecting to the service;

[0007] The cache server, in response to each service calling the script execution interface, atomically runs the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters;

[0008] In the case where multiple callers apply for services to the service discovery registration center, the multiple callers each call the script execution interface and instruct in the script execution interface to use their own service application parameters to execute the service application script; the service application parameters include the target service name applied for by the caller;

[0009] The cache server atomically runs the service application script indicated by the calling end in a single thread for each call to the script execution interface, so as to match the target service registration information bound to the target service name among the multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the corresponding calling end, so that the calling end connects to the service corresponding to the target service name based on the connection information.

[0010] In a second aspect, the present application further provides a service processing system, the system comprising: a service discovery registration center, at least one server and at least one calling terminal; the server runs at least one service; the service discovery registration center includes a cache server;

[0011] The server is used to, when multiple services register services with the service discovery registration center, call the script execution interface provided by the cache server through each of the multiple services, and indicate in the script execution interface to execute the registration script using the respective service registration parameters; the service registration parameters include the service name of the service and the connection information for connecting to the service;

[0012] The service discovery registration center is used to respond to the call of each service to the script execution interface through the cache server, and atomically run the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters;

[0013] The calling end is used to call the script execution interface and instruct in the script execution interface to execute the service application script using respective service application parameters; the service application parameters include the target service name applied by the calling end;

[0014] The service discovery registration center is also used to call the script execution interface for each calling end through the cache server, and atomically run the service application script indicated by the calling end in a single thread to match the target service registration information bound to the target service name in multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the corresponding calling end, so that the calling end connects to the service corresponding to the target service name based on the connection information.

[0015] In one of the embodiments, the service corresponding to the target service name is a multi-connection service; the target service registration information records the number of idle connections of the service corresponding to the target service name; the service discovery registration center is also used to reduce the recorded number of idle connections when the number of idle connections is greater than zero, and return the connection information of the service corresponding to the target service name to the corresponding calling end.

[0016] In one of the embodiments, the target service registration information records the connection information and the number of idle connections of at least two multi-connection services corresponding to the target service name; the service discovery registration center is also used to search for an idle connection number whose value is greater than zero from the idle connection numbers of the at least two multi-connection services, and if the search is successful, reduce the idle connection number of the found record and return the connection information of the target service to the corresponding calling end; the target service is a multi-connection service under the same target service name and corresponding to the found idle connection number.

[0017] In one embodiment, the connection information includes the URL and port for connecting to the service; the service discovery registration center is also used to respond to each service's call to the script execution interface through the cache server, and atomically run the registration script indicated by the service in a single thread to update the service registration information with the URL of the service, the port of the service, and the number of idle connections of the service as a group of first data; and append the URL of the service and the port of the service as a group of second data to the registration set in the service registration information; the service discovery registration center is also used to traverse each second data of the registration set, obtain the URL and port in the second data, and obtain the number of idle connections corresponding to the URL and the port according to the first data; if the obtained number of idle connections is equal to zero, continue to traverse the second data to obtain new URL and port operations and subsequent steps until an idle connection number greater than zero is obtained.

[0018] In one of the embodiments, the service corresponding to the target service name is a multi-task service that supports running multiple different tasks simultaneously; the service application parameters include the task name of the task applied for by the calling end; the target service registration information includes the upper limit of the number of single tasks and the upper limit of the number of multi-tasks for each task, as well as the number of executed tasks of each task of the multi-task service; the service discovery registration center is also used to determine the number of executed tasks of the service corresponding to the target service name based on the target service registration information; compare the number of executed tasks with the upper limit of the number of single tasks or the upper limit of the number of multi-tasks for each task recorded in the target service registration information; the target task is the task represented by the task name of the task applied for running in the service parameters; when the comparison result indicates support for adding the running of the target task, the number of executed tasks recorded in the target service registration information is updated, and the connection information of the service corresponding to the target service name is returned to the corresponding calling end.

[0019] In one of the embodiments, the service discovery registration center is also used to respond to each service's call to the script execution interface through the cache server, and atomically run the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, and record the heartbeat cycle of the service; the service discovery registration center is also used to invalidate the connection information in the service registration information of the service if no heartbeat message of the service is received within the heartbeat cycle.

[0020] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor executes the steps of the above service processing method.

[0021] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to perform the steps of the above service processing method.

[0022] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and the computer program is executed by a processor to perform the steps of the above service processing method.

[0023] In the above-mentioned service processing method, system, computer device, storage medium and computer program product, when multiple services register services with a service discovery registration center, the multiple services each call the script execution interface provided by the cache server in the service discovery registration center, and indicate in the script execution interface to use their respective service registration parameters to execute the registration script. Wherein, the service registration parameters include the service name of the service and the connection information for connecting the service. In this way, the service can register the service after specifying the registration script and the service registration parameters, and there is no need to configure the multiple interfaces provided by the service discovery registration center one by one, thereby improving the service registration efficiency. In response to each service calling the script execution interface, the cache server atomically runs the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters. When multiple callers apply for services to the service discovery registration center, the multiple callers each call the script execution interface, and indicate in the script execution interface to use their respective service application parameters to execute the service application script. Wherein, the service application parameters include the service name of the target service applied by the caller. In this way, the caller can make a service application after specifying the service application script and service application parameters, thereby improving the service application efficiency. The cache server atomically runs the service application script indicated by the caller in a single thread for each call to the script execution interface, so as to match the target service registration information bound to the service name of the target service in the multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the caller, so that the caller can connect to the target service based on the connection information. In this way, it is avoided that the cache server data processing is abnormal when the service and the caller concurrently call the script execution interface, thereby ensuring the accuracy of the cache server processing on the basis of improving the service registration efficiency and service application efficiency. In addition, since the service and the caller can specify the script through the script execution interface, different registration or application requirements can specify different scripts, thereby improving the compatibility and extensive application of service registration and service application. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 An application environment diagram of a service processing method in an embodiment;

[0025] Figure 2 A flowchart of a service processing method in one embodiment;

[0026] Figure 3 A flowchart of a service processing method in one embodiment;

[0027] Figure 4 A schematic diagram of the principle of a service processing method in an embodiment;

[0028] Figure 5 is a structural block diagram of a service processing system in one embodiment;

[0029] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0031] The service processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. The service discovery registration center 110 communicates with multiple service terminals 120 and multiple call terminals 130 through the network. The call terminals can be, but are not limited to, various personal computers, laptops, smart phones, servers, tablet computers, and portable wearable devices. The service discovery registration center 110 can be implemented with an independent server or a server cluster composed of multiple servers. The server 120 runs at least one service; the service discovery registration center 110 includes a cache server 1101, which can be a cache server in a cache server cluster or an independent cache server.

[0032] In the case where services in multiple service terminals 120 register with the service discovery registration center 110, the multiple services each call the script execution interface provided by the cache server 1101 in the service discovery registration center 110, and indicate in the script execution interface to execute the registration script using their respective service registration parameters; the service registration parameters include the service name of the service and the connection information for connecting to the service. In response to each service calling the script execution interface, the cache server 1101 atomically runs the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters. In the case where multiple call terminals 130 apply for services to the service discovery registration center 110, the multiple call terminals 130 each call the script execution interface, and indicate in the script execution interface to execute the service application script using their respective service application parameters; the service application parameters include the target service name applied by the call terminal 130. The cache server 1101 atomically runs the service application script indicated by the calling end 130 in a single thread for each call to the script execution interface, so as to match the target service registration information bound to the target service name in the multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the corresponding calling end 130, so that the calling end 130 connects to the service corresponding to the target service name based on the connection information.

[0033] In one embodiment, Figure 2 As shown, a service processing method is provided. This embodiment is applied to a system including a service discovery registration center, a call end, and a server end, and is implemented through the interaction between the service discovery registration center, the call end, and the server end. In this embodiment, the method includes the following steps:

[0034] S202, when multiple services register with the service discovery registration center, the multiple services each call the script execution interface provided by the cache server in the service discovery registration center, and indicate in the script execution interface to execute the registration script using their own service registration parameters; the service registration parameters include the service name of the service and the connection information of the connected service.

[0035] The script execution interface is used to instruct the cache server to execute the specified script using the specified parameters. The service registration parameters are the parameters required for the service to register with the service discovery registry. A server can run at least one service.

[0036] Specifically, when multiple services register services with the service discovery registration center, the multiple services each call the script execution interface provided by the cache server in the service discovery registration center, and input their respective service registration parameter inputs and registration scripts in the script execution interface to instruct the execution of the specified registration script using their respective service registration parameters. The service registration parameters include the service name of the service and the connection information of the connection service.

[0037] In one embodiment, the service discovery registration center includes a cache server group, and the cache server is any one of the cache server cluster.

[0038] S204, the cache server responds to each service's call to the script execution interface by atomically running the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters.

[0039] The service registration information is bound to the service name. Since multiple services may have the same service name, the service registration information may include service registration parameters of multiple services having the same service name.

[0040] Specifically, the cache server responds to each service's call to the script execution interface and runs the registration script indicated by the service in a single thread atomically. In the process of running the code logic of the registration script, the service registration parameters indicated by the service are updated to the service registration information bound to the service name in the service registration parameters. It can be understood that since the registration script is run atomically in a single thread, only one registration script can be executed at the same time, avoiding data confusion caused by asynchronous processing, thereby ensuring the accuracy of the service registration information.

[0041] In one embodiment, the connection information in the service registration parameters includes the website and port of the connection service. When updating the service registration parameters to the service registration information, the cache server may write the website and port into the service registration information.

[0042] In one embodiment, the cache server records the heartbeat cycle of the service while updating the service registration parameters to the service registration information, and detects whether the connection information in the service registration information is valid based on the heartbeat cycle of the service and the heartbeat message sent by the service.

[0043] S206, when multiple callers apply for services to the service discovery registration center, the multiple callers each call the script execution interface and instruct in the script execution interface to use their own service application parameters to execute the service application script; the service application parameters include the target service name applied for by the caller.

[0044] Specifically, when multiple callers apply for services to the service discovery registration center, the multiple callers each call the script execution interface and input their own service application parameter input and service application script in the script execution interface to instruct the execution of the service application script using their own service application parameters. The service application parameters include the target service name applied for by the caller.

[0045] It can be understood that the process of registering multiple services and applying for services by multiple callers is not subject to execution order. When multiple services register services, they can be concurrent, and when multiple callers apply for services, they can also be concurrent.

[0046] S208, the cache server atomically runs the service application script indicated by the calling end in a single thread for each call to the script execution interface, so as to match the target service registration information bound to the target service name in multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the corresponding calling end, so that the calling end connects to the service corresponding to the target service name based on the connection information.

[0047] Specifically, for each call to the script execution interface by the caller, the cache server atomically runs the service application script indicated by the caller in a single thread, matches the target service registration information bound to the target service name in multiple service registration information, updates the target service registration information, and returns the connection information in the target service registration information to the corresponding caller, so that the caller connects to the service corresponding to the target service name based on the connection information. Since the service application script is atomically executed by a single thread, only one service application script can be executed at the same time. It can be understood that since both the registration script and the service application script are atomically executed by a single thread, only one registration script or service application script can be executed at the same time. And the execution of the script is atomic and cannot be interrupted. In this way, data anomalies caused by asynchronous processing are avoided, thereby ensuring the accuracy of the service registration information.

[0048] In one embodiment, the service corresponding to the target service name may be a multi-connection service, and the target service registration information records the number of idle connections of the service corresponding to the target service name. In the process of updating the target service registration information, the number of idle connections needs to be updated to record the number of connections that can be currently called by the multi-connection service.

[0049] In one embodiment, the service corresponding to the target service name may be a multi-task service that supports running a variety of different tasks at the same time, and the service application parameters include the task name of the task applied for by the caller; the target service registration information includes the upper limit of the number of single tasks and the upper limit of the number of multi-tasks for each task, as well as the number of executed tasks of each task of the multi-task service. In the process of updating the target service registration information, it is determined whether the target service supports adding running target tasks based on the upper limit of the number of single tasks or the upper limit of the number of multi-tasks, and the number of executed tasks is updated if it supports. Among them, the target task is the task represented by the task name of the task applied for in the service parameters.

[0050] In one embodiment, the service corresponding to the target service name may be at least one of a multi-task service and a multi-connection service, etc. Services of different service types specify registration scripts corresponding to their respective service types in the script execution interface.

[0051] In the above service processing method, system, computer device, storage medium and computer program product, when multiple services register services with a service discovery registration center, the multiple services each call the script execution interface provided by the cache server in the service discovery registration center, and indicate in the script execution interface to execute the registration script using their respective service registration parameters. The service registration parameters include the service name of the service and the connection information of the connection service. In this way, the service can register the service after specifying the registration script and the service registration parameters, and there is no need to configure the multiple interfaces provided by the service discovery registration center one by one, thereby improving the service registration efficiency. In response to each service calling the script execution interface, the cache server atomically runs the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters. When multiple callers apply for services to the service discovery registration center, the multiple callers each call the script execution interface, and indicate in the script execution interface to execute the service application script using their respective service application parameters. The service application parameters include the service name of the target service applied by the caller. In this way, the caller can apply for services after specifying the service application script and the service application parameters, thereby improving the service application efficiency. For each call to the script execution interface by the caller, the cache server atomically runs the service application script indicated by the caller in a single thread to match the target service registration information bound to the service name of the target service in multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the caller, so that the caller can connect to the target service based on the connection information. In this way, it is avoided that the service and the caller concurrently call the script execution interface, which causes abnormal data processing of the cache server, thereby ensuring the accuracy of the cache server processing on the basis of improving the efficiency of service registration and service application. In addition, since the service and the caller can specify the script through the script execution interface, different registration or application requirements can specify different scripts, thereby improving the compatibility and extensive application of service registration and service application.

[0052] In one embodiment, the service corresponding to the target service name is a multi-connection service; the target service registration information records the number of idle connections of the service corresponding to the target service name; updating the target service registration information and returning the connection information in the target service registration information to the corresponding calling end include: when the number of idle connections is greater than zero, reducing the recorded number of idle connections and returning the connection information of the service corresponding to the target service name to the corresponding calling end.

[0053] The multi-connection service refers to a service with multiple connection paths that can be connected to by multiple callers at the same time. The number of idle connections refers to the number of idle connection paths that can be currently applied for connection in the multi-connection service.

[0054] Specifically, when the service corresponding to the target service name is a multi-connection service, the target service registration information records the number of idle connections of the service corresponding to the target service name. After the cache server obtains the number of idle connections, if the number of idle connections is greater than zero, it reduces the number of recorded idle connections and returns the connection information of the service corresponding to the target service name to the corresponding caller.

[0055] In this embodiment, the service corresponding to the target service name can be a multi-connection service, and the number of idle connections is updated to confirm whether the multi-connection service can still be applied for connection, so that the service discovery registration center supports the registration and connection application of the multi-connection service, meeting the use requirements of the multi-connection service.

[0056] In one embodiment, the target service registration information records the connection information and the number of idle connections of at least two multi-connection services corresponding to the target service name; when the number of idle connections is greater than zero, the recorded number of idle connections is reduced, and the connection information of the service corresponding to the target service name is returned to the corresponding calling end, including: searching for an idle connection number greater than zero from the idle connection numbers of at least two multi-connection services, and when the search is successful, reducing the found number of idle connections recorded, and returning the connection information of the target service to the corresponding calling end; the target service is a multi-connection service under the same target service name and corresponding to the found number of idle connections.

[0057] Specifically, since multiple services may have the same service name, the target service registration information records the connection information and idle connection numbers of at least two multi-connection services corresponding to the target service name. The service discovery registration center searches for an idle connection number whose value is greater than zero from the idle connection numbers of at least two multi-connection services. If the search is successful, the idle connection number of the found record is reduced, and the connection information of the target service is returned to the corresponding caller. Among them, the target service is a multi-connection service under the same target service name and corresponding to the idle connection number found. For example, the content of the target service registration information record may be {first multi-connection service, first connection information, first idle connection number}, {second multi-connection service, second connection information, second idle connection number}. Among them, the first idle connection value is 0, and the second idle connection value is not 0. The service discovery registration center can find the second idle connection number whose value is not 0, and return the second connection information of the second multi-connection service corresponding to the second idle connection number.

[0058] In this embodiment, the target service registration information records the connection information and the number of idle connections of at least two multi-connection services corresponding to the target service name. The service discovery registration center can search for the number of idle connections greater than zero and return the corresponding connection information, so that the service discovery registration center can support service applications for multiple multi-connection services with the same service name, thereby meeting the service application requirements for multiple multi-connection services.

[0059] In one embodiment, the connection information includes a website and a port of a connection service; the cache server responds to each service calling a script execution interface, and runs the registration script indicated by the service in a single thread atomically to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, including: the cache server responds to each service calling a script execution interface, and runs the registration script indicated by the service in a single thread atomically to update the website address of the service, the port of the service, and the number of idle connections of the service as a group of first data to the service registration information; the website address of the service and the port of the service are appended as a group of second data to a registration set in the service registration information; searching for an idle connection number greater than zero from the idle connection numbers of at least two multi-connection services respectively includes: traversing each second data of the registration set, obtaining the website address and port in the second data, and obtaining the number of idle connections corresponding to the website address and port according to the first data; if the obtained number of idle connections is equal to zero, continuing to traverse the second data to obtain the operation of obtaining a new website address and port and subsequent steps until an idle connection number greater than zero is obtained.

[0060] Specifically, the connection information includes the URL and port of the connection service. In response to each service's call to the script execution interface, the cache server atomically runs the registration script indicated by the service in a single thread to update the service's URL, service's port, and the number of idle connections of the service as a set of first data to the service registration information. The cache server appends the service's URL and service's port as a set of second data to the registration set in the service registration information. The cache server traverses each second data of the registration set, obtains the URL and port in the second data, and obtains the number of idle connections corresponding to the URL and port based on the first data. The cache server makes a numerical judgment on the number of hollow connections. If the obtained number of idle connections is equal to zero, it continues to traverse the second data to obtain the operation of the new URL and port and subsequent steps until an idle connection number greater than zero is obtained.

[0061] For example, the code in the registration script may include "Set[servname(service name):ip(website):port(port)free(number of idle connections)]expiret(expire):10s", which is used to update the service website, service port and number of idle connections of the service as a set of first data to the service registration information, and record the expiration time. The code in the registration script may also include "Sadd[servname[ip:port]]", which is used to append the service website and service port as a set of second data to the registration set in the service registration information. For example, if the original registration set includes ip1:port1 ip2:port2, then after executing this code, it may be ip1:port1 ip2:port2 ip3:port3.

[0062] In this embodiment, the service URL, service port and number of idle connections of the service are updated as a set of first data to the service registration information, and the service URL and service port are added as a set of second data to the registration set in the service registration information. In this way, during the process of expanding the number of services, the service discovery center can flexibly add the URL, port and other information of the expanded services.

[0063] In one embodiment, the service corresponding to the target service name is a multi-task service that supports running multiple different tasks simultaneously; the service application parameters include the task name of the task applied for by the calling end; the target service registration information includes the upper limit of the number of single tasks and the upper limit of the number of multi-tasks for each task, as well as the number of executed tasks of each task of the multi-task service; updating the target service registration information and returning the connection information in the target service registration information to the corresponding calling end include: determining the number of executed tasks of each task of the service corresponding to the target service name based on the target service registration information; comparing the number of executed tasks with the upper limit of the number of single tasks or the upper limit of the number of multi-tasks for each task recorded in the target service registration information; the target task is the task represented by the task name of the task applied for running in the service parameters; when the comparison result indicates support for adding the running target task, updating the number of executed target tasks recorded in the target service registration information, and returning the connection information of the service corresponding to the target service name to the corresponding calling end.

[0064] Among them, the upper limit of the number of single tasks refers to the upper limit of the number of running tasks of each task when the multi-task service only runs one task. The upper limit of the number of multi-tasks refers to the upper limit of the number of running tasks of each of the multiple tasks when the multi-task service runs multiple tasks at the same time. For example, the multi-task service supports running the first task, the second task and the third task. The target service registration information includes: when the multi-task service only runs the first task, the upper limit of the number of single tasks of the first task is 3; when the multi-task service only runs the second task, the upper limit of the number of single tasks of the second task is 5; when the multi-task service only runs the third task, the upper limit of the number of single tasks of the third task is 7; when the multi-task service runs the first task, the second task and the third task at the same time, the upper limit of the number of multi-tasks of the first task is 2, the upper limit of the number of multi-tasks of the second task is 3, and the upper limit of the number of multi-tasks of the third task is 3.

[0065] In one embodiment, the multiple simultaneously running tasks corresponding to the upper limit of the number of multitasks may be some different types of tasks supported by the multitask service. For example, the multitask service supports running the first task, the second task, and the third task. The target service registration information may also include that when the multitask service runs the first task and the third task simultaneously, the upper limit of the number of multitasks for the first task is 3, and the upper limit of the number of multitasks for the second task is 5.

[0066] Specifically, the service corresponding to the target service name may be a multi-task service that supports running multiple different tasks at the same time. The service application parameters include the task name of the task applied for by the calling end; the target service registration information includes the upper limit of the number of single tasks and the upper limit of the number of multi-tasks for each task, as well as the number of executed tasks of each task of the multi-task service. The cache server can determine the number of executed tasks of the service corresponding to the target service name based on the target service registration information. The cache server compares the number of executed tasks with the upper limit of the number of single tasks or the upper limit of the number of multi-tasks for each task recorded in the target service registration information. Among them, the target task is the task represented by the task name of the task applied for running in the service parameters. When the comparison result indicates that support for adding the running target task is supported, the number of executed target tasks recorded in the target service registration information is updated, and the connection information of the service corresponding to the target service name is returned to the corresponding calling end.

[0067] In one embodiment, the plurality of services include at least two multi-task services with the same service name. The cache server may select a target multi-task service from the at least two multi-task services using a target algorithm and return connection information of the target multi-task service.

[0068] In one embodiment, the target algorithm may determine the number of task types of tasks executed by each multi-tasking service, and select the multi-tasking service with the smallest number of task types.

[0069] In this embodiment, the service discovery registration center supports service registration and service application operations related to the multi-task service, thereby meeting the application requirements for the multi-task service.

[0070] In one embodiment, the cache server responds to each service's call to the script execution interface, and single-threaded atomically runs the registration script indicated by the service to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, including: the cache server responds to each service's call to the script execution interface, and single-threaded atomically runs the registration script indicated by the service to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, and records the heartbeat cycle of the service; the method also includes: if the service discovery registration center does not receive the heartbeat message of the service within the heartbeat cycle, the service discovery registration center invalidates the connection information in the service registration information of the service.

[0071] Specifically, the cache server responds to each service's call to the script execution interface, and runs the registration script indicated by the service in a single thread atomically to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, and records the heartbeat cycle of the service. The service sends a heartbeat message to the service discovery registration center. If the service discovery registration center does not receive the heartbeat message of the service within the heartbeat cycle, the service discovery registration center sets the connection information in the service registration information of the service to invalid.

[0072] In one embodiment, the service can complete the sending of the heartbeat message by calling a script execution interface.

[0073] In this embodiment, the heartbeat cycle of the service is recorded, and whether the connection information is available is determined based on the heartbeat cycle and the heartbeat message, thereby ensuring the validity of the connection information.

[0074] In one embodiment, Figure 3As shown, the service in the server side calls the script execution interface provided by the cache server in the service discovery registration center, and indicates in the script execution interface to use its own service registration parameters to execute the registration script. In response to the service's call to the script execution interface, the cache server in the service discovery registration center atomically runs the registration script indicated by the service in a single thread, so as to update the service website, service port and number of idle connections of the service as a set of first data to the service registration information, and append the service website and service port as a set of second data to the registration set in the service registration information, and record the heartbeat cycle of the service. The service sends a heartbeat message to the service discovery registration center, and the service discovery registration center updates the expiration time of the service to the current time plus the time after the heartbeat cycle. When the calling end makes a service application to the service discovery registration center, the calling end calls the script execution interface and indicates in the script execution interface to use the respective service application parameters to execute the service application script. The cache server of the service discovery registration center, in response to the call of the script execution interface by the caller, atomically runs the service application script indicated by the caller in a single thread, matches the target service registration information bound to the target service name in multiple service registration information, traverses each second data of the registration set in the target server registration information, obtains the website and port in the second data, and obtains the number of idle connections corresponding to the website and the port according to the first data. If the obtained number of idle connections is equal to zero, continue to traverse the second data to obtain the operation and subsequent steps of the new website and port until an idle connection number greater than zero is obtained, determine the connection information corresponding to the idle connection number, and return the service application script running result, that is, the obtained connection information, to the corresponding caller, so that the caller can connect to the service corresponding to the target service name based on the connection information.

[0075] In one embodiment, specifically, Figure 4As shown, a schematic diagram of a service processing method is shown. The first multi-connection service and the second multi-connection service are multi-connection services, and the first multi-task service is a multi-task service. It can be understood that the first multi-connection service, the second multi-connection service and the first multi-task service have their own service registration parameters. The service registration parameters used by the first and second multi-connection services are the first and second service registration parameters, respectively, and the service registration parameters used by the first multi-task service are the third service registration parameters. The registration scripts used by the first multi-connection service and the second multi-connection service are the first registration scripts that can be registered by the multi-connection service, and the registration scripts used by the first multi-task service are the second registration scripts that can be registered by the multi-task service. It can be understood that the first registration script and the second registration script can also share the same registration script, and the specific different execution logics of the registration script can be specified by the relevant parameters in the service registration parameters. The first multi-connection service, the second multi-connection service and the first multi-task service all call the script execution interface, and indicate in the script execution interface that the specified registration script is executed using their respective service registration parameters. The cache server updates the relevant service registration information in response to the call of the registration script. The calling end calls the script execution interface, and indicates in the script execution interface that the service application script is executed using the service application parameters to obtain the connection information of the connectable service. It is understandable that there may be multiple multi-task services, and this is not limited.

[0076] It should be understood that, although each step in the flow chart in the embodiment of the present application is shown in sequence according to the indication of the arrow, these steps are not necessarily performed in sequence according to the order indicated by the arrow. Unless there is clear explanation in this article, the execution of these steps does not have strict order restriction, and these steps can be performed in other order. Moreover, at least a portion of the steps in the flow chart may include a plurality of steps or a plurality of stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.

[0077] Based on the same inventive concept, the embodiment of the present application also provides a service processing system for implementing the service processing method involved above. The implementation scheme for solving the problem provided by the system is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more service processing system embodiments provided below can refer to the limitations on the service processing method above, and will not be repeated here.

[0078] In one embodiment, Figure 5 As shown, a service processing system 500 is provided, including: a service end 502, a service discovery registration center 504 and a call end 506, wherein:

[0079] The server 502 is used to call the script execution interface provided by the cache server through multiple services when multiple services register services with the service discovery registration center, and instruct to execute the registration script using their respective service registration parameters in the script execution interface; the service registration parameters include the service name of the service and the connection information of the connection service.

[0080] The service discovery registration center 504 is used to respond to each service's call to the script execution interface through a cache server, and atomically run the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters.

[0081] The calling end 506 is used to call the script execution interface and instruct in the script execution interface to use respective service application parameters to execute the service application script; the service application parameters include the target service name applied by the calling end 506 .

[0082] The service discovery registration center 504 is also used to call the script execution interface for each calling end 506 through the cache server, and atomically run the service application script indicated by the calling end 506 in a single thread to match the target service registration information bound to the target service name in multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the corresponding calling end 506, so that the calling end 506 connects to the service corresponding to the target service name based on the connection information.

[0083] In one of the embodiments, the service corresponding to the target service name is a multi-connection service; the target service registration information records the number of idle connections of the service corresponding to the target service name; the service discovery registration center 502 is also used to reduce the recorded number of idle connections when the number of idle connections is greater than zero, and return the connection information of the service corresponding to the target service name to the corresponding calling end 506.

[0084] In one of the embodiments, the target service registration information records the connection information and the number of idle connections of at least two multi-connection services corresponding to the target service name; the service discovery registration center 504 is also used to search for an idle connection number greater than zero from the idle connection numbers of at least two multi-connection services, and when the search is successful, reduce the idle connection number of the found record and return the connection information of the target service to the corresponding calling end 506; the target service is a multi-connection service under the same target service name and corresponding to the found idle connection number.

[0085] In one embodiment, the connection information includes the URL and port of the connected service; the service discovery registration center 504 is also used to respond to the call of each service to the script execution interface through the cache server, and atomically run the registration script indicated by the service in a single thread to update the service URL, service port and number of idle connections of the service as a group of first data to the service registration information; the service URL and service port are added as a group of second data to the registration set in the service registration information; the service discovery registration center 504 is also used to traverse each second data of the registration set, obtain the URL and port in the second data, and obtain the number of idle connections corresponding to the URL and port according to the first data; if the obtained number of idle connections is equal to zero, continue to traverse the second data to obtain the operation of new URL and port and subsequent steps until the number of idle connections greater than zero is obtained.

[0086] In one embodiment, the service corresponding to the target service name is a multi-task service that supports running multiple different tasks simultaneously; the service application parameters include the task name of the task applied for by the calling end 506; the target service registration information includes the upper limit of the number of single tasks and the upper limit of the number of multi-tasks for each task, as well as the number of executed tasks of each task of the multi-task service; the service discovery registration center 504 is also used to determine the number of executed tasks of the service corresponding to the target service name based on the target service registration information; compare the number of executed tasks with the upper limit of the number of single tasks or the upper limit of the number of multi-tasks for each task recorded in the target service registration information; the target task is the task represented by the task name of the task applied for running in the service parameters; when the comparison result indicates support for adding the running target task, the number of executed target tasks recorded in the target service registration information is updated, and the connection information of the service corresponding to the target service name is returned to the corresponding calling end 506.

[0087] In one of the embodiments, the service discovery registration center 504 is also used to respond to each service's call to the script execution interface through a cache server, and atomically run the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, and record the heartbeat cycle of the service; the service discovery registration center 504 is also used to invalidate the connection information in the service registration information of the service if no heartbeat message from the service is received within the heartbeat cycle.

[0088] In the above service processing system, when multiple services register services with the service discovery registration center, the multiple services each call the script execution interface provided by the cache server in the service discovery registration center, and indicate in the script execution interface to use their respective service registration parameters to execute the registration script. Among them, the service registration parameters include the service name of the service and the connection information of the connection service. In this way, the service can register the service after specifying the registration script and the service registration parameters, and there is no need to configure the multiple interfaces provided by the service discovery registration center one by one, thereby improving the service registration efficiency. In response to each service calling the script execution interface, the cache server atomically runs the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters. In the case that multiple callers apply for services to the service discovery registration center, the multiple callers each call the script execution interface, and indicate in the script execution interface to use their respective service application parameters to execute the service application script. Among them, the service application parameters include the service name of the target service applied by the caller. In this way, the caller can apply for services after specifying the service application script and the service application parameters, thereby improving the service application efficiency. For each call to the script execution interface by the caller, the cache server atomically runs the service application script indicated by the caller in a single thread to match the target service registration information bound to the service name of the target service in multiple service registration information, update the target service registration information, and return the connection information in the target service registration information to the caller, so that the caller can connect to the target service based on the connection information. In this way, it is avoided that the service and the caller concurrently call the script execution interface, which causes abnormal data processing of the cache server, thereby ensuring the accuracy of the cache server processing on the basis of improving the efficiency of service registration and service application. In addition, since the service and the caller can specify the script through the script execution interface, different registration or application requirements can specify different scripts, thereby improving the compatibility and extensive application of service registration and service application.

[0089] For the specific definition of the above-mentioned service processing system, please refer to the definition of the above-mentioned service processing method above, which will not be repeated here. Each device in the above-mentioned service processing system can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned devices can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above devices.

[0090] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store service registration information. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a service processing method is implemented.

[0091] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0092] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0093] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0094] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0095] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0096] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0097] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A service processing method, characterized in that: The method comprises: In the case where multiple services register services with a service discovery registration center, the multiple services each call a script execution interface provided by a cache server in the service discovery registration center, and indicate in the script execution interface to execute a registration script using respective service registration parameters; the service registration parameters include a service name of the service and connection information for connecting to the service; The cache server, in response to each service calling the script execution interface, atomically runs the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters; In the case where multiple callers apply for services to the service discovery registration center, the multiple callers each call the script execution interface and indicate in the script execution interface to use their own service application parameters to execute the service application script; the service application parameters include the target service name applied by the caller; the service corresponding to the target service name is a multi-connection service; The cache server responds to each service calling the script execution interface by atomically running the registration script indicated by the service in a single thread to update the service registration information with the website address of the service, the port of the service and the number of idle connections of the service as a group of first data; appends the website address of the service and the port of the service as a group of second data to the registration set in the service registration information, and the target service registration information records the connection information and the number of idle connections of at least two multi-connection services corresponding to the target service name; traverses each second data of the registration set to obtain the website address and port in the second data, and updates the service registration information according to the second data. The first data obtains the number of idle connections corresponding to the URL and the port; if the obtained number of idle connections is equal to zero, continue to traverse the second data to obtain operations and subsequent steps for new URLs and ports until an idle connection number greater than zero is obtained. If the search is successful, reduce the number of idle connections of the found record, and return connection information of the target service to the corresponding calling end, the connection information including the URL and port for connecting to the service; so that the calling end connects to the service corresponding to the target service name based on the connection information; the target service is a multi-connection service under the same target service name and corresponding to the found number of idle connections.

2. The method according to claim 1, characterized in that The service corresponding to the target service name is a multi-task service that supports running multiple different tasks simultaneously; the service application parameter includes the task name of the task applied for by the calling end; the target service registration information includes the upper limit of the number of single tasks and the upper limit of the number of multi-tasks for each task, and the number of executed tasks of each task of the multi-task service; The method further comprises: Based on the target service registration information, determine the number of executed target tasks of the service corresponding to the target service name; Compare the executed quantity of each target task with the upper limit of the single task quantity or the upper limit of the multi-task quantity of each target task recorded in the target service registration information; the target task is the task represented by the task name of the task applied for running in the service application parameters; When the comparison result indicates that the target task can be added, the number of executed target tasks recorded in the target service registration information is updated, and the connection information of the service corresponding to the target service name is returned to the corresponding calling end.

3. The method according to any one of claims 1 to 2, characterized in that The cache server responds to each service calling the script execution interface, and runs the registration script indicated by the service in a single thread atomically to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, including: The cache server responds to each service calling the script execution interface by atomically running the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, and records the heartbeat cycle of the service; The method further comprises: When the service discovery registration center does not receive the heartbeat message of the service within the heartbeat period, the service discovery registration center sets the connection information in the service registration information of the service to be invalid.

4. The method according to any one of claims 1 to 2, characterized in that The script execution interface is used to instruct the cache server to execute a specified script using specified parameters.

5. A service processing system, characterized in that: The system comprises: a service discovery registration center, at least one server and at least one calling terminal; the server runs at least one service; the service discovery registration center comprises a cache server; The server is used to, when multiple services register services with the service discovery registration center, call the script execution interface provided by the cache server through each of the multiple services, and indicate in the script execution interface to execute the registration script using the respective service registration parameters; the service registration parameters include the service name of the service and the connection information for connecting to the service; The service discovery registration center is used to respond to the call of each service to the script execution interface through the cache server, and atomically run the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters; The calling end is used to call the script execution interface and instruct in the script execution interface to use respective service application parameters to execute the service application script; the service application parameters include the target service name applied by the calling end; the service corresponding to the target service name is a multi-connection service; The service discovery registration center is also used to respond to each service's call to the script execution interface through the cache server, and atomically run the registration script indicated by the service in a single thread to update the service registration information with the website address of the service, the port of the service, and the number of idle connections of the service as a group of first data; append the website address of the service and the port of the service as a group of second data to the registration set in the service registration information, and the target service registration information records the connection information and the number of idle connections of at least two multi-connection services corresponding to the target service name; traverse each second data of the registration set to obtain URL and port, and obtain the number of idle connections corresponding to the URL and the port according to the first data; if the obtained number of idle connections is equal to zero, continue to traverse the second data to obtain new URLs and port operations and subsequent steps until the number of idle connections greater than zero is obtained. If the search is successful, reduce the number of idle connections of the found record, and return the connection information of the target service to the corresponding calling end, the connection information including the URL and port for connecting to the service; so that the calling end connects to the service corresponding to the target service name based on the connection information, and the target service is a multi-connection service under the same target service name and corresponding to the found number of idle connections.

6. The system according to claim 5, characterized in that The service corresponding to the target service name is a multi-task service that supports running multiple different tasks simultaneously; the service application parameter includes the task name of the task applied for by the calling end; the target service registration information includes the upper limit of the number of single tasks and the upper limit of the number of multi-tasks for each task, and the number of executed tasks of each task of the multi-task service; the service discovery registration center is also used to: Based on the target service registration information, determine the number of executed target tasks of the service corresponding to the target service name; Compare the executed quantity of each target task with the upper limit of the single task quantity or the upper limit of the multi-task quantity of each target task recorded in the target service registration information; the target task is the task represented by the task name of the task applied for running in the service application parameters; When the comparison result indicates that the target task can be added, the number of executed target tasks recorded in the target service registration information is updated, and the connection information of the service corresponding to the target service name is returned to the corresponding calling end.

7. The system according to any one of claims 5 to 6, characterized in that The service discovery registration center is also used to: The cache server responds to each service calling the script execution interface by atomically running the registration script indicated by the service in a single thread to update the service registration parameters indicated by the service to the service registration information bound to the service name in the service registration parameters, and records the heartbeat cycle of the service; When the service discovery registration center does not receive the heartbeat message of the service within the heartbeat period, the service discovery registration center sets the connection information in the service registration information of the service to be invalid.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

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

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Distributed remote establishing method of Oracle example life cycle

    CN104021175A

  • Application installation-free operation control method and device

    CN105094922A