CN-114490136-B - Service calling and providing method, device, electronic equipment, medium and program product
Abstract
The present disclosure provides a service invocation method, a service providing method, an apparatus, an electronic device, a medium, and a computer program product based on a unitized architecture. The method and the device can be used in the fields of distributed computing and financial technology. The service calling method comprises the steps of providing a service request, wherein the service request comprises item information of a target service item, obtaining stub information of the service item corresponding to the target service item, analyzing annotation information in interface definition of the stub information to obtain an attribute value in the annotation information, loading a class corresponding to the attribute value in the annotation information, executing the class method to obtain a customer characteristic value, determining a unitization module capable of providing the target service item according to the customer characteristic value, and initiating a calling request to the unitization module capable of providing the target service item.
Inventors
- GUAN HAICHAO
- XIA LONGFEI
- YAN GAOFEI
Assignees
- 中国工商银行股份有限公司
- 中国工商银行股份有限公司
Dates
- Publication Date
- 20260421
- Application Date
- 20220215
- Priority Date
- 20220215
Claims (6)
- 1. A service invocation method based on a unitized architecture, the unitized architecture comprising a plurality of unitized modules that deploy service providers and service consumers, each of the service providers providing a service transaction, each of the service transactions having corresponding stub information, the stub information comprising an interface definition of the service transaction, the service invocation method being applied to the service consumer, the method comprising: providing a service request, wherein the service request comprises item information of a target service item; Obtaining stub information of a service item corresponding to the target service item; analyzing annotation information in interface definition of the stub information to obtain attribute values in the annotation information; Loading a class corresponding to the attribute value in the annotation information; executing the class method to obtain a client characteristic value, wherein the client characteristic value comprises address information of a user; determining a unitized module capable of providing the target service item according to the client characteristic value, and A call request is initiated to a unitized module capable of providing the target service instance, Wherein the step of determining a unitized module capable of providing the target service item according to the customer characteristic value comprises: calculating the number of the unitized module corresponding to the address information, and And determining a unitized module capable of providing the target service item according to the number.
- 2. The method of claim 1, wherein the transaction information includes a request parameter; the method of executing the class to obtain the client characteristic value includes executing the class method to parse the client characteristic value from the request parameter.
- 3. A service invocation apparatus based on a unitized architecture, the unitized architecture comprising a plurality of unitized modules that deploy service providers and service consumers, each of the service providers providing a service transaction, each of the service transactions having corresponding stub information, the stub information comprising an interface definition of the service transaction, the apparatus comprising: the system comprises a request module, a service request module and a service request module, wherein the request module is used for executing a service request, and the service request comprises item information of a target service item; The acquisition module is used for executing the stub information of the service item corresponding to the target service item; the analysis module is used for executing analysis of the annotation information in the interface definition of the stub information so as to obtain an attribute value in the annotation information; The loading module is used for executing loading of the class corresponding to the attribute value in the annotation information; The execution module is used for executing the class method to acquire a client characteristic value, wherein the client characteristic value comprises address information of a user; a determination module for executing a unitization module for determining that the target service item can be provided according to the client characteristic value, and A calling module for executing a call request initiated to a unitization module capable of providing the target service item, Wherein the step of determining a unitized module capable of providing the target service item according to the customer characteristic value comprises: calculating the number of the unitized module corresponding to the address information, and And determining a unitized module capable of providing the target service item according to the number.
- 4. An electronic device, comprising: One or more processors; One or more memories for storing executable instructions which, when executed by the processor, implement the method according to any of claims 1-2.
- 5. A computer readable storage medium, characterized in that the storage medium has stored thereon executable instructions which, when executed by a processor, implement the method according to any of claims 1-2.
- 6. A computer program product comprising a computer program comprising one or more executable instructions which when executed by a processor implement the method according to any one of claims 1-2.
Description
Service calling and providing method, device, electronic equipment, medium and program product Technical Field The present disclosure relates to the field of distributed computing and financial technology, and more particularly, to a service invocation method, a service providing method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product based on a unitized architecture. Background In a traditional distributed architecture, all provider nodes of a service are logically equal, and a consumer needs to invoke the service, and optionally one provider initiates the invocation according to the load balancing policy provided by the RPC framework, without further consideration. However, in the unitized architecture, the situation changes. The provider of a certain service is divided into a plurality of units, and a whole set of provider clusters and corresponding database resources with complete functions are deployed in each unit. In this scenario, a consumer in one unit must first calculate which unit's provider should be invoked to invoke the service, which may have two consequences, one is to invoke the provider of the unit, which directly initiates the RPC invocation, and the second is to invoke the provider of the other unit, which requires cross-unit invocation. Today, where microservices are widely popular, a centralized configuration center is a very natural choice. The service provider writes the unitized features of all the services provided by the service provider into a configuration center, a consumer acquires the features from the configuration center and caches the features locally, and the consumer directly reads the feature information of the Key-Value structure as target unit identification in the running process and then invokes the service provider in the unit or other units. Disclosure of Invention In view of this, the present disclosure provides a service invocation method, a service providing method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product based on a unitized architecture, which have little dependency, low cost of operation and code maintenance, and little difficulty of code maintenance. An aspect of the present disclosure provides a service invocation method based on a unitized architecture including a plurality of unitized modules that deploy service providers and service consumers, each of the service providers providing a service transaction, each of the service transaction having corresponding stub information including an interface definition of the service transaction, the service invocation method being applied to the service consumer, the method including providing a service request including transaction information of a target service transaction, obtaining stub information of the service transaction corresponding to the target service transaction, parsing annotation information in the interface definition of the stub information to obtain attribute values in the annotation information, loading classes corresponding to the attribute values in the annotation information, executing the methods of the classes to obtain customer characteristic values, determining a unitized module capable of providing the target service transaction according to the customer characteristic values, and initiating invocation of the unitized module capable of providing the target service transaction. According to the service calling method based on the unitized framework, the attribute value of the client characteristic value can be obtained by analyzing the annotation information in the interface definition of the stub information, the attribute value of the client characteristic value can be analyzed from the item information of the target service item, the client characteristic value can be analyzed by executing the method corresponding to the attribute value, and therefore the unitized module capable of providing the target service item is determined according to the client characteristic value. In some embodiments, the transaction information includes a request parameter, and the executing the class method to obtain the customer characteristic value includes executing the class method to parse the customer characteristic value from the request parameter. In some embodiments, the customer characteristic value includes address information of the user in the request parameter. In some embodiments, the determining the unitization module capable of providing the target service item according to the address information comprises calculating a number of the unitization module corresponding to the address information, and determining the unitization module capable of providing the target service item according to the number. Another aspect of the disclosure provides a service invocation apparatus based on a unitized architecture, the unitized architecture including a plurality of unitized modules