CN113778479A - Service agent method and device - Google Patents
Service agent method and device Download PDFInfo
- Publication number
- CN113778479A CN113778479A CN202110090297.5A CN202110090297A CN113778479A CN 113778479 A CN113778479 A CN 113778479A CN 202110090297 A CN202110090297 A CN 202110090297A CN 113778479 A CN113778479 A CN 113778479A
- Authority
- CN
- China
- Prior art keywords
- service
- function
- producer
- publishing agent
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 230000006870 function Effects 0.000 claims abstract description 201
- 238000013515 script Methods 0.000 claims abstract description 67
- 238000012545 processing Methods 0.000 claims description 20
- 238000012544 monitoring process Methods 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 9
- 238000004458 analytical method Methods 0.000 claims description 8
- 239000012141 concentrate Substances 0.000 abstract description 11
- 239000003795 chemical substances by application Substances 0.000 description 127
- 238000010586 diagram Methods 0.000 description 21
- 238000011161 development Methods 0.000 description 10
- 230000008569 process Effects 0.000 description 10
- 238000004891 communication Methods 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000000007 visual effect Effects 0.000 description 3
- 230000008901 benefit Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 101100446506 Mus musculus Fgf3 gene Proteins 0.000 description 1
- 101100317378 Mus musculus Wnt3 gene Proteins 0.000 description 1
- 101000767160 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) Intracellular protein transport protein USO1 Proteins 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000007667 floating Methods 0.000 description 1
- 230000008571 general function Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000000977 initiatory effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 238000012856 packing Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The invention discloses a service agent method and device, and relates to the technical field of computers. The specific implementation mode of the method comprises the following steps: determining one or more target functions common to a plurality of service producers; determining scripts corresponding to the one or more target functions; generating a service publishing agent according to the script; and sending a function request corresponding to one or more target functions to a management end by using the service publishing agent so that the management end realizes the target functions corresponding to one or more service producers according to the function request. The implementation mode can realize the common target function of a plurality of service producers through the service publishing agent, so that each service producer can concentrate on the unique function of the service producer, the same target function does not need to be repeatedly executed, and the system performance is improved.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a service broker method and apparatus.
Background
An RPC (remote Procedure Call protocol) framework is a remote calling service mode in microservices, and can improve calling efficiency.
When a service producer (i.e., a service provider) of an existing RPC framework provides a service, different service producers can implement various functions of their own.
However, different service producers may have the same functionality. Each service producer needs to be repeatedly executed for such same function, resulting in poor system performance.
Disclosure of Invention
In view of this, embodiments of the present invention provide a service broker method and apparatus, which can implement a target function common to multiple service producers through a service publishing broker, so that each service producer can concentrate on its own unique function, and the same target function does not need to be repeatedly executed, thereby improving system performance.
Further, when the function shared by a plurality of service producers needs to be updated, the script of the service publishing agent only needs to be updated, and the script of each service producer does not need to be updated, so that the development efficiency is improved.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a service broker method including:
determining one or more target functions common to a plurality of service producers;
determining scripts corresponding to the one or more target functions;
generating a service publishing agent according to the script;
and sending a function request corresponding to one or more target functions to a management end by using the service publishing agent so that the management end realizes the target functions corresponding to one or more service producers according to the function request.
Optionally, the service publishing agent comprises a codec protocol; the generating a service publishing agent according to the script includes:
according to a first coding format in the script and a second coding format required by the service publishing agent, converting the script of the first coding format into the second coding format according to the codec protocol;
and generating the service publishing agent according to the converted script.
Optionally, after the generating a service publishing agent according to the script, the method further includes:
receiving an inquiry request sent by the management terminal through the service publishing agent, wherein the inquiry request comprises an identifier of at least one service producer;
and responding to the query request, and sending the functional state of the at least one service producer to the management terminal through the service publishing agency.
Optionally, generating a mirror image of the service publishing agent;
and sending the functional state of the at least one service producer to the management terminal through the mirror image of the service publishing agent.
Optionally, receiving an update request for the one or more target functions;
and updating the script corresponding to the service publishing agent according to the updating request so as to update the target function shared by the plurality of service producers.
Optionally, the method further comprises:
when a new service producer is added, determining whether the new service producer has the target function, if so, registering the service producer to the service publishing agency so that the service publishing agency realizes the target function of the new service producer.
Optionally, the target function comprises any one or more of: the service registration function, the service quality monitoring function and the service heartbeat sending function.
According to still another aspect of an embodiment of the present invention, there is provided a service agent apparatus including:
an analysis module to determine one or more target functions common to a plurality of service producers;
the data processing module is used for determining scripts corresponding to the one or more target functions;
the generating module is used for generating a service publishing agent according to the script;
the request module is used for sending a function request corresponding to one or more target functions to a management end by using the service publishing agent so that the management end can realize the target functions corresponding to one or more service producers according to the function request.
According to another aspect of an embodiment of the present invention, there is provided a service agent electronic device including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the service broker method provided by the present invention.
According to still another aspect of an embodiment of the present invention, there is provided a computer-readable medium on which a computer program is stored, the program implementing the service broker method provided by the present invention when executed by a processor.
One embodiment of the above invention has the following advantages or benefits: because the technical means of generating the service publishing agent according to the script corresponding to the target function shared by the service producers is adopted, the technical problem that different service producers repeatedly execute the same function to cause poor system performance is solved, and the technical effect that each service producer can concentrate on the unique function of the service producer and does not need to repeatedly execute the same target function to improve the system performance is achieved
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is an exemplary system architecture diagram of a service broker method or service broker apparatus suitable for application to embodiments of the present invention;
FIG. 2 is a schematic diagram of the main flow of a service broker method according to an embodiment of the invention;
FIG. 3(a) is a first schematic diagram illustrating a detailed flow of a service broker method according to an embodiment of the present invention;
FIG. 3(b) is a second schematic diagram illustrating a detailed flow of another service brokering method according to an embodiment of the present invention;
FIG. 3(c) is a third schematic diagram illustrating a detailed flow of another service agent method according to an embodiment of the present invention;
FIG. 3(d) is an exemplary diagram of a codec according to an embodiment of the invention;
FIG. 3(e) is a diagram illustrating a calling process of a service broker method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main modules of a service broker apparatus according to an embodiment of the present invention;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
RPC: remote Procedure Call Protocol refers to a distributed node requesting a service provided by another distributed node.
Mirroring: is a form of file storage, meaning that the data on one disk has an identical copy on another disk.
Fig. 1 shows an exemplary system architecture diagram of a service broker method or a service broker apparatus suitable for being applied to an embodiment of the present invention, and as shown in fig. 1, the exemplary system architecture of the service broker method or the service broker apparatus of the embodiment of the present invention includes:
as shown in fig. 1, the system architecture 100 may include servers 101, 102, 103, a network 104, and a server 105 having a service broker 400 (not shown). Network 104 is the medium used to provide communication links between servers 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use servers 101, 102, 103 to interact with server 105 over network 104 to receive or send messages, etc. The servers 101, 102, 103 may be servers having a distributed architecture system.
The server 105 may be a server that provides various services, such as a background management server (for example only) that supports user requests for functions issued using the servers 101, 102, 103. The backend management server may analyze and otherwise process data such as the received registration request, and feed back a processing result (e.g., registration success/failure) to the servers 101, 102, and 103.
It should be noted that the service agent method provided by the embodiment of the present invention is generally executed by the server 105, and accordingly, the service agent apparatus is generally disposed in the server 105.
It should be understood that the number of networks and servers in fig. 1 is merely illustrative. There may be any number of networks and servers, as desired for implementation.
Fig. 2 is a schematic diagram of a main flow of a service agent method according to an embodiment of the present invention, and as shown in fig. 2, the service agent method of the present invention includes:
in step S201, one or more target functions common to a plurality of service producers are determined.
Service producers under the micro-service architecture can implement a wide variety of business logic and specific functions, where specific functions in the service producer are implemented by SDKs that are independent of the specific business. The specific functions of different service producers often have commonality, and therefore, the specific functions are often target functions that are common to multiple service producers. In order to improve the running performance of the system, one or more target functions which are common to a plurality of service producers, namely common to the service producers, are analyzed and determined, and are separated from the service producers, so that the target functions which respond can be independent, and the decoupling of business logic and functional logic is realized, thereby improving the system performance.
Step S202, determining a script corresponding to the one or more target functions.
After one or more target functions shared by a plurality of service producers are determined, script contents corresponding to the one or more target functions are determined based on the scripts of the service producers. The target function corresponds to a function for service release in a service producer; the script of the target function corresponds to the script of the function which is realized by the service release. The functions of service publishing may include functions of service registration, service quality monitoring, service heartbeat transmission, and the like. In order to realize the service registration function, the service release needs to send a registration request to a management terminal; in order to realize the service state monitoring and the service heartbeat sending function, service publishing needs to send the service state of a service producer to a management end.
Step S203, generating a service release agent according to the script.
After script contents corresponding to one or more target functions are determined, a service publishing agent is generated based on the script contents corresponding to the one or more target functions, wherein the script corresponding to the target function is a script published by the service, namely the service publishing agent is generated based on the script contents published by the service. The essence is to extract the functions shared by a plurality of service producers and to implement the shared functions through service distribution, i.e. to generate a service distribution agent. After the service publishing agent is generated, one or more target functions shared by a plurality of service producers can be realized by the service publishing agent, so that the code redundancy of the service producers is reduced, the complexity of system codes is reduced, and developers can concentrate on the development of business logic without considering the publishing logic of the service when developing the service.
Step S204, the service publishing agent is used for sending a function request corresponding to one or more target functions to a management end, so that the management end realizes the target functions corresponding to one or more service producers according to the function request.
After the service publishing agent is generated, one or more service producers can send function requests corresponding to one or more target functions to the management terminal through the service publishing agent, and the management terminal processes the function requests after receiving the function requests, so that the target functions corresponding to the function requests, namely the one or more target functions corresponding to the one or more service producers, are realized. The service publishing agents can comprise a plurality of service publishing agents, one or more target functions can correspond to one service publishing agent, and also can correspond to a plurality of service publishing agents; one or more service producers can correspond to one service publishing agent or a plurality of service publishing agents, and the setting can be selected according to the performance and the running condition of the service publishing agents.
Illustratively, the function request may be a registration request, after the service producer communicates with the service publishing agent, the service publishing agent sends the registration request to the management end, the management end returns a result to the service publishing agent after registration, and the service publishing agent returns a result of successful registration to the service producer; the service publishing agent can periodically send heartbeat detection to the management end, so that the management end confirms that the service producer is in a normal service state.
In the embodiment of the invention, one or more target functions shared by a plurality of service producers are determined; determining scripts corresponding to the one or more target functions; generating a service publishing agent according to the script; and sending a function request corresponding to one or more target functions to a management end by using the service release agent, so that the management end realizes the target functions corresponding to one or more service producers according to the function request, and the like.
Fig. 3(a) is a schematic diagram of a detailed flow of a service agent method according to an embodiment of the present invention, fig. 3(b) is a schematic diagram of a detailed flow of another service agent method according to an embodiment of the present invention, fig. 3(c) is a schematic diagram of a detailed flow of another service agent method according to an embodiment of the present invention, fig. 3(d) is an example of a compilation protocol according to an embodiment of the present invention, fig. 3(e) is a schematic diagram of a calling process of a service agent method according to an embodiment of the present invention, as shown in fig. 3(a), the service agent method of the present invention includes:
in step S301, a target function common to service producers is determined.
The RPC framework of the microservice is suitable for a distributed architecture, and can realize remote calling between services, namely remote calling between distributed nodes. A service producer under the existing RPC framework includes the business logic of the service and the publishing logic of the service,
for example, when the service producer implements internal service publishing logic, each service producer may need to repeatedly execute the related function of service publishing, and the related function of service publishing has commonality, so in order to improve system performance, so that the service producer does not need to repeatedly execute the related function of service publishing with commonality, one or more target functions common to a plurality of service producers are determined and extracted from the service producer, thereby the target function related to service publishing can be executed by one agent, and system performance is improved. The target function corresponds to a function issued for a service in the service producer.
Further, service publishing may provide service implementation of related functions in the form of a service interface, enabling service consumers to discover and invoke services from a management side.
Step S302, determining script content of the target function.
After determining one or more target functions common to a plurality of service producers, script content of the one or more target functions is searched and determined based on the codes of the service producers. The script content of the target function is the script content of the function realized by the service release. The functions of service publishing may include functions of service registration, service quality monitoring, service heartbeat transmission, and the like.
Step S303, encoding format processing.
After determining the script content of one or more target functions shared by a plurality of service producers, according to a first encoding format of the script content of one or more target functions and a second encoding format required by the generated service publishing agent, the script content of the first encoding format is converted into the script content of the second encoding format based on a codec protocol.
Illustratively, as shown in fig. 3(b), the service producer, when implementing the system application, includes service logic and an SDK, the SDK includes: compiling a protocol; the functions of service registration, service quality monitoring, service heartbeat sending and the like can be realized. When a service release agent is generated, the SDK of a service producer is modified, the general function service registration, the service quality monitoring, the service heartbeat sending and the like in the SDK are extracted, the compiling and resolving protocol of the SDK is stored, and the service release logic is formed by the SDK and the compiling and resolving protocol; meanwhile, the original service logic of the service producer is kept unchanged, and the SDK only keeps the original compiling and solving protocol, so that one or more common target functions of a plurality of service producers can be realized through the service publishing agent, the code redundancy of the service producer is reduced, and the development efficiency is improved.
Illustratively, as shown in fig. 3(c), the generic function service registration, the service quality monitoring, the service heartbeat sending, and the like of the service producer are extracted, and the codec is saved to generate the service publishing agent. The service publishing agent can realize the functions of service registration, service quality monitoring, service heartbeat sending and the like.
Step S304, a service publishing agent is generated.
After converting script contents of a first encoding format of one or more target functions shared by a plurality of service producers into script contents of a second encoding format, generating a service publishing agent according to the converted script contents of the one or more target functions of the second encoding format. When a service producer under the existing RPC framework realizes service release, the service release is embedded in an application program of a service, correspondingly, a code of the service release is embedded in a code of the service producer, a business logic of the service is coupled with a release logic of the service, and if the business logic or related content of the release logic needs to be developed, a developer needs to modify the code of the service producer integrally. After one or more target functions shared by a plurality of service producers are generated into a service publishing agent, the service producers can realize the shared target functions through the service publishing agent, so that each service producer can concentrate on the unique function of the service producer, and developers can concentrate on the development of the business logic of the service without considering the publishing logic of the service; or, the developer can concentrate on the development of the service release logic without considering the service logic of the service, thereby reducing the workload of the developer and the code complexity of the service producer and reducing the code redundancy of the service producer.
Illustratively, based on the compilation protocol, the service publishing agent may implement the service provider to provide services to data structures in different languages. The codec protocol is a standard for converting to binary codec protocol, and the data consists of two parts including header information and entity data. The header information includes a field Type and a field number Tag, the Type is used to identify the Type of entity part data corresponding to the header information, the length and format of the entity part data of different types are different, for example, Type ═ 0 indicates that the data Type is int1, and the length and format of the corresponding entity part data are integer data following 1 byte; type 1, 2 and 3 indicate that the data types are int2, int4 and int8, and the length and format of the corresponding entity part data are immediately followed by 2, 4 and 8 bytes integer data; the Type is 4 and 5, the data Type is float and double, and the length and format of the corresponding entity part data are floating point Type data which are followed by 4 bytes and 8 bytes; the Type is 6 and 7, the data types are string1 and string4, the length and the format of the corresponding entity part data are 1 byte and 4 bytes, and the data are followed with the content; 8, the data Type is Map, the length and format of the corresponding entity data are the size of Map represented by 1 integer data, and then the list of key value pairs is followed; the Type is 9, the data Type is List, the length and the format of the corresponding entity part data are the size of the List which is represented by following 1 integer data, and then the List is followed by the element List; the Type is 10, the data Type is the start of the self-defined structure, and the length and the format of the corresponding entity part data are the start mark of the self-defined structure; the Type is 11, the data Type is the end of the self-defined structure, the length and the format of the corresponding entity part data are the end mark of the self-defined structure, and Tag is 0; the Type is 12, the data Type is number 0, the length and format of the corresponding entity part data are number 0, and data are not followed; type 13 indicates that the data Type is SimpleList, the length and format of the corresponding entity part data are simple lists (for example, byte arrays), 1 Type field (for example, byte) is followed, 1 integer data indicates the length, and then byte data is followed.
Further, the different languages may be converted into binary through serialization, for example, the language is C + + language, as shown in fig. 3 (d). By establishing a uniform compilation protocol, cross-language development of a service producer can be realized, and development efficiency can be improved.
Furthermore, when the target function shared by a plurality of service producers needs to be updated, only the script content of the service publishing agent needs to be updated, and the code of each service producer does not need to be updated, so that the development efficiency is improved.
Step S305, the service publishing agent encapsulates.
And after the service publishing agent is generated, packaging/packing the service publishing agent to obtain a service publishing agent interface for providing service for a service producer. When a new service producer is added, whether the new service producer has the target function corresponding to the service publishing agent is judged, if yes, the service producer can be accessed into the service publishing agent interface, and the service publishing agent can realize the target function of the new service producer. The service publishing agent interface is deployed in a distributed manner in a service process, and can be exclusively owned by a single machine or shared by a plurality of machines.
Step S306, registering the management terminal.
After the service publishing agent is packaged, a plurality of service producers send service registration requests to the management end through the service publishing agent interface, the management end requests to register the plurality of service producers on the management end, after the management end passes the registration, the registration result is returned to the service publishing agent through TCP calling, and the service publishing agent returns the registration result to the corresponding plurality of service producers. After the service producer is successfully registered, the management terminal can send the list information of the service producer to the service consumer according to the request of the service consumer, so that the service consumer can select the service producer to provide the required service for the service consumer.
For example, after the service producer successfully registers with the management terminal through the service publishing agent, the service publishing agent may send the service state of the service producer to the management terminal, so as to implement functions of service state monitoring, service heartbeat sending, and the like.
Step S307, the service publishing agent mirrors.
After a plurality of service producers successfully register to the management terminal through the service publishing agent, the service producers request the server to distribute the container, and the service publishing agent mirror image is installed on the container, so that the management terminal can selectively operate the deployment condition of the service publishing agent interface according to the requirement through the service publishing agent mirror image. The service publishing agent comprises a service publishing producer and a service publishing consumer, and the management end can selectively check the service publishing producer and the service publishing consumer of the service publishing agent interface according to needs through the service publishing agent mirror image and start and stop or modify the configuration of the service according to needs. The management terminal is based on the service publishing agent mirror image, and the deployment condition of the service publishing agent interface is checked, modified and started and stopped through the visual interface, so that the service state of the system can be monitored while the normal operation of the original system is ensured, the operation of the original system is not interfered, and the operation stability of the original system is ensured.
Illustratively, the service release mirror image is deployed through the container, so that the relevant functions of the service release can be selectively selected and correspondingly operated after the container is applied and distributed, operation and maintenance personnel can uniformly monitor the service release of all machines when maintaining the system, the start and stop of a service release interface and the configuration of relevant information are performed through a visual interface, and the operation and maintenance cost can be greatly reduced. And the operation is carried out through a visual interface of the service release, so that the centralized management and control of the service release are realized.
Further, the management terminal can directly check the service publishing producer and the service publishing consumer of the service publishing agent interface through the service publishing agent, and start and stop or modify the configuration of the service according to the requirement.
Step S308, the service publishing agent runs.
After the service publishing agent mirror image is installed on the container in the server, the management end can select whether to load the service publishing mirror image according to the requirement, if the service publishing mirror image is loaded, the service publishing mirror image is loaded when the server is started, and the management end can check the deployment condition of the service publishing interface and perform corresponding operation.
As shown in fig. 3(e), the calling process of the service broker method of the present invention includes:
and the client applies for a deployment container to the system when the service is started, and encapsulates the service producer and the service publishing agent by using the container after the container is obtained to obtain a service publishing agent interface. The client may be a developer. Initiating a service request to a service release producer through a service release agent interface; after receiving the service request, the service producer initiates a service release request to a service release consumer according to information such as a service interface, an alias and the like in the service request; after receiving the service publishing request, the service publishing consumer sends the request to the service publishing producer through TCP direct connection calling; and after receiving the calling request, the service release producer initiates a function request to the management terminal. The management terminal can be a service registration center, and a service release producer can initiate a request to the service registration center through TCP calling. After the management side processes the function request, a processing result is returned to the service release producer; after receiving the processing result, the service release producer returns the processing result to the service release consumer; after receiving the processing result returned by the service release producer, the service release consumer returns the processing result to the service producer; and after receiving the processing result, the service producer returns the processing result to the service publishing agent interface, so that the client can obtain the result of successful/failed execution.
Illustratively, the main function of the service publishing agent is to obtain the request of the service producer, and return the service result to the client through RPC by a series of service publishing policies, including connecting the registry, configuring the cluster fault tolerance policy, and the load balancing policy of the service producer.
Illustratively, the portion of the service publication may be the envoy of the ServiceMesh service grid; the compiling protocol can be a grpc protocol, a thrift protocol and the like;
in the embodiment of the invention, the target functions shared by the service producers are determined; determining script content of a target function; processing a coding format; generating a service publishing agent; service publishing agent encapsulation; registering to a management terminal; a service publishing agent mirror image; the service release agent runs and other steps, and the common target function of a plurality of service producers can be realized through the service release agent, so that each service producer can concentrate on the unique function of the service producer, the same target function does not need to be repeatedly executed, and the system performance is improved.
Fig. 4 is a schematic diagram of main modules of a service broker apparatus according to an embodiment of the present invention, and as shown in fig. 4, a service broker apparatus 400 of the present invention includes:
an analysis module 401 for determining one or more target functions common to a plurality of service producers.
Illustratively, a service producer under the microservice architecture can implement a wide variety of business logic and specific functions, where specific functions in the service producer are implemented by SDKs that are independent of the specific business. The specific functions of different service producers often have commonality, and therefore, the specific functions are often target functions that are common to multiple service producers. In order to improve the operation performance of the system, the analysis module 401 analyzes and determines one or more target functions of the plurality of service producers, which are common, and separates the one or more target functions from the service producers, so that the target functions of the response can be independent, and the decoupling of the business logic and the functional logic is realized, thereby improving the system performance.
A data processing module 402, configured to determine a script corresponding to the one or more target functions.
Illustratively, after the analysis module 401 determines one or more target functions shared by a plurality of service producers, the data processing module 402 determines script contents corresponding to the one or more target functions based on the scripts of the service producers. The target function corresponds to a function for service release in a service producer; the script of the target function corresponds to the script issued by the service. The functions of service publishing may include functions of service registration, service quality monitoring, service heartbeat transmission, and the like. In order to realize the service registration function, the service release needs to send a registration request to a management terminal; in order to realize the service state monitoring and the service heartbeat sending function, service publishing needs to send the service state of a service producer to a management end.
A generating module 403, configured to generate a service publishing agent according to the script.
Illustratively, after the data processing module 402 determines script contents corresponding to one or more target functions, the generating module 403 generates a service publishing agent based on the script contents corresponding to one or more target functions, where the script corresponding to a target function is a script published by a service, that is, the service publishing agent is generated based on the script contents published by the service. The essence is to extract the functions shared by a plurality of service producers and to implement the shared functions through service distribution, i.e. to generate a service distribution agent. After the generating module 403 generates the service publishing agent, one or more target functions shared by a plurality of service producers can be realized by the service publishing agent, so that the code redundancy of the service producers is reduced, the complexity of system codes is reduced, and developers can concentrate on the development of business logic without considering the publishing logic of the service when developing the service.
A request module 404, configured to send, by using the service publishing agent, a function request corresponding to one or more target functions to a management end, so that the management end implements the target functions corresponding to the one or more service producers according to the function request.
For example, after the generating module 403 generates the service publishing agent, one or more service producers can send a function request corresponding to one or more target functions to the management end by using the requesting module 404 through the service publishing agent, and the management end processes the function request after receiving the function request, so as to implement the target function corresponding to the function request, that is, one or more target functions corresponding to one or more service producers. The service publishing agents can comprise a plurality of service publishing agents, one or more target functions can correspond to one service publishing agent, and also can correspond to a plurality of service publishing agents; one or more service producers can correspond to one service publishing agent or a plurality of service publishing agents, and the setting can be selected according to the performance and the running condition of the service publishing agents.
Further, the function request may be a registration request, after the service producer communicates with the service publishing agent, the service publishing agent sends the registration request to the management end, the management end returns a result to the service publishing agent after registration, and the service publishing agent returns a result of successful registration to the service producer; the service publishing agent can periodically send heartbeat detection to the management end, so that the management end confirms that the service producer is in a normal service state.
In the embodiment of the invention, through the analysis module, the data processing module, the generation module, the request module and other modules, the common target function of a plurality of service producers can be realized through the service publishing agent, so that each service producer can concentrate on the unique function of the service producer and does not need to repeatedly execute the same target function, and the system performance is improved.
Fig. 5 is a schematic structural diagram of a computer system suitable for implementing a terminal device according to an embodiment of the present invention, and as shown in fig. 5, the computer system 500 of the terminal device according to the embodiment of the present invention includes:
a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the system 500 are also stored. The CPU501, ROM502, and RAM503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes an analysis module, a data processing module, a generation module, and a request module. Where the names of these modules do not in some cases constitute a limitation on the module itself, for example, an analysis module may also be described as a "module that analyzes scripts of multiple service producers to determine a target function common to the multiple service producers".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: determining one or more target functions common to a plurality of service producers; determining scripts corresponding to the one or more target functions; generating a service publishing agent according to the script; and sending a function request corresponding to one or more target functions to a management end by using the service publishing agent so that the management end realizes the target functions corresponding to one or more service producers according to the function request.
According to the technical scheme of the embodiment of the invention, the common target function of a plurality of service producers can be realized through the service publishing agent, so that each service producer can concentrate on the unique function of the service producer, the same target function does not need to be repeatedly executed, and the system performance is improved.
Further, when the function shared by a plurality of service producers needs to be updated, the script of the service publishing agent only needs to be updated, and the script of each service producer does not need to be updated, so that the development efficiency is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A service brokering method, comprising:
determining one or more target functions common to a plurality of service producers;
determining scripts corresponding to the one or more target functions;
generating a service publishing agent according to the script;
and sending a function request corresponding to one or more target functions to a management end by using the service publishing agent so that the management end realizes the target functions corresponding to one or more service producers according to the function request.
2. The method of claim 1, wherein the service publishing agent comprises a codec; the generating a service publishing agent according to the script includes:
according to a first coding format in the script and a second coding format required by the service publishing agent, converting the script of the first coding format into the second coding format according to the codec protocol;
and generating the service publishing agent according to the converted script.
3. The method of claim 1, after the generating a service publishing agent according to the script, further comprising:
receiving an inquiry request sent by the management terminal through the service publishing agent, wherein the inquiry request comprises an identifier of at least one service producer;
and responding to the query request, and sending the functional state of the at least one service producer to the management terminal through the service publishing agency.
4. The method of claim 3,
generating a mirror image of the service publishing agent;
and sending the functional state of the at least one service producer to the management terminal through the mirror image of the service publishing agent.
5. The method of claim 1,
receiving an update request for the one or more target functions;
and updating the script corresponding to the service publishing agent according to the updating request so as to update the target function shared by the plurality of service producers.
6. The method of claim 1, further comprising:
when a new service producer is added, determining whether the new service producer has the target function, if so, registering the service producer to the service publishing agency so that the service publishing agency realizes the target function of the new service producer.
7. The method of claim 1, wherein the target function comprises any one or more of: the service registration function, the service quality monitoring function and the service heartbeat sending function.
8. A service broker apparatus, comprising:
an analysis module to determine one or more target functions common to a plurality of service producers;
the data processing module is used for determining scripts corresponding to the one or more target functions;
the generating module is used for generating a service publishing agent according to the script;
the request module is used for sending a function request corresponding to one or more target functions to a management end by using the service publishing agent so that the management end can realize the target functions corresponding to one or more service producers according to the function request.
9. A service broker electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110090297.5A CN113778479A (en) | 2021-01-22 | 2021-01-22 | Service agent method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110090297.5A CN113778479A (en) | 2021-01-22 | 2021-01-22 | Service agent method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113778479A true CN113778479A (en) | 2021-12-10 |
Family
ID=78835484
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110090297.5A Pending CN113778479A (en) | 2021-01-22 | 2021-01-22 | Service agent method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113778479A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101048732A (en) * | 2004-08-31 | 2007-10-03 | 国际商业机器公司 | Object oriented architecture for data integration service |
US20090133113A1 (en) * | 2007-11-15 | 2009-05-21 | Schneider James P | Adding client authentication to networked communications |
CN101686173A (en) * | 2008-09-27 | 2010-03-31 | 华为技术有限公司 | Method, system and apparatus of service negotiation |
CN110032392A (en) * | 2019-04-15 | 2019-07-19 | 杭州朗和科技有限公司 | Service administering method and device, storage medium and electronic equipment |
WO2020048391A1 (en) * | 2018-09-04 | 2020-03-12 | 京东数字科技控股有限公司 | Methods and apparatuses for deploying and invoking web services based on multi-tenancy technology |
CN111654386A (en) * | 2020-01-15 | 2020-09-11 | 许继集团有限公司 | Method and system for establishing service function chain |
-
2021
- 2021-01-22 CN CN202110090297.5A patent/CN113778479A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101048732A (en) * | 2004-08-31 | 2007-10-03 | 国际商业机器公司 | Object oriented architecture for data integration service |
US20090133113A1 (en) * | 2007-11-15 | 2009-05-21 | Schneider James P | Adding client authentication to networked communications |
CN101686173A (en) * | 2008-09-27 | 2010-03-31 | 华为技术有限公司 | Method, system and apparatus of service negotiation |
WO2020048391A1 (en) * | 2018-09-04 | 2020-03-12 | 京东数字科技控股有限公司 | Methods and apparatuses for deploying and invoking web services based on multi-tenancy technology |
CN110032392A (en) * | 2019-04-15 | 2019-07-19 | 杭州朗和科技有限公司 | Service administering method and device, storage medium and electronic equipment |
CN111654386A (en) * | 2020-01-15 | 2020-09-11 | 许继集团有限公司 | Method and system for establishing service function chain |
Non-Patent Citations (4)
Title |
---|
刘婧;李宥谋;黄建军;周欢;: "基于无线Mesh网络仪器代理的设计与实现", 现代电子技术, no. 02, 15 January 2017 (2017-01-15) * |
王汝传, 邓玉龙, 王颖: "移动代理技术模型的研究和实现", 计算机工程与应用, no. 03, 9 March 2000 (2000-03-09) * |
郑世明;高歆;付雪梅;钱一虹;王智新;: "基于Web服务的作战仿真模型一体化建模与验证", 指挥控制与仿真, no. 05, 15 October 2012 (2012-10-15) * |
阳王东;吴宏斌;祝青;: "一种基于服务空间的服务提供模型", 小型微型计算机系统, no. 11, 15 November 2008 (2008-11-15) * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11843661B2 (en) | Web service system and method | |
US6757899B2 (en) | Dynamic CORBA gateway for CORBA and non-CORBA clients and services | |
US9002997B2 (en) | Instance host configuration | |
CN109922158A (en) | Data processing method, device, medium and electronic equipment based on micro services | |
CN109815025B (en) | Service model calling method, device and storage medium | |
CN109104368B (en) | Connection request method, device, server and computer readable storage medium | |
CN113821352A (en) | Remote service calling method and device | |
CN113703997A (en) | Bidirectional asynchronous communication middleware system integrating multiple message agents and implementation method | |
US11531526B1 (en) | Creating portable serverless applications | |
EP3398304B1 (en) | Network service requests | |
CN113992641B (en) | Data processing method, device, equipment and storage medium | |
US11494184B1 (en) | Creation of transportability container files for serverless applications | |
CN112905273A (en) | Service calling method and device | |
CN110780915B (en) | Data processing method, device and storage medium | |
US12120205B2 (en) | Communication protocol for a distributed event streaming platform | |
CN113778479A (en) | Service agent method and device | |
CN109660573B (en) | Data transmission method and device | |
CN113973139B (en) | Message processing method and device | |
CN114285859B (en) | Data processing method, device, equipment and storage medium for middle layer block chain service | |
CN116755799A (en) | Service arrangement system and method | |
US11513833B1 (en) | Event listener interface for container-based execution of serverless functions | |
CN114968636A (en) | Fault processing method and device | |
CN114489754A (en) | Configurable service management method and device | |
CN111949472A (en) | Method and device for recording application logs | |
CN116860353B (en) | Data processing method, device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |