GPRC client unified management method and system

By using map storage and cache rules of preset programming languages ​​in GRPC clients, unified management of GRPC connection objects is achieved, and the problem of inefficient GRPC client management in asynchronous and concurrent scenarios is solved, and the coordinated control of GRPC connection objects is improved ability.

CN114217776BActive Publication Date: 2024-12-20CCB FINTECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111545500.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-16
Publication Date
2024-12-20
Estimated Expiration
2041-12-16

AI Technical Summary

Technical Problem

When existing GRPC clients call different registration service interfaces in asynchronous and concurrent scenarios, there are multiple repeated GRPC connection management problems in the code, and the connection parameters are inconvenient to modify, resulting in inefficiency and difficulty in regulation.

Method used

Map storage and cache rules using preset programming languages ​​are used to cache GRPC connection objects to achieve unified management, including read locks, write locks, cache functions, life cycle management, statistical management and disconnection management, and use snowflake random numbers to generate a unique service Type ID, defines the Struct structure type and cache function, and implements the coordinated control of GRPC connection objects.

Benefits of technology

It improves the management efficiency of GRPC clients, realizes unified management and control of GRPC connection objects, simplifies connection parameter modification, and enhances management convenience and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114217776B_ABST
    Figure CN114217776B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a unified management method and system for GPRC clients. The method includes: using a preset programming language to preset a map storage, in the preset map storage, each time a GRPC connection object for a specified service is created, the GRPC connection object is cached using the cache rules preset by the preset programming language; when there is a need for GRPC connection object regulation and management, the cached GRPC connection object corresponding to the need is directly called for regulation and management. The scheme of the present invention realizes the controllability of connection parameters through the cached GRPC connection object, and improves the management efficiency of the GPRC client through unified cache object regulation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a GPRC client unified management method and a GPRC client unified management system. Background Art

[0002] On the server side of software development, servers that are implemented through the GRPC protocol and provide external GRPC connections and various registration service calling interfaces often appear. Based on this situation, the traditional method of using GRPC short connection, calling the GRPC connection function, setting timeout and other connection parameters, and then calling a certain service interface, and finally releasing the GRPC connection will no longer be applicable. Because when different registration service interfaces are called in different implementations, there will be multiple repeated GRPC connections in the code, and it is not convenient to unify the writing of the registration service interface and the modification of connection parameters such as IP, port, timeout and other parameters. Based on the problems of low efficiency and difficulty in regulation of the existing GRPC registration service calling method, it is necessary to create a new GPRC client unified management method. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a GPRC client unified management method and a GPRC client unified management system to at least solve the above-mentioned problems.

[0004] In order to achieve the above-mentioned objectives, the first aspect of the present application provides a unified management method for GPRC clients, including: using a preset programming language to preset a map storage, in the preset map storage, each time a GRPC connection object for a specified service is created, the GRPC connection object is cached using the cache rules preset in the preset programming language; when there is a need for GRPC connection object regulation and management, the cached GRPC connection object corresponding to the need is directly called for regulation and management.

[0005] In an embodiment of the present application, the preset map storage using a preset programming language includes: using the type of key-value pairs of the map using the preset programming language to store all concurrent GRPC connection objects; setting a read lock function and a write lock function according to a preset concurrent connection threshold and a concurrent GRPC connection object conflict rule; outputting the concurrent map storage that completes the above settings as the preset map storage; wherein the key of the preset map storage is of int64 type; and the value of the preset map storage is of any type of interface{}.

[0006] In an embodiment of the present application, the method also includes: adding a management scheme for a preset map storage; the management scheme includes: an adding scheme, a deleting scheme and a reading scheme; wherein the adding scheme and the deleting scheme are executed in the unlocked state of the write lock function of the preset map storage; the reading scheme needs to be performed in the unlocked state of the read lock function of the preset map storage.

[0007] In an embodiment of the present application, the method also includes: presetting cache rules using a preset programming language, including: enumerating the service type set provided by GRPC to obtain each service type ID; defining a Struct structure type for correspondingly defining a GRPC connection object; defining a cache function based on the service type set and the Struct structure type; wherein the input parameter of the cache function is the service type ID, and the output parameter is the correspondingly created GRPC connection object.

[0008] In an embodiment of the present application, a GRPC connection object is cached using a cache rule preset in a preset programming language, including: using a snowflake random number generation algorithm to generate a unique service type ID; creating a corresponding Struct structure type based on the unique service type ID and the cache function; and returning a defined GRPC connection object as a cache object based on the Struct structure type.

[0009] In an embodiment of the present application, the regulation and management requirements include: life cycle management, statistical management, debugging output management and disconnection management of GRPC connection objects.

[0010] In an embodiment of the present application, the statistical management includes: obtaining the clock node of the GRPC connection object, the number of real-time GRPC connection clients, the registration service type of each client, the connection peak of each registration service, the average number of connections over a period of time, and the statistics of objects that have not been released for a preset time length.

[0011] In an embodiment of the present application, the lifecycle management includes: unified management and control of connection clients based on various performance data obtained through statistical management; wherein the basic criterion for the unified management and control is that the connection service types of each GRPC connection object do not conflict and the total number of parallel connections is not greater than the preset parallel connection number threshold.

[0012] In an embodiment of the present application, the disconnection management includes: presetting active disconnection parameters, and actively disconnecting the connected GRPC object based on the preset active disconnection parameters; after completing the active disconnection of the GRPC object, automatically deleting the cached data of the disconnected GRPC connection object; after completing the active disconnection of the GRPC object, opening the relevant log and statistical functions of the disconnected GRPC connection object.

[0013] In an embodiment of the present application, the direct call to the cached GRPC connection object corresponding to the demand for regulation and management includes: defining a calling function, which obtains the cached GRPC connection object corresponding to the demand through a generated unique service type ID.

[0014] The second aspect of the present application provides a GPRC client unified management system, the system comprising: a storage unit for storing a map storage preset using a preset programming language, and for storing cache rules preset using a preset programming language; a processing unit for caching the GRPC connection object using the cache rules preset in the preset programming language each time a GRPC connection object for a specified service is created in the preset map storage; a calling unit for directly calling the cached GRPC connection object corresponding to the requirement when there is a requirement for GRPC connection object regulation and management; a regulation unit for regulating and managing the called GRPC connection object.

[0015] In an embodiment of the present application, the storage unit is also used to store a calling function; the calling unit is used to obtain the cached GRPC connection object corresponding to the demand through the unique service type ID generated by the calling function.

[0016] A fourth aspect of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned GPRC client unified management method.

[0017] A fifth aspect of the present application provides a computer program product, including a computer program, which implements the above-mentioned GPRC client unified management method when executed by a processor.

[0018] Through the above technical solution, a preset cache structure is written through a preset programming language code, and GRPC connection objects are cached based on the cache structure. In the subsequent use process, each time a GRPC connection object for a specified service is created, the GRPC connection object is cached using the cache rules preset in the preset programming language, and then the cached GRPC connection object is finally uniformly managed and controlled, thereby improving the management efficiency of the GPRC client.

[0019] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0021] Figure 1 A flowchart schematically shows the steps of the GPRC client unified management method according to an embodiment of the present application;

[0022] Figure 2 A system structure diagram of a GPRC client unified management system according to an embodiment of the present application is schematically shown;

[0023] Figure 3 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0025] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0026] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0027] The GPRC client unified management method provided in this application can be applied to scenarios where different interfaces of different registration services of a specified GRPC service are called asynchronously and concurrently. In conventional GPRC client usage scenarios, it mainly includes the following steps:

[0028] 1) On the client side, the interface caller establishes a communication connection with the GRPC server based on the GRPC protocol through the IP address and port provided by the GRPC service;

[0029] 2) According to the client's needs, specify a GRPC registration service service interface. Based on the service interface, obtain the ServiceClient interface of the specified registration service service;

[0030] 3) Finally, the specific GRPC implementation interface is called in a blocking manner through the specified ServiceClient interface. After the response to the interface call is completed, the call is completed, and after the call is completed, the connection to the GRPC service is disconnected through the destruction interface of the GRPC connection.

[0031] The above-mentioned existing GPRC client usage method has an ideal solution effect for a GPRC client usage scenario, but this method has great disadvantages when there are asynchronous and concurrent application scenarios for calling different interfaces of different registration services of a specified GRPC service. Because on the server side of software development, there are often servers that are implemented through the GRPC protocol and provide GRPC connections and various registration service calling interfaces to the outside world. In common scenarios, GRPC is a short connection, calling the GRPC connection function, setting timeout and other connection parameters, and then calling a certain service interface, and finally releasing the GRPC connection. When calling different registration service interfaces in different implementation scenarios, there will be multiple repeated GRPC connections in the code, obtaining the writing of the registration service service interface, and it is not convenient to unify the modification of connection parameters such as IP, port, timeout and other parameters, and there is no way to operate the management of GRPC connection objects in multiple places.

[0032] For the sake of convenience, the specific implementation of the present application is introduced by the implementation of the go language, but it should be noted that it is not only the go language that can be implemented. Based on the concept process proposed in this application, any programming language can theoretically implement the method proposed in this application. Among them, the go language is a statically strongly typed, compiled language with a syntax similar to C, but with the following functions: memory safety, GC (garbage collection), structural form and CSP-style concurrent computing. As a new language with only a decade of history, the development momentum of the go language is quite rapid. In many applications, it has replaced Python, for example, processing cloud logs stored on S3; moving TB-level files between buckets and / or regions on S3; matching local database records and files on S3 to ensure that the files are in sync. Most of these tasks are one-time, so it is more appropriate to use scripting languages. These tasks need to be programmed quickly, and the code is generally discarded after being used once. Generally speaking, the requirements for such tasks are relatively novel and specific, and their code rarely needs to be reused. Because the Go language has the advantages of convenient compiler, fast development speed, better parallelism, simple deployment, consistent style and convenient tools, it has a very ideal prospect for building a unified management method for parallel GPRC clients. The present invention sets the method steps based on the characteristics of the Go language to achieve a unified management method for the life cycle of GRPC connection client objects. The management functions are the creation, destruction and servicer interface calls of client objects.

[0033] Figure 2 The system structure diagram of the GPRC client unified management system according to the embodiment of the present application is schematically shown. Figure 2 As shown, the present application provides a unified management system for GPRC clients, including: a storage unit for storing a map storage preset using the go language, and for storing cache rules preset using the go language; a processing unit for caching the GRPC connection object using the cache rules preset in the go language each time a GRPC connection object for a specified service is created in the preset map storage; a calling unit for directly calling the cached GRPC connection object corresponding to the demand when there is a demand for GRPC connection object regulation and management; a regulation unit for regulating and managing the called GRPC connection object.

[0034] Figure 1 The following is a schematic diagram showing a process flow of a unified management method for GPRC clients according to an embodiment of the present application. Figure 1 As shown, in one embodiment of the present application, a GPRC client unified management method is provided, comprising the following steps:

[0035] Step S10: Preset a map storage using the Go language.

[0036] Specifically, when there are asynchronous and concurrent calls to different interfaces of different registration services of the specified GRPC service, it is necessary to perform collaborative control on each connection object under the premise of single control of each connection object. Therefore, not only stable control of each connection object is required, but also a unified collaborative control method is required. First of all, it is necessary to understand that the conventional GPRC client usage method may have disadvantages in dealing with this problem, including: there are multiple repeated GRPC connections, and it is difficult to write the registration service interface; it is not convenient to uniformly modify the connection parameters of each connection object such as IP, port, timeout and other parameters; 3) it is impossible to manage the life cycle of different GRPC connection objects in multiple places, such as: it is impossible to know the current time, how many GRPC connection clients there are; what type of registration service service is called by each connection client; how many connections are the peak of each registration service; the average number of connections within a period of time performance statistics, and the statistics of long-term connection objects that have not been released. The present invention needs to solve the above problems, and first of all, it is necessary to create an application framework for collaborative control.

[0037] Preferably, the corresponding framework is written by using the good parallelism of the go language. Preferably, the framework is constructed by using the map storage of the go language. Map is a data structure that obtains value through key. Its underlying storage method is an array. The key cannot be repeated during storage. When the key is repeated, the value is overwritten. We perform hash operations on the key (which can be simply understood as converting the key into an integer) and then take the modulus of the length of the array to get the subscript position of the array where the key is stored. Finally, the key and value are assembled into a structure and put into the array subscript. Use go to design a concurrent and safe map storage type, defined as SafeMapInt64, where the key stored in the map is of int64 type and the value of the map is of any type of interface{}. In the process of writing SafeMapInt64, first use the go language to use the type of map key-value pairs to store all concurrent GRPC connection objects, then set the read and write lock functions according to the preset concurrent connection threshold and the concurrent GRPC connection object conflict rules, and finally output the concurrent map storage that completes the above settings as the preset map storage.

[0038] In one embodiment, after completing the writing of SafeMapInt64, it is also necessary to add management methods for the preset map storage. These management methods are used for the subsequent supplement and update of the framework, so as to transform the framework according to actual needs, without having to rewrite it every time it is used. These management methods include adding methods, deleting methods and reading methods. Among them, when executing the adding method, the write lock function is first locked, and the key-value pair data of the key:value of the data to be added is saved in the map structure, and then the write lock is unlocked. In contrast to the adding method, the key-value pair data of the key:value needs to be deleted from the map structure. For the reading method, it is necessary to query the value of the key from the map structure, and then return the value of the key found and the bool value when the read lock is unlocked; wherein, the bool value indicates that true is returned when the value of the key is found, otherwise false.

[0039] Step S20: In the map storage, each time a GRPC connection object for a specified service is created, the connection object is cached using the cache rules preset in the go language.

[0040] Specifically, in the constructed map storage framework, the collaborative control framework needs to be applied to the specific algorithm. The theoretical basis of the scheme of the present invention is to first identify and cache the connection object, and then regulate based on the cached connection object, that is, to realize the possibility of controlling a single connection object under the collaborative system, because it is regulated based on the cache object, and the overall information contained is complete and valid. In the framework application process, it is first necessary to create a variable CONNECT_HANDLER_MAP of a global map storage type SafeMapInt64 as a cache object for the life cycle of the GRPC connection object, which corresponds to the cache object required later, so as to form a mapping relationship between the two. Then, it is necessary to cache the connection object according to the preset cache rules, specifically, including the following steps: the ideal concept of the present invention is to cache the corresponding connection object for each GRPC connection object for a specified service, and then perform subsequent regulation and management based on the cache object. Because it is managed based on the cache object, the complete cache object information is obtained, and all service types need to be enumerated, and then the connection object identification is performed based on these types, so as to locate the information of the connection object, and cache this information for subsequent regulation and modification. Therefore, first define a set of enumeration variables to represent the registered service type IDs according to the different registered service types provided by GRPC. For example, if the ID of registered service type 1 is N, then the ID of registered service type 2 is N+1, and so on, enumerate all service type IDs. Then define a Struct structure type ConnectHandler, which is used to define a GRPC connected object. The specific definition steps are as follows: First, cache the key value in the map, which is of type int64. It is generated by a snowflake random number generation algorithm to ensure its uniqueness, and the uniqueness can be used for subsequent mapping rules. Then read the ID of the connected service type, use the enumeration type defined above, and then read the GRPC service connection object, the GRPC registered service interface object, and the connection context object, and then the GRP connection destruction execution function, using the Bool value to represent the GRPC connection status, true means connected, and false means not connected. Based on the service type ID and Struct structure type ConnectHandler defined above, a cache function is preset. The cache function is defined as NewConnectHandler, whose input parameter is the ID of the registered service service and whose output parameter is the created GRPC connection object ConnectHandler. Its implementation process includes:

[0041] First, use the snowflake random number generation algorithm to generate a unique service ID. As mentioned above, a service maps to a corresponding connection object, so based on the above cache function, create a Struct structure type ConnectHandler object corresponding to the ID. Then cache the ConnectHandler object, the key of the ConnectHandler object is the ID, and the value is the ConnectHandler object. Finally, return the created ConnectHandler object.

[0042] Through the above preset cache rules, you can automatically cache the connection object when creating the GRPC connection object of the specified service. You can then perform various desired regulation and management based on the cache formation.

[0043] Step S30: When there is a need for connection object regulation and management, directly call the corresponding cached connection object for regulation and management.

[0044] Specifically, the core purpose of the solution of the present invention is to achieve unified management of the life cycle of GRPC connection client objects, and the management functions are the creation, destruction, and servicer interface calls of client objects. Therefore, the main purpose of connection object caching is to facilitate subsequent collaborative management. These regulatory management requirements include connection object life cycle management, statistical management, debugging output management, and disconnection management.

[0045] The statistical management of connection objects includes: obtaining the clock node of the connection object, the number of real-time GRPC connection clients, the registration service type of each client, the connection peak of each registration service, the average number of connections over a period of time, and the statistics of objects that have not been released for a long time. The life cycle management of connection objects includes: unified management and control of connection clients based on various performance data obtained by statistical management; wherein the basic principle of unified management and control is that the connection service types of each connection object do not conflict and the total number of parallel connections is not greater than the preset parallel connection number threshold.

[0046] When writing log statistics, you first need to disconnect the connection object, so you need to preset an active disconnect function, which is defined as Disconnect. This function has no input and output parameters. It is only used to actively disconnect a connected GRPC object. The disconnection implementation process is: call the delete method to delete the key connection object from the cache, then call the defined GRP connection destruction execution function, perform data destruction operations, call the GRPC connection object, disconnect the GRPC connection, and finally set the bool value to false, indicating that the connection is disconnected. In this way, through the Disconnect function, while actively disconnecting the GRPC connection, the cached data of the connection object is automatically deleted. After the disconnection is completed, the relevant log and statistical functions of the corresponding connection object can be opened for rewriting relevant data.

[0047] In one embodiment, the corresponding connection object of the cache is directly called for regulation and management, including: defining a calling function, which obtains the GRPC connection object in the corresponding cache through the generated unique service type ID. The function is defined as GetConnectHandler, because it obtains the GRPC connection object in the cache by referring to the generated unique ID, which facilitates the reuse of the GRPC connection object. The input parameter of the function is the key ID, the output parameter is the GRPC connection object, and a bool value used to indicate whether the acquisition is successful. The above uses the type coercion function of interface{} of the go language, because the type of value in the map is interface{}, which can be represented by any data type. Here we use the type of interface{} to force it to the preset type ConnectHandler of the GRPC connection object, and determine whether the conversion is successful.

[0048] In the embodiment of the present invention, through the design and implementation of the above security cache structure SafeMapInt64 and the GRPC connection object structure ConnectHandler, we can easily implement the implementation method of unified management of the life cycle of GRPC connection client objects, and the management functions are the creation, destruction, and servicer interface calls of client objects.

[0049] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0050] An embodiment of the present application provides a storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned GPRC client unified management method is implemented.

[0051] An embodiment of the present application provides a processor, which is used to run a program, wherein the program executes the above-mentioned GPRC client unified management method when running.

[0052] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor A01, a network interface A02, a display screen A04, an input device A05 and a memory (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A06. The non-volatile storage medium A06 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A06. The network interface A02 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 A01, a GPRC client unified management method is implemented. The display screen A04 of the computer device can be a liquid crystal display or an electronic ink display, and the input device A05 of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse, etc.

[0053] Those skilled in the art will understand that Figure 3 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.

[0054] The present application also provides a computer program product, which implements the above-mentioned GPRC client unified management method when executed by a processor.

[0055] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0056] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0057] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0058] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0059] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0060] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0061] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0062] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0063] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A GPRC client unified management method, characterized in that: The method comprises: Use the default programming language to use the map key-value pair type to store all concurrent GRPC connection objects; According to the preset concurrent connection threshold and concurrent GRPC connection object conflict rules, set the read lock function and write lock function to complete the concurrent map storage setting; Output the set concurrent map storage as the preset map storage; where, The key stored in the preset map is of int64 type; The value stored in the preset map is of any type of interface{}; In the preset map storage, each time a GRPC connection object for a specified service is created, the GRPC connection object is cached using the cache rules preset in the preset programming language; The preset caching rules of the preset programming language are used, including: Enumerate the service type set provided by GRPC and obtain the ID of each service type; Define a Struct structure type to define a GRPC connection object; A cache function is defined according to the service type set and the Struct structure type; wherein the input parameter of the cache function is the service type ID, and the output parameter is the correspondingly created GRPC connection object; Utilizing the cache rule preset in the preset programming language to cache the GRPC connection object includes: Use the snowflake random number generation algorithm to generate a unique service type ID; Create a corresponding Struct structure type according to the unique service type ID and the cache function; Return the defined GRPC connection object as a cache object based on the Struct structure type; When there is a need for regulation and management of GRPC connection objects, directly call the cached GRPC connection object corresponding to the need for regulation and management.

2. The method according to claim 1, characterized in that The method further comprises: adding a management scheme for the preset map storage; The management options include: Add a plan, delete a plan, and read a plan; among them, Adding and deleting plans are executed when the write lock function of the preset map storage is unlocked; The reading scheme needs to be performed in the unlocked state of the read lock function of the preset map storage.

3. The method according to claim 1, characterized in that The regulatory management requirements include: Lifecycle management, statistics management, debugging output management, and disconnection management of GRPC connection objects.

4. The method according to claim 3, characterized in that The statistical management includes: Get the clock node of the GRPC connection object, the number of real-time GRPC connection clients, the service type of each client's registered service, the connection peak of each registered service, the average number of connections over a period of time, and the statistics of objects that have not been released for a preset time length.

5. The method according to claim 4, characterized in that The life cycle management includes: Based on the performance data obtained from statistical management, unified management and control of connected clients is performed; The basic principle of unified management and control is that the connection service types of each GRPC connection object do not conflict and the total number of parallel connections is not greater than the preset parallel connection number threshold.

6. The method according to claim 3, characterized in that The disconnection management includes: Preset active disconnection parameters, and actively disconnect the connected GRPC object based on the preset active disconnection parameters; After the GRPC object is actively disconnected, the cached data of the disconnected GRPC connection object is automatically deleted; After the GRPC object is actively disconnected, the relevant log and statistics functions of the disconnected GRPC connection object are enabled.

7. The method according to claim 1, characterized in that The direct call to the cached GRPC connection object corresponding to the demand for regulation and management includes: Define a calling function that obtains the cached GRPC connection object corresponding to the requirement through the generated unique service type ID.

8. A GPRC client unified management system, characterized in that: The system comprises: Storage unit for: Use the default programming language to use the map key-value pair type to store all concurrent GRPC connection objects; According to the preset concurrent connection threshold and concurrent GRPC connection object conflict rules, set the read lock function and write lock function to complete the concurrent map storage setting; Output the set concurrent map storage as the preset map storage; where, The key stored in the preset map is of int64 type; The value stored in the preset map is of any type of interface{}; and for storing cache rules preset using a preset programming language; A processing unit, configured to cache each GRPC connection object for a specified service in the preset map storage by using a cache rule preset in the preset programming language; The cache rules preset by the preset programming language include: Enumerate the service type set provided by GRPC and obtain the ID of each service type; Define a Struct structure type to define a GRPC connection object; A cache function is defined according to the service type set and the Struct structure type; wherein the input parameter of the cache function is the service type ID, and the output parameter is the correspondingly created GRPC connection object; Utilizing the cache rule preset in the preset programming language to cache the GRPC connection object includes: Use the snowflake random number generation algorithm to generate a unique service type ID; Create a corresponding Struct structure type according to the unique service type ID and the cache function; Return the defined GRPC connection object as a cache object based on the Struct structure type; The calling unit is used to directly call the cached GRPC connection object corresponding to the demand when there is a GRPC connection object regulation and management demand; The control unit is used to control and manage the called GRPC connection object.

9. The system according to claim 8, characterized in that The storage unit is also used to store the calling function; The calling unit is used to obtain the cached GRPC connection object corresponding to the demand by calling the unique service type ID generated by the function.

10. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the GPRC client unified management method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the GPRC client unified management method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Multi-thread processing method and device, storage medium and processor

    CN107562516A

  • A real-time long connection method and device based on a Go language

    CN109739652A