[go: up one dir, main page]

CN116800848A - A service calling method, device and client - Google Patents

A service calling method, device and client Download PDF

Info

Publication number
CN116800848A
CN116800848A CN202310706275.6A CN202310706275A CN116800848A CN 116800848 A CN116800848 A CN 116800848A CN 202310706275 A CN202310706275 A CN 202310706275A CN 116800848 A CN116800848 A CN 116800848A
Authority
CN
China
Prior art keywords
target
service
address information
instance
initial
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
Application number
CN202310706275.6A
Other languages
Chinese (zh)
Inventor
张正园
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
CCB Finetech Co Ltd
Original Assignee
China Construction Bank Corp
CCB Finetech Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp, CCB Finetech Co Ltd filed Critical China Construction Bank Corp
Priority to CN202310706275.6A priority Critical patent/CN116800848A/en
Publication of CN116800848A publication Critical patent/CN116800848A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a service calling method, a service calling device and a service calling client, and belongs to the technical field of cloud computing. The method comprises the following steps: receiving an initial service call request initiated by a target application; the initial service call request carries initial address information; extracting a service name from the initial address information; inquiring whether an instance matched with the service name exists in a local cache of the client; acquiring a target instance sent by a registry under the condition that the target instance does not exist; the target instance includes target address information; replacing the initial address information in the initial service call request by utilizing the target address information to obtain a target service call request; sending a target service call request to a target application; the target application is used for accessing the service resource pointed by the target address information to complete service call. Through the method, the error address in the service call request can be directly modified under the condition that a user does not feel, so that the correct call of the service is realized.

Description

Service calling method, device and client
Technical Field
The application belongs to the technical field of cloud computing, and particularly relates to a service calling method, a service calling device and a service calling client.
Background
Service discovery is a concept in a micro-service architecture, referring to the process of finding and accessing service instances in a distributed system. The existing service discovery capability generally needs to import and call an open source component in engineering codes or systems, the import and call the open source component can enable core functions such as service discovery and service call to be deeply coupled with the open source component, if the open source component changes, a dependent package of the open source component needs to be recompiled and packaged, and then the regulated new system can be obtained through the steps of modifying bottom layer codes, testing, on-line publishing and the like. The mode is complex in operation and high in development cost.
In view of the above technical problems, no effective solution has been proposed at present.
Disclosure of Invention
The application provides a service calling method, a service calling device and a service calling client, which can solve the technical problem of high development difficulty caused by dependence on an open source component in the existing method.
An object of an embodiment of the present application is to provide a service invocation method, where the method is applied to a proxy module, and the proxy module is deployed at a client, and the method includes:
receiving an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client;
Extracting a service name from the initial address information;
inquiring whether an instance matched with the service name exists in a local cache of the client;
under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name;
replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request;
sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
Further, in another embodiment of the method, after receiving the initial service call request initiated by the target application, the method further includes:
detecting whether the initial address information meets preset requirements;
and under the condition that the initial address information does not meet the preset requirement, extracting the service name from the initial address information.
Further, in another embodiment of the method, the method further comprises:
and returning the initial service call request to the target application under the condition that the initial address information meets the preset requirement.
Further, in another embodiment of the method, the detecting whether the initial address information meets a preset requirement includes:
detecting whether the initial address information comprises IP information and port information;
and under the condition that the initial address information comprises IP information and port information, determining that the initial address information meets the preset requirement.
Further, in another embodiment of the method, the method further comprises:
and under the condition that the initial address information does not comprise IP information and port information, determining that the initial address information does not meet the preset requirement.
Further, in another embodiment of the method, the obtaining the target instance sent by the registry includes:
sending a query request to a registry; wherein the query request carries the service name; the registry is used for inquiring in a registry database to obtain a plurality of first instances matched with the service names, and sending the plurality of first instances to the proxy module;
Receiving the first instances sent by the registry;
and screening the plurality of first examples to obtain target examples.
Further, in another embodiment of the method, the screening from the plurality of first instances to obtain the target instance includes: and selecting target examples from the plurality of first examples by adopting a polling selection or random selection mode.
Further, in another embodiment of the method, the method further comprises: the plurality of first instances are stored in the local cache.
Further, in another embodiment of the method, the method further comprises:
under the condition that the fact that the instance matched with the service name exists in the local cache is determined, screening to obtain a target instance from the instance matched with the service name in the local cache; wherein the target instance includes target address information;
replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request;
sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
Further, in another embodiment of the method, the method further comprises:
sending an update instance request to the registry at regular time; the registry is used for returning an update instance to the proxy module after receiving the update instance request;
receiving an updated instance returned by the registry;
storing the updated instance in the local cache.
In another aspect, the present application provides a service invocation apparatus, the apparatus being applied to a proxy module, the proxy module being deployed at a client, the apparatus comprising:
the receiving module is used for receiving an initial service call request initiated by the target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client;
the extraction module is used for extracting a service name from the initial address information;
the query module is used for querying whether an instance matched with the service name exists in the local cache of the client;
the acquisition module is used for acquiring a target instance sent by a registry under the condition that the instance matched with the service name does not exist in the local cache; wherein the target instance includes target address information; the target instance is matched with the service name;
The replacing module is used for replacing the initial address information in the initial service call request by utilizing the target address information to obtain a target service call request;
the sending module is used for sending the target service calling request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
In another aspect, the present application provides a client, including at least one processor and a memory for storing instructions executable by the processor, where the processor implements the steps of any one of the method embodiments of the present application when executing the instructions.
In another aspect, the application provides a computer readable storage medium having stored thereon computer instructions which when executed perform the steps of any of the method embodiments of the application.
In another aspect, the application provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of any of the method embodiments of the application.
Based on the service calling method provided by the application, an initial service calling request initiated by a target application is received; wherein, the initial service call request carries initial address information; the target application is deployed at the client; extracting a service name from the initial address information; inquiring whether an instance matched with the service name exists in a local cache of the client; under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name; replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request; sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call. The error address in the service call request can be directly modified without perception of the user, and correct call of the service is realized without modifying the bottom layer code.
Drawings
In order to more clearly illustrate the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described, and the drawings described below are only some embodiments described in the present application, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
FIG. 1 is a flow diagram of one embodiment of a service invocation method provided by the present application;
FIG. 2 is a class loading flow diagram based on a java agent;
FIG. 3 is a schematic diagram of an application service after using a java agent according to the present application;
FIG. 4 is a schematic diagram of a request call flow in one example of a specific scenario of the present application;
FIG. 5 is a schematic block diagram illustrating an embodiment of a service invocation apparatus according to the present application;
FIG. 6 is a block diagram of the hardware architecture of one embodiment of a client provided by the present application.
Detailed Description
In order to make the technical solution of the present application better understood by those skilled in the art, the technical solution of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, shall fall within the scope of the application.
Service discovery is a concept in a micro-service architecture, referring to the process of finding and accessing service instances in a distributed system. In the prior art, service discovery capability generally needs to import and call an open source component in engineering codes or systems, and the manner of relying on the open source component can enable core functions such as service discovery and service call to be deeply coupled with the open source component, if the open source component changes, a dependent package of the open source component needs to be recompiled and packaged, and then the regulated new system can be obtained through steps such as bottom code modification, testing, on-line release and the like. The mode is complex in operation and high in development cost. Moreover, the use of the open source component also needs to solve the problem of dependency library version conflict between the service and the open source component, so that the use of the open source component has drawbacks.
Aiming at the problems and the specific reasons for generating the problems in the prior method, the application considers to introduce a service calling method based on byte code enhancement to finish code-free invasive service calling and service discovery.
Based on the above thought, the present application provides a service calling method, where the method is applied to a proxy module, and the proxy module is deployed at a client, and the method includes: receiving an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client; extracting a service name from the initial address information; inquiring whether an instance matched with the service name exists in a local cache of the client; under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name; replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request; sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
It should be noted that, the information data related to the user in the present application is obtained and used on the premise that the user knows and agrees. And, the information data is acquired, stored, used, processed and the like, which meet the relevant regulations of national laws and regulations.
Referring to fig. 1, an embodiment of the present application provides a service calling method. In particular implementations, the method may include the following.
S101: receiving an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client.
In some embodiments, the target application may be a software, system, web page, platform, or the like; a service refers to a particular data processing function that allows for function calls. For example, a service required by a certain shopping platform can be disassembled into a payment service, a logistics inquiry service, an inventory inquiry service and the like, when the shopping platform wants to use the certain service, a service call request is initiated, and the service can be called by accessing a site or an interface of the service which is open to the outside without knowing the underlying code of the service. The micro-service is a software application for providing business function services to the outside, is a collection of numerous services, each service in the micro-service has an autonomous running business function, and is an Application Programming Interface (API) which is free from language limitation on the outside, and the API usually uses THHP protocol and can be called by the outside. The method disclosed by the application can be applied to a micro-service scene and also can be applied to a conventional service scene.
In some embodiments, in order to improve availability when running deployment, each service runs multiple identical service copies at the same time, where each service copy is an instance, an instance may also be called a service instance, and a service formed by multiple instances (service copies) exposes to the outside a unique identifier that is convenient to call and identify, and this identifier is a service name of the service. When calling, only the address information (address information is the site of the instance) of a certain instance is known and accessed, so that the call to the service can be realized.
In some embodiments, as services are often adjusted and changed, the address information corresponding to the instance is also changed. If the initial service call request initiated by the target application carries wrong address information, the call fails or a wrong call result is obtained. If the initial service call request can be intercepted and the error address information modified before the error address information is accessed, service discovery and service call can be completed without perception of a user.
In some embodiments, after receiving the initial service invocation request initiated by the target application, the method further comprises:
S1: detecting whether the initial address information meets preset requirements;
s2: and under the condition that the initial address information does not meet the preset requirement, extracting the service name from the initial address information.
In some embodiments, if the initial address information does not meet the preset requirement, it is indicated that the initial address information is erroneous, and therefore, it is necessary to intercept the initial service call request and further modify the initial address information to change to the correct address information.
In some embodiments, the initial service invocation request is returned to the target application if it is determined that the initial address information meets a preset requirement. If the initial address information meets the preset requirement, the initial address information is correct, the initial service call request can be directly returned to the target application without intercepting the initial service call request, and the target application accesses the service resource (the service resource is a service copy) pointed by the initial address information, so that the service call of the time is completed.
In some embodiments, the detecting whether the initial address information meets a preset requirement specifically includes:
s1: detecting whether the initial address information comprises IP information and port information;
S2: and under the condition that the initial address information comprises IP information and port information, determining that the initial address information meets the preset requirement.
In some embodiments, detecting whether the initial address information meets a preset requirement further includes: and under the condition that the initial address information does not comprise IP information and port information, determining that the initial address information does not meet the preset requirement.
In some embodiments, the initial address information has two forms, the first form is composed of protocol type, IP information and port information, for example, the initial address information is http://10.0.0.1:8080/hello, wherein http is the protocol type, 10.0.0.1 is the IP information and 8080 is the port information. The second form consists of a protocol type, a service name, e.g. http:// service-a/hello, where http is the protocol type and service-a is the service name. If the initial address information includes IP information and port information, it indicates that the initial address information is correct and can be accessed directly. If the IP information and the port information are not included in the initial address information but the service name is included, it is interpreted that the initial address information is erroneous.
S102: and extracting a service name from the initial address information.
In some embodiments, if the initial address information does not include IP information and port information, but includes a service name, indicating that the initial address information is erroneous, the service name may be extracted from the initial address information, where the service name is the service name of the service that the target application wants to call, e.g., the service name may be in the form of service-a, service-b, etc.
S103: and inquiring whether an instance matched with the service name exists in the local cache of the client.
In some embodiments, some instances are stored in the local cache of the client, and first, whether there are instances matching the service name is queried in the local cache; if not, an instance matching the service name needs to be obtained from the registry.
In some embodiments, each instance carries an instance identity, which represents the service name of the instance; by comparing whether the instance identification is consistent with the service name, the instance matched with the service name can be screened out.
S104: under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance and the service name are matched.
In some embodiments, the registry is a ligament in the micro-service architecture that records the mapping of services and service address information. In the distributed architecture, the service instance registers own service information to a registry, and when a user and a target application need to call the service, the service instance finds the address of the service to the registry and calls the service. The process of obtaining information of service instances registered therein through a registry and requesting services provided by them through the information is service discovery.
In some embodiments, each time an instance is modified, the latest address information is sent to the registry, which updates the instance by overwriting the original address information with the latest address information. The registry is thus used to store the full, up-to-date instance information.
In some embodiments, the registry stores address information for the service instance as well as other registration information in a registry database.
In some embodiments, obtaining a target instance sent by a registry specifically includes:
s1: sending a query request to a registry; wherein the query request carries the service name; the registry is used for inquiring in a registry database to obtain a plurality of first instances matched with the service names, and sending the plurality of first instances to the proxy module;
S2: receiving the first instances sent by the registry;
s3: and screening the plurality of first examples to obtain target examples.
In some embodiments, the screening to obtain the target instance from the plurality of first instances specifically includes: and selecting target examples from the plurality of first examples by adopting a polling selection or random selection mode. The polling selection refers to pre-sorting a plurality of first examples, then sequentially judging whether the first examples are in an online state or not from the first examples, and taking the first examples as target examples if the first examples are in the online state, wherein the polling selection is finished.
In some embodiments, the target instance may also be selected by means of an average response delay weighting, or the like. The default selection mode is random selection in general, and the user can manually designate the selection mode.
In some embodiments, after the target instance is screened out, it may also be detected whether the target instance is online, and if not, it is discarded, and a new target instance is selected again.
In some embodiments, after receiving the plurality of first instances sent by the registry, the method further comprises: the plurality of first instances are stored in the local cache. Based on the above manner, when the service call request of the next time carries the same service name, the service name can be directly obtained from the local cache without requesting the registry again, so that the time for obtaining the instance can be reduced, and the access speed can be increased.
In some embodiments, the method further comprises:
s1: under the condition that the fact that the instance matched with the service name exists in the local cache is determined, screening to obtain a target instance from the instance matched with the service name in the local cache; wherein the target instance includes target address information;
s2: replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request;
s3: sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
In some embodiments, a polling selection or random selection manner may also be used to screen out the target instance from the local cache and the instances matched with the service names. At this time, the query request is not required to be sent to the registry, and the service call can be completed by accessing the service resource pointed by the target address information.
S105: and replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request.
In some embodiments, the agent module is constructed using java agent technology. The Java agent can also be called as a Java agent, and is a technology capable of dynamically modifying Java byte codes (byte code enhancement), the byte codes formed after compiling the Java class are executed by a JVM (Java virtual machine), the Java agent can intercept a class file before loading the class file when a program runs, and the class file is enhanced, so that the byte codes are modified, and finally, the non-invasive service discovery flow is realized.
In some embodiments, the java agent technology is widely applied to the field of monitoring probes, a monitoring function is added before and after a monitored method, a monitoring server is arranged, data generated when the method context is executed is collected, time consumption and internal calling conditions of the method are fed back to the monitoring server for processing, and dynamic modification can be performed on loaded java classes when the application is started on the premise that an application deployment package is not modified.
In some embodiments, referring to fig. 2, fig. 2 illustrates a class loading process after using a java Agent, first, in a JVM environment, extracting a class a file from an application deployment package, using the java Agent to enhance (Agent) the class a, i.e., modify the class a, to obtain an enhanced class a file, then using an application class loader to load the enhanced class a file, and finally executing the enhanced class a file. This process does not require modification of the code in the application deployment package and therefore has low development difficulty. By means of the non-invasive enhancement capability provided by the java agent, the method and the device can dynamically modify address information in the target application before the target application executes a service call request, automatically supplement a service discovery function, and enable the application to have no perception in the whole process.
In some embodiments, referring to fig. 3, after a common java application service accesses a java agent technology, an original code intrusion method that introduces an open source component into a source code is changed into a code non-intrusion method that is enhanced by a byte code, and new functional characteristics can be added for user business logic, a service registration component and a service discovery component, so that development is focused on realization of business functions, development difficulty is reduced, and project propulsion efficiency is improved.
S106: sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
In some embodiments, the method further comprises:
s1: sending an update instance request to the registry at regular time; the registry is used for returning an update instance to the proxy module after receiving the update instance request;
s2: receiving an updated instance returned by the registry;
s3: storing the updated instance in the local cache.
In some embodiments, a timing task may be provided in the proxy module, which is used to send update instance requests to the registry at regular intervals (e.g., every 30 seconds); after receiving the request for updating the instances, the registry returns the latest full-quantity of instances (i.e. updated instances) to the proxy module, and the proxy module puts the updated instances in the local cache so as to improve the query speed in the next query.
In some embodiments, if the total number of instances in the registry is large, the one-time return may cause blocking, and at this time, an instance name of an instance which has a higher importance and is wanted to be updated in time may be added in the update instance request in a subscription-on-demand manner, and the corresponding instance is returned according to the instance name in the update instance request.
In some embodiments, the method further comprises: according to the internal structural logic of the SDK of the main stream HTTP client, analyzing a core method link which is requested to be called so as to formulate a reasonable byte code instrumentation rule; the byte code instrumentation rule is used for detecting whether the initial address information meets the preset requirement.
In some embodiments, the client may further deploy an adaptation module, where the adaptation module is configured to add a protocol implementation of the service discovery interface of the mainstream registry, so as to reduce the introduction of third party dependencies. The matched registries comprise Eureka and Nacos, the registries have open HTTP protocol interface specifications, and the proxy module uses a java system class library to complete the call and request analysis functions related to service discovery. For other kinds of registries, the adaptation module provides a plug-in, and can import other registry client dependencies (such as a Zookeeper or Consul client SDK) to complete compatible adaptation. And the registry client introduced in the proxy module depends on the scope of the proxy module only, and related class resources and applications are mutually isolated, so that the quality risk of the running applications is not brought.
By the method, an open source component is not required to be introduced, the agent module based on the java agent technology provides imperceptible service discovery capability during application running, and compatible adaptation of a mainstream HTTP client and a registry is realized. The compatible HT TP client has Spring, feign, apacheHttpClient, the registration center of direct adaptation has Eureka and Nacos, the registration center of adaptation can be completed through the adaptation module has Zookeeper, consul, and the like, so that the application does not need to modify codes or add dependencies, recompilation and packaging are not needed, the use threshold is greatly reduced, the use flexibility is higher, and the cost of research, development and test is reduced.
In a specific scenario example, referring to fig. 4, a request call flow without a java AGENT (AGENT for short) includes: the HTTP client SDK (software development kit) initiates a call flow, generates Request information (the Request information refers to a Request object, the Request object is used for accessing all information transferred based on the HTTP Request) according to the call flow, completes network call access according to the Request information to obtain and analyze Response information (the Response information is used for responding to the client), and returns a call result.
In a specific scenario, referring to fig. 4, the AGENT enhanced request call flow includes:
step 1: the HTTP client SDK initiates a call flow, generates an initial call request and sends the initial call request to the proxy module; common mainstream SDKs include Spring, feign, apacheHttpClient and the like;
step 2: the agent module judges whether the method front interception is needed or not, and the judging mode is as follows: if the initial address information in the initial call request comprises the IP information and the port information, the method pre-interception is not needed, and if the initial address information in the initial call request does not comprise the IP information and the port information, the method pre-interception is needed, and the step 3 is formulated at the moment;
step 3: intercepting an initial call request, and analyzing the initial call request to obtain a service name; for example, the initial address information is http:// service-a/hello, and the service name is service-a;
step 4: detecting whether an instance cache matched with a service name exists in a local cache; inquiring the registry to obtain a first instance if the first instance does not exist, and jumping to the step 5; jumping to step 6 if present; timing tasks may also be created for periodically updating instances in the local cache;
Step 5: selecting a target instance from the first instance by adopting a polling selection or random selection mode through a load equalizer; extracting a target instance address of a target instance; for example, the target example address is http://10.0.0.1:8080/hello;
step 6: selecting a target instance from the instance cache by adopting a polling selection or random selection mode through a load equalizer; extracting a target instance address of a target instance; for example, the target example address is http://10.0.0.1:8080/hello;
step 7: replacing initial address information (request address) in the initial call request with a target instance address; that is, http:// service-a/hello is replaced by http://10.0.0.1:8080/hello;
step 8: accessing the service resource pointed by the target instance address, completing network call, and obtaining Response information;
step 9: analyzing Response information to obtain a calling result; and calculates the time consumption of the network call co-generation, and adjusts the selection method (i.e. the load balancing algorithm) in the step 5 or 6 according to the time consumption.
Although the application provides method operational steps as described in the examples or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps recited in the embodiments is merely one way of performing the order of steps and does not represent a unique order of execution. When implemented by an apparatus or client product in practice, the methods illustrated in the embodiments or figures may be performed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even in a distributed data processing environment). The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, it is not excluded that additional identical or equivalent elements may be present in a process, method, article, or apparatus that comprises a described element. The terms first, second, etc. are used to denote a name, but not any particular order.
Based on the service calling method, one or more embodiments of the present application further provide a service calling device. The described devices may include systems (including distributed systems), software (applications), modules, components, servers, clients, etc. that employ the methods of embodiments of the present application in conjunction with the necessary devices to implement the hardware. Based on the same innovative concepts, embodiments of the present application provide for devices in one or more embodiments as described in the following examples. Because the implementation scheme and the method for solving the problem by the device are similar, the implementation of the device in the embodiment of the application can refer to the implementation of the method, and the repetition is omitted. As used below, the term "unit" or "module" may be a combination of software and/or hardware that implements the intended function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
Specifically, fig. 5 is a schematic block diagram of an embodiment of a service invocation device according to the present application, and referring to fig. 5, the service invocation device according to the present application may include: a receiving module 501, an extracting module 502, a querying module 503, an obtaining module 504, a replacing module 505 and a sending module 506.
A receiving module 501, configured to receive an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client;
an extracting module 502, configured to extract a service name from the initial address information;
a query module 503, configured to query a local cache of the client for whether there is an instance that matches the service name;
an obtaining module 504, configured to obtain, when it is determined that there is no instance matching the service name in the local cache, a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name;
a replacing module 505, configured to replace the initial address information in the initial service call request with the target address information, to obtain a target service call request;
a sending module 506, configured to send the target service invocation request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
In some embodiments, when the service calling device is specifically implemented, the service calling device may be further configured to detect, after receiving an initial service call request initiated by a target application, whether the initial address information meets a preset requirement; under the condition that the initial address information is determined not to meet the preset requirement, extracting a service name from the initial address information; and returning the initial service call request to the target application under the condition that the initial address information meets the preset requirement.
In some embodiments, the obtaining module 504 is specifically configured to send a query request to a registry; wherein the query request carries the service name; the registry is used for inquiring in a registry database to obtain a plurality of first instances matched with the service names, and sending the plurality of first instances to the proxy module; receiving the first instances sent by the registry; and screening the plurality of first examples to obtain target examples.
In some embodiments, when the service calling device is specifically implemented, the service calling device may be further configured to, in a case where it is determined that an instance matching the service name exists in the local cache, screen to obtain a target instance from the local cache and the instance matching the service name; wherein the target instance includes target address information; replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request; sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
In some embodiments, the service invocation device may be further configured to send an update instance request to the registry at regular time when the service invocation device is implemented; the registry is used for returning an update instance to the proxy module after receiving the update instance request; receiving an updated instance returned by the registry; storing the updated instance in the local cache.
It should be noted that the description of the above apparatus according to the method embodiment may further include other embodiments, and specific implementation manner may refer to the description of the related method embodiment, which is not described herein in detail.
The application also provides a client, which comprises at least one processor and a memory for storing instructions executable by the processor, wherein the processor can realize any method embodiment when executing the instructions. For example, an implementation of the instructions when executed by the processor includes the steps of: receiving an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client; extracting a service name from the initial address information; inquiring whether an instance matched with the service name exists in a local cache of the client; under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name; replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request; sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
It should be noted that the description of the embodiments of the method or apparatus for a client may also include other implementations. Specific implementation may refer to descriptions of related method embodiments, which are not described herein in detail.
Specifically, fig. 6 is a block diagram of a hardware structure of an embodiment of a client provided in the present application. As shown in fig. 6, the client 10 may include one or more (only one is shown in the figure) processors 100 (the processors 100 may include, but are not limited to, a microprocessor MCU or a processing device such as a programmable logic device FPGA), a memory 200 for storing data, and a transmission module 300 for communication functions. It will be appreciated by those of ordinary skill in the art that the configuration shown in fig. 6 is merely illustrative and is not intended to limit the configuration of the electronic device described above. For example, client 10 may also include more or fewer components than shown in FIG. 6, for example, may also include other processing hardware such as a database or multi-level cache, a GPU, or have a different configuration than that shown in FIG. 6.
The memory 200 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the service invocation method in the embodiment of the present application, and the processor 100 executes the software programs and modules stored in the memory 200, thereby performing various functional applications and data processing. Memory 200 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
In some examples, memory 200 may further include memory located remotely from processor 100, which may be connected to the computer terminal via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission module 300 is used to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission module 300 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission module 300 may be a Radio Frequency (RF) module for communicating with the internet wirelessly.
The present application also provides a computer readable storage medium storing computer program instructions that, when executed, implement: receiving an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client; extracting a service name from the initial address information; inquiring whether an instance matched with the service name exists in a local cache of the client; under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name; replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request; sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
The application also provides a computer program product comprising a computer program which, when executed by a processor, realizes: receiving an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client; extracting a service name from the initial address information; inquiring whether an instance matched with the service name exists in a local cache of the client; under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name; replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request; sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
The foregoing describes certain embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The method or the device according to the above embodiment of the present application may implement service logic through a computer program and record the service logic on a storage medium, where the storage medium may be read and executed by a computer, so as to implement the effects of the solution described in the embodiment of the present application. The storage medium may include physical means for storing information, typically by digitizing the information before storing it in an electronic, magnetic, or optical medium. The storage medium may include: means for storing information using electrical energy such as various memories, e.g., RAM, ROM, etc.; devices for storing information using magnetic energy such as hard disk, floppy disk, magnetic tape, magnetic core memory, bubble memory, and USB flash disk; devices for optically storing information, such as CDs or DVDs. Of course, there are other ways of readable storage medium, such as quantum memory, graphene memory, etc.
The embodiment of the data processing method or the device provided by the application can be realized by executing corresponding program instructions by a processor in a computer, such as a c++ language of a windows operating system is used for realizing at a PC end, a linux system is used for realizing, or other program design languages such as android and iOS systems are used for realizing at an intelligent terminal, and a processing logic based on a quantum computer is used for realizing.
It should be noted that the descriptions of the apparatus and the device according to the related method embodiments described in the specification may further include other embodiments, and specific implementation manners may refer to descriptions of corresponding method embodiments, which are not described in detail herein.
The embodiments of the present application are described in a progressive manner, and the same and similar parts of the embodiments are all referred to each other, and each embodiment is mainly described in the differences from the other embodiments. In particular, for a hardware+program class embodiment, the description is relatively simple, as it is substantially similar to the method embodiment, as relevant see the partial description of the method embodiment.
For convenience of description, the above devices are described as being functionally divided into various modules, respectively. Of course, when implementing one or more of the present application, the functions of some modules may be implemented in the same piece or pieces of software and/or hardware, or a module that implements the same function may be implemented by a plurality of sub-modules or a combination of sub-units, or the like.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus, devices, and/or apparatus according to embodiments of the application. It will be appreciated that these computer program instructions may be implemented by a computer program instruction which may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
One skilled in the relevant art will recognize that one or more embodiments of the application may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects.
Although the present application has been described by way of examples, one of ordinary skill in the art appreciates that there are many variations and modifications that do not depart from the spirit of the application, and it is intended that the appended claims encompass such variations and modifications as fall within the spirit of the application.

Claims (14)

1. A service invocation method, wherein the method is applied to a proxy module, the proxy module being deployed at a client, the method comprising:
receiving an initial service call request initiated by a target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client;
extracting a service name from the initial address information;
inquiring whether an instance matched with the service name exists in a local cache of the client;
under the condition that the fact that the instance matched with the service name does not exist in the local cache is determined, acquiring a target instance sent by a registry; wherein the target instance includes target address information; the target instance is matched with the service name;
replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request;
Sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
2. The method of claim 1, wherein after receiving the initial service invocation request initiated by the target application, the method further comprises:
detecting whether the initial address information meets preset requirements;
and under the condition that the initial address information does not meet the preset requirement, extracting the service name from the initial address information.
3. The method according to claim 2, wherein the method further comprises:
and returning the initial service call request to the target application under the condition that the initial address information meets the preset requirement.
4. The method of claim 2, wherein detecting whether the initial address information meets a preset requirement comprises:
detecting whether the initial address information comprises IP information and port information;
and under the condition that the initial address information comprises IP information and port information, determining that the initial address information meets the preset requirement.
5. The method according to claim 4, wherein the method further comprises:
and under the condition that the initial address information does not comprise IP information and port information, determining that the initial address information does not meet the preset requirement.
6. The method of claim 1, wherein obtaining the target instance sent by the registry comprises:
sending a query request to a registry; wherein the query request carries the service name; the registry is used for inquiring in a registry database to obtain a plurality of first instances matched with the service names, and sending the plurality of first instances to the proxy module;
receiving the first instances sent by the registry;
and screening the plurality of first examples to obtain target examples.
7. The method of claim 6, wherein screening the target instance from the plurality of first instances comprises:
and selecting target examples from the plurality of first examples by adopting a polling selection or random selection mode.
8. The method of claim 6, wherein the method further comprises:
the plurality of first instances are stored in the local cache.
9. The method according to claim 1, wherein the method further comprises:
under the condition that the fact that the instance matched with the service name exists in the local cache is determined, screening to obtain a target instance from the instance matched with the service name in the local cache; wherein the target instance includes target address information;
replacing the initial address information in the initial service call request by using the target address information to obtain a target service call request;
sending the target service call request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
10. The method according to claim 1, wherein the method further comprises:
sending an update instance request to the registry at regular time; the registry is used for returning an update instance to the proxy module after receiving the update instance request;
receiving an updated instance returned by the registry;
storing the updated instance in the local cache.
11. A service invocation apparatus, the apparatus being applied to a proxy module, the proxy module being deployed at a client, the apparatus comprising:
The receiving module is used for receiving an initial service call request initiated by the target application; wherein, the initial service call request carries initial address information; the target application is deployed at the client;
the extraction module is used for extracting a service name from the initial address information;
the query module is used for querying whether an instance matched with the service name exists in the local cache of the client;
the acquisition module is used for acquiring a target instance sent by a registry under the condition that the instance matched with the service name does not exist in the local cache; wherein the target instance includes target address information; the target instance is matched with the service name;
the replacing module is used for replacing the initial address information in the initial service call request by utilizing the target address information to obtain a target service call request;
the sending module is used for sending the target service calling request to the target application; the target application is used for accessing the service resource pointed by the target address information according to the target service call request so as to complete service call.
12. A client comprising at least one processor and a memory storing computer executable instructions which when executed by the processor implement the steps of the method of any one of claims 1 to 10.
13. A computer readable storage medium, having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of any of claims 1 to 10.
14. A computer program product, characterized in that it comprises a computer program which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 10.
CN202310706275.6A 2023-06-14 2023-06-14 A service calling method, device and client Pending CN116800848A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310706275.6A CN116800848A (en) 2023-06-14 2023-06-14 A service calling method, device and client

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310706275.6A CN116800848A (en) 2023-06-14 2023-06-14 A service calling method, device and client

Publications (1)

Publication Number Publication Date
CN116800848A true CN116800848A (en) 2023-09-22

Family

ID=88035527

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310706275.6A Pending CN116800848A (en) 2023-06-14 2023-06-14 A service calling method, device and client

Country Status (1)

Country Link
CN (1) CN116800848A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118797964A (en) * 2024-09-12 2024-10-18 杭州长川科技股份有限公司 Virtual simulation method, device, computer equipment and program product

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108234666A (en) * 2018-01-16 2018-06-29 云宏信息科技股份有限公司 A kind of micro services calling system, method and computer storage media
CN110266517A (en) * 2019-05-21 2019-09-20 深圳壹账通智能科技有限公司 External service call method, device and terminal device based on gateway
CN112114979A (en) * 2020-08-31 2020-12-22 厦门安胜网络科技有限公司 Remote procedure call method and device
CN112311786A (en) * 2020-10-28 2021-02-02 北京健康之家科技有限公司 Service request processing method and device, storage medium and computing equipment
CN114726863A (en) * 2022-04-27 2022-07-08 阿里云计算有限公司 Method, device, system and storage medium for load balancing
US20220377146A1 (en) * 2021-05-24 2022-11-24 Bank Of America Corporation Apparatus and methods for dynamic scaling and orchestration
CN115550428A (en) * 2022-09-19 2022-12-30 中国银行股份有限公司 Business processing method, client, server and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108234666A (en) * 2018-01-16 2018-06-29 云宏信息科技股份有限公司 A kind of micro services calling system, method and computer storage media
CN110266517A (en) * 2019-05-21 2019-09-20 深圳壹账通智能科技有限公司 External service call method, device and terminal device based on gateway
CN112114979A (en) * 2020-08-31 2020-12-22 厦门安胜网络科技有限公司 Remote procedure call method and device
CN112311786A (en) * 2020-10-28 2021-02-02 北京健康之家科技有限公司 Service request processing method and device, storage medium and computing equipment
US20220377146A1 (en) * 2021-05-24 2022-11-24 Bank Of America Corporation Apparatus and methods for dynamic scaling and orchestration
CN114726863A (en) * 2022-04-27 2022-07-08 阿里云计算有限公司 Method, device, system and storage medium for load balancing
CN115550428A (en) * 2022-09-19 2022-12-30 中国银行股份有限公司 Business processing method, client, server and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118797964A (en) * 2024-09-12 2024-10-18 杭州长川科技股份有限公司 Virtual simulation method, device, computer equipment and program product

Similar Documents

Publication Publication Date Title
US11714675B2 (en) Virtualization-based transaction handling in an on-demand network code execution system
CN112424746B (en) In-situ triggered functions as a service within a service mesh
CN105389191B (en) A kind of method for upgrading software based on LAN, device and system
CN112118565A (en) Multi-tenant service grayscale publishing method, apparatus, computer equipment and storage medium
CN108306917A (en) The register method and device of data processing method and device, micro services module
JP2018536935A (en) Access request conversion method and apparatus
CN114448895B (en) Application access method, device, equipment and medium
CN105512044A (en) Method and system for updating object base used for keyword drive test
CN110677475A (en) Micro-service processing method, device, equipment and storage medium
US20240007537A1 (en) System and method for a web scraping tool
CN113434796B (en) Page cache operation method and device, storage medium and electronic device
CN116204239A (en) Service processing method, device and computer readable storage medium
CN116800848A (en) A service calling method, device and client
US10771579B2 (en) Redirection of data flows from an end device
CN108647139B (en) System test method, device, storage medium and electronic device
CN113014626B (en) Data service management method and device, storage medium and electronic device
CN115378993A (en) Method and system for service registration and discovery supporting namespace awareness
US12255791B2 (en) Method and device for processing a network service instantiation request
CN114584629B (en) Transaction message processing method and device
CN106685708A (en) Determining method, device and system of service relationship
CN106936643B (en) Equipment linkage method and terminal equipment
CN111782291B (en) Method and device for starting test page
CN113626295B (en) Method and system for processing pressure measurement data and computer readable storage medium
Song et al. PMDC: Programmable mobile device clouds for convenient and efficient service provisioning
EP3174245A1 (en) Method for discovering topology network, network device 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