CN116880970A - Application function calling method and device, terminal equipment and storage medium - Google Patents

Application function calling method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN116880970A
CN116880970A CN202310706980.6A CN202310706980A CN116880970A CN 116880970 A CN116880970 A CN 116880970A CN 202310706980 A CN202310706980 A CN 202310706980A CN 116880970 A CN116880970 A CN 116880970A
Authority
CN
China
Prior art keywords
function
calling
address
service node
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
Application number
CN202310706980.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.)
Shenzhen Paikrypton Technology Co ltd
Original Assignee
Shenzhen Paikrypton Technology 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 Shenzhen Paikrypton Technology Co ltd filed Critical Shenzhen Paikrypton Technology Co ltd
Priority to CN202310706980.6A priority Critical patent/CN116880970A/en
Publication of CN116880970A publication Critical patent/CN116880970A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system

Abstract

The embodiment of the application is suitable for the technical field of software, and provides a calling method, a device, terminal equipment and a storage medium of an application function, wherein the method comprises the following steps: responding to a function call request initiated by any call function in a target application, and determining a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; generating a call request based on the request type corresponding to the target address and the request parameters in the function call request; sending the call request to a service node corresponding to the target address according to the target address; and receiving response data returned by the service node based on the calling request, and calling the target application to respond to an operation instruction corresponding to the calling function by using the response data. The method provided by the embodiment enables the public components or public databases of the target application to be deployed on the independent service nodes, and simplifies the operation and maintenance costs of the calling relationship of the developer to the target application.

Description

Application function calling method and device, terminal equipment and storage medium
Technical Field
The embodiment of the application belongs to the technical field of software, and particularly relates to a calling method and device of an application function, terminal equipment and a storage medium.
Background
In the software field, in order to reduce the space occupied by an application on an electronic device, developers often store common components common to the application on a server side, and in order to better manage user data, developers often store user data in a special common database. When an application program executes an application function, and the application function needs to be implemented through a public component or user data, the application program needs to call the public component of the server side or call a public database to acquire the user data. In the related art, an application program often calls a common component or a common database in two ways.
The first mode is that calling is realized through calling codes in an application program; however, in this way, the calling implementation is bound to the calling code in the application program, so that after the common component or the common database is updated, the calling code in the application program must be synchronously updated to ensure the calling function of the application program, and the maintenance cost of the calling code is relatively high.
And in a second mode, each public component or public database is distributed to different micro servers, and when an application program needs to call the public component or the public database, the application program communicates with the corresponding micro server through a specific API interface to call the public component or the public database on the micro server. However, since the functions of the application program are realized by the micro-service framework formed by the plurality of micro-servers in this way, when the developer updates the micro-service framework, all the micro-servers need to be updated at the same time, and the operation and maintenance costs are high.
In summary, the calling method of the existing public component or public database has high operation and maintenance costs.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, an apparatus, a terminal device, and a storage medium for calling an application function, so as to reduce the operation and maintenance costs of a call relationship of a developer to a target application.
A first aspect of an embodiment of the present application provides a method for calling an application function, including:
responding to a function call request initiated by any call function in a target application, and determining a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; the target address is the address of a service node for providing the data call service corresponding to the function call request; the calling function is an application function realized by calling a service node in the target application;
Generating a call request based on the request type corresponding to the target address and the request parameters in the function call request;
sending the call request to a service node corresponding to the target address according to the target address;
and receiving response data returned by the service node based on the calling request, and calling the target application to respond to an operation instruction corresponding to the calling function by using the response data.
A second aspect of an embodiment of the present application provides an application function calling device, including:
the determining module is used for responding to a function call request initiated by any call function in the target application, and determining a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; the target address is the address of a service node for providing the data call service corresponding to the function call request; the calling function is an application function realized by calling a service node in the target application;
the request generation module is used for generating a call request based on the request type corresponding to the target address and the request parameters in the function request;
the sending module is used for sending the calling request to the service node corresponding to the target address according to the target address;
And the response module is used for receiving response data returned by the service node based on the calling request and calling the target application to respond to the operation instruction corresponding to the calling function by using the response data.
A third aspect of an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements a method for calling an application function as described in the first aspect when the processor executes the computer program.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements a method for calling an application function as described in the first aspect above.
A fifth aspect of an embodiment of the present application provides a computer program product, which when run on a computer causes the computer to perform the method for invoking an application function according to the first aspect above.
Compared with the prior art, the embodiment of the application has the following advantages:
according to the embodiment of the application, the electronic equipment can respond to the function call request initiated by any call function in the target application, and the target address corresponding to the function call request is determined from the preset address list; the electronic equipment can also determine the request type corresponding to the target address through the address list; the target address determined by the adapter module is used for determining the address of any service node of the function call request providing the data call service; the calling function on the target application can be an application function which is required to be realized by calling the service node on the target application; after the adapter module on the electronic equipment determines the target address, a call request can be generated according to the request type corresponding to the target address and the request parameters in the function call request; after the electronic equipment generates a call request, the call request can be sent to a service node corresponding to the target address through the adapter module according to the target address corresponding to the function call request, so that a data call service provided by the service node is obtained; after the electronic equipment sends the call request, response data returned by the service node based on the call request can be received through the adapter module; then, the electronic device can call the target application to respond to the operation instruction corresponding to the call function by using the received response data so as to complete the call function on the target application. Through the method provided by the embodiment, when the user needs to use the calling function on the target application, the electronic device can generate a corresponding calling request through the adapter module and send the calling request to the corresponding service node so as to call the data on the service node to execute the calling function. Therefore, by the method provided by the embodiment, since the target application can acquire the data call service provided by the service node through the call request, a developer can deploy the public component or the public database in any service node independent of the target application, and decoupling between the public component or the public database and the target application is realized, so that the developer can independently operate and maintain the target application or the service node, and therefore, management work of various call relations of the developer on the target application can be greatly reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings that are required to be used in the embodiments or the description of the prior art. It is evident that the drawings in the following description are only some embodiments of the present application and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a schematic diagram of a method for calling an application function according to a first embodiment of the present application;
FIG. 2 is a schematic diagram of a relationship between a target application call service node according to an embodiment of the present application;
fig. 3 is a flowchart of a specific implementation of a method S101 for calling an application function according to a second embodiment of the present application;
fig. 4 is a flowchart of a specific implementation of a calling method S103 of an application function according to a third embodiment of the present application;
fig. 5 is a flowchart of a specific implementation of a calling method S101 of an application function according to a fourth embodiment of the present application;
fig. 6 is a flowchart of a specific implementation of a calling method S104 of an application function according to a fifth embodiment of the present application;
fig. 7 is a flowchart of a specific implementation of a calling method S104 of an application function according to a sixth embodiment of the present application;
FIG. 8 is a flowchart of another implementation of a method for calling an application function according to a seventh embodiment of the present application;
FIG. 9 is a schematic diagram of an application function calling device according to an embodiment of the present application;
FIG. 10 is a schematic diagram of an application function calling device according to an embodiment of the present application;
fig. 11 is a schematic diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
The technical scheme of the application is described below through specific examples.
Embodiment one:
referring to fig. 1, a schematic diagram of a method for calling an application function according to an embodiment of the present application is shown, where the method for calling may be applied to an electronic device with a target application installed, where the electronic device may be an electronic device with a target application installed, such as a notebook computer, a tablet computer, or a smart phone. The method for calling the application function specifically comprises the following steps:
S101, responding to a function call request initiated by any call function in a target application, and determining a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; the target address is the address of a service node for providing the data calling service corresponding to the function request; and the calling function is an application function realized by calling a service node in the target application.
In this embodiment, when a user needs to use a certain application function on the target application, in response to an operation instruction initiated by the user, the electronic device may operate the target application, and display an application interface of the target application in the display module. The user may use the individual application functions on the target application by clicking on the functionality controls on the application interface. In response to a click operation of a certain function control by a user, the target application can firstly judge whether an application function which the user needs to use is a calling function on the target application. The calling function is an application function which needs to call a service node on a target application and can complete response by combining the service node feedback response data. If the target device determines that the application function currently required to be used by the user is a calling function, the target device can initiate a function calling request to an adapter module on the target application through a calling function module of the calling function.
In one possible implementation manner, if the target application determines that the application function currently used by the user is not a calling function, the target application may directly call a function module corresponding to the application function to respond to an operation instruction corresponding to the application function.
After receiving the function call request, the adapter module on the electronic device responds to the function call request initiated by the call function, and can determine a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list. The address list stores addresses of a plurality of service nodes, each service node in the address list is a node capable of providing data calling service corresponding to various function calling requests, and the addresses of each service node can be represented by an IP address or a port.
In one possible implementation manner, the function call request initiated by the call function may include a call tag corresponding to the data call service to be called, where the call tag may include a service name of the data call service to be used by the call function. The adapter module can determine a service node which can provide the data call service corresponding to the call label from the address list according to the service name in the call label, and takes the address corresponding to the service node as a target address. It should be noted that, in this embodiment, the same service node may provide multiple different data call services, and the same data call service may also be provided by multiple different service nodes, where each service node may exist in the same node cluster with a server of a target application, and each service node may also exist in a different node cluster with a server of a target application. The same data calling service is provided by a plurality of different service nodes, so that the condition of single-point faults can be effectively avoided, and the stable operation of the system is guaranteed. And different data calling services are deployed on one service node, so that the resources of each service node can be maximized, and the system cost can be reduced.
In one possible implementation, the target application may be deployed on a different electronic device than the adapter module. The target application may be installed on the user device, and the adapter module corresponding to the target application may also be deployed on a server of the target application. When a calling function on a target application needs to call data on a service node, the target application can send a function calling request to a server through user equipment. When the developer deploys the adapter module on the server, because the adapter module exists independently of the user equipment, when the developer needs to perform operation maintenance on the adapter module, the operation maintenance can be performed only on the adapter module on the server, and the operation maintenance cost can be further reduced. The adapter module may also be deployed on the user device with the target application as a module in the target application. When the adapter module is deployed on the user equipment together with the target application, the target application can directly call the adapter module on the user equipment, so that the running efficiency of the system can be accelerated.
In one possible implementation, the adapter module may also be used to generate call requests for a variety of different target applications when the adapter module is deployed on a server. In this case, the function call request sent by the target application to the server through the user equipment may include an application tag corresponding to the target application. After receiving the function call request, the adapter may determine, according to the application tag, a target application that sends the function call request. The adapter module can determine a target address list corresponding to the target application from a plurality of stored different address lists according to the application label, and generate a call request for the target application according to the target address list.
In one possible implementation, if there are multiple addresses in the address list that satisfy the data call service corresponding to the function call request, the adapter module may further determine the target address from the address list through its load balancing algorithm. The load balancing algorithm used by the adapter module may include, but is not limited to, a variety of load balancing algorithms including a polling algorithm, a weighted polling algorithm, a random algorithm, a source address hashing algorithm, and the like.
S102, generating a call request based on the request type corresponding to the target address and the request parameters in the function call request.
In this embodiment, after determining the target address and the request type corresponding to the function call request, the adapter module on the electronic device may generate the call request according to the request type corresponding to the target address and the request parameter in the function call request.
For example, when a user needs to use a historical order query function on a target application, the historical order query module on the target application may generate a function call request using query conditions entered by the user as request parameters and send the function call request to the adapter module. The request parameters may include various query conditions such as a time range of the query, an order type of the query, keywords of the query, and the like. The adapter module can generate a call request for the historical order data according to the request type and the request parameter corresponding to the service node where the database storing the historical order data is located.
For example, when a certain calling function in the target application needs to be encrypted by using an encryption function encryption () in the encryption library, the adapter module can encapsulate a request parameter in the calling function request into an encryption calling request according to a preset encryption request type corresponding to the encryption library through the encryption calling function encryption adapter () in the module.
In one possible implementation, the request type corresponding to the target address may be determined by the developer according to related information such as a programming language used by the target application, a programming language used on the service node, a calling method of data on the service node, and a data structure agreed between the target application and the service node, that is, when different service nodes are used by the same target address, the request type corresponding to the target address may be different. The destination address corresponding request type may also be different for different destination applications when using the same serving node. That is, the types of requests stored in the adapter modules corresponding to different target applications may be different, the adapter modules are in one-to-one correspondence with the target applications, and one target application may correspond to one adapter module. For example, if the program language used in the database storing the historical order data is a structured query language (i.e., SQL language), and the program language used in the target application is JAVA, the adapter may determine the request parameters in the function call request according to the JAVA language, and then generate the call request through the SQL language according to the preset data structure and the request parameters.
S103, sending the call request to the service node corresponding to the target address according to the target address.
In this embodiment, after generating the call request, the adapter module on the electronic device may send the call request to the service node corresponding to the target address according to the target address.
S104, receiving response data returned by the service node based on the calling request, and calling the target application to respond to an operation instruction corresponding to the calling function by using the response data.
In this embodiment, after the adapter module on the electronic device sends the call request to the service node, the response data returned by the service node based on the call request may be received. The adapter module can also call the target application so that the target application responds to the operation instruction corresponding to the calling function by using the response data.
Fig. 2 is a schematic diagram of a relationship between a target application call service node according to the present embodiment. Referring to fig. 2, a developer may deploy a public component or a public database with a low access amount on a server of a target application, so that the server of the target application also becomes a service node, and provides a data call service for the target application, so as to improve the resource utilization rate of the system. The developer can also deploy the public components or public databases with larger access quantity on the independent servers so as to ensure the normal operation of the service nodes. As shown in fig. 2, the first target application on the first server and the second target application on the second server may be different target applications. When the first target application needs to acquire the data stored in the second public database, the first target application can generate a first call request through an adapter module on the first server, and send the first call request to the second server according to the address of the second server. After receiving the first call request, the second server can query in the second public database according to the first call request, and return the query result to the first server in a first response data mode, so that the first target application can use the first response data to complete an operation instruction of a call function. Therefore, the target application on the electronic equipment through the adapter module can acquire the data calling service provided on the server, and can acquire the data calling service deployed on other servers.
In this embodiment, since the target application may generate different call requests for different service nodes through the adapter module, call the data call service provided by the service node by remotely sending the call request, and execute the corresponding application function according to the response data returned by the service node. Therefore, by the method provided by the embodiment, the public components or the public database can be deployed in the service node independent of the target application, and the calling through the preset calling program or the API interface is not needed, so that the management of various calling relations of the developer to the target application can be simplified. In addition, the method provided by the embodiment enables the target application and each service node to independently operate and maintain, so that the operation and maintenance cost of the system and the downtime of the target application can be reduced greatly.
Fig. 3 shows a flowchart of a specific implementation of an application function calling method S101 according to a second embodiment of the present application. Referring to fig. 3, compared to the embodiment shown in fig. 1, before S101, the method for calling an application function according to the present embodiment includes: s1011 to S1013, the details are as follows:
S1011, responding to the running instruction of the target application, generating address inquiry instructions about all calling functions in the target application.
In this embodiment, when the adapter module on the electronic device detects that the target application starts to run, in response to the running instruction of the target application, an address query instruction about all call functions in the target application may be generated.
In one possible implementation manner, if the adapter module is deployed on the user device together with the target application, after the user runs the target application by clicking a target application control on the user device, the adapter module in the target application may confirm a plurality of call functions in the target application according to type labels corresponding to each function module in the target application, and generate an address query instruction according to all call functions on the target application.
In one possible implementation, if the adapter module and the target application are disposed on different electronic devices, that is, the adapter module is disposed on the server and the target application is disposed on the user device, when the user operates the target application by clicking on a target application control on the user device, the target application may generate an operation instruction, and send the generated operation instruction to the server through the user device. The running instruction sent by the target application may include an application tag corresponding to the target application, and the adapter module on the server may query, on the system, a plurality of call functions included in the target application according to the application tag in the running instruction, and generate an address query instruction according to all call functions on the target application, so as to obtain an address of a service node that can provide a data call service for any call function on the target application.
S1012, sending the address inquiry instruction to a function management system to determine the address of the service node corresponding to each calling function; the function management system is used for managing a plurality of service nodes.
In this embodiment, after the adapter module on the electronic device generates the address query instruction, the address query instruction may be sent to the function management system to determine an address of a service node corresponding to the data call service that needs to be used by each call function. The function management system may include multiple kinds of node information, such as addresses corresponding to multiple service nodes, names of the service nodes, node states of the service nodes, and the like, which may provide data call services for the target application. A developer may manage a plurality of service nodes through a function management system.
In one possible implementation, the address query instruction sent by the adapter module to the function management system may include function labels corresponding to all calling functions on the target application. After receiving the address inquiry command, the function management system can inquire a plurality of service nodes which can provide corresponding data calling service according to all function labels contained in the address inquiry command. The function management system may generate an address list according to the queried node name of each service node, the request type corresponding to each service node, the address of each service node, and the node status of each service node, and send the address list to the adapter module that initiates the address query instruction.
S1013, receiving and storing the address list fed back by the function management system based on the address inquiry instruction.
In this embodiment, after the adapter module on the electronic device sends the address query instruction to the function management system, the address list fed back by the function management system based on the address query instruction may be received and stored. The adapter module can query a target address corresponding to the function call request in the stored address list after receiving the function call request initiated by the call function.
In one possible implementation manner, if the adapter module cannot query the target address corresponding to the function call request in the address list, the adapter module may regenerate the address query instruction according to the function tag included in the function call request, and send the newly generated address query instruction to the function management module to obtain the target address corresponding to the function call request.
In one possible implementation manner, during the running process of the target application, the adapter module may send an address query instruction to the function management system according to a preset time interval, so as to regularly acquire a new address list from the function management system, so as to ensure the validity of the address list stored by the adapter module.
In this embodiment, since the adapter module may respond to the running instruction of the target application, an address query instruction is generated at the time of starting the target application, and an address list is acquired from the function management system. The adapter module can thus quickly determine the target address from the address list after the calling function on the target application initiates the function call request. Therefore, the method provided by the embodiment can obviously improve the response speed of the system, quicken the running process of the system and improve good use experience for users.
Fig. 4 is a flowchart showing a specific implementation of an application function calling method S103 according to the third embodiment of the present application. Referring to fig. 4, compared to the embodiment described in fig. 1, in the method for calling an application function S103 provided in this embodiment, the method includes: s1031 to S1032 are specifically described as follows:
s1031, determining a target communication protocol corresponding to the target address.
In this embodiment, the address list stored in the electronic device may further include a target communication protocol corresponding to each target address. After receiving the function call request initiated by the call function, the adapter module can also determine a target communication protocol corresponding to the target address from the address list according to the function call request.
It should be noted that, the present embodiment is not limited to the target communication protocol, and any efficient, scalable, simple and secure communication protocol may be used in the practical application process, such as hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP), remote invocation protocol (Google Remote Procedure Call Protocol, GPRC), and the like. Among them, the remote invocation protocol (Google Remote Procedure Call Protocol, GPRC) is a preferred choice among many communication protocols due to its advantages of high performance and cross-language support.
S1032, establishing a communication link between the target application and the service node based on the target communication protocol; the communication link is for transmitting the call request and the response data.
In this embodiment, after determining the target communication protocol corresponding to the target address, the adapter module on the electronic device may establish a communication link between the target application and the service node corresponding to the target address based on the target communication protocol. The adapter module may send the generated invocation request to the service node over a communication link established by the target communication protocol. Meanwhile, the service node can also feed back response data generated based on the call request to the adapter module through a communication link established by the target communication protocol.
In this embodiment, the adapter module on the electronic device may further determine a target communication protocol corresponding to each target address in the address list, and establish a communication link between the target application and the service node according to the target communication protocol. By the method provided by the embodiment, the adapter can build the communication link in a customized way according to the conditions of the service node and the target application, thereby being beneficial to ensuring the stable operation of the system and improving the efficiency of data transmission between the service node and the target application.
Fig. 5 shows a flowchart of a specific implementation of an application function calling method S101 according to a fourth embodiment of the present application. Referring to fig. 5, compared to the embodiment described in fig. 1, in a method for calling an application function S101 provided in this embodiment, the method includes: s501 to S503 are specifically described below:
s501, determining a candidate address from the address list based on the function label in the function call request.
In this embodiment, the function call request initiated by the call function on the target application to the adapter module on the electronic device may further include a function tag corresponding to the call function. After receiving a function call request initiated by a call function, an adapter module on the electronic device can determine a function tag corresponding to the call function from the function call request, and determine a candidate address from an address list according to the function tag.
In one possible implementation manner, the address list may include node names corresponding to the service nodes, and each node name may have a service tag corresponding to a data calling service that the service node can provide. The adapter module can search all node names in the address list according to the function label in the function call request, and can determine the target address of the service node corresponding to the function call request according to the service label in each node name.
In one possible implementation manner, the address list may include a plurality of different type tables, and node information of each service node may be stored in a type table corresponding to a service type according to a service type corresponding to a data call service provided by the service node.
S502, if the number of the candidate addresses is greater than or equal to 2, generating a candidate list containing a plurality of candidate addresses based on the weighted values corresponding to the candidate addresses; and the weighting parameter is determined by the configuration performance of the service node corresponding to the candidate address.
In this embodiment, after the adapter module on the electronic device retrieves the candidate addresses from the address list according to the function tag, it may first determine whether the number of the retrieved candidate addresses is greater than or equal to 2. If the adapter module determines that the number of the candidate addresses is greater than or equal to 2, the adapter module may obtain the weighting values corresponding to the candidate addresses from the address list. The adapter module may generate a candidate list comprising a plurality of candidate addresses according to the weighting values corresponding to the respective candidate addresses. The weighting value corresponding to each candidate address may be set by a developer according to the configuration performance of the service node corresponding to the candidate address.
For example, after the adapter module determines three candidate addresses from the address list according to the function tag, the weighting value corresponding to each candidate address may be determined from the address list. Wherein the first candidate address may have a weight of 5, the second candidate address may have a weight of 1, and the third candidate address may have a weight of 2. The adapter module may then generate a candidate list containing 5 first candidate addresses, 1 second candidate address, and 2 third candidate addresses.
In one possible implementation, if the adapter module determines that the number of candidate addresses is greater than or equal to 2, the adapter module may further determine whether the number of candidate addresses is 1. If the adapter module determines that the number of candidate addresses is 1, the adapter module may determine that the candidate address is the target address. If the adapter module determines that the number of the candidate addresses is not 1, the adapter module may determine that the address list does not include the target address corresponding to the function call request, and at this time, the adapter module may regenerate the address query instruction according to the function tag corresponding to the function call request, and send the newly generated address query instruction to the function management module to obtain the target address corresponding to the function call request.
In one possible implementation, after the adapter module determines that the number of candidate addresses is greater than or equal to 2, the adapter module may determine, through other load balancing algorithms, a target address from a plurality of candidate addresses, for example, a polling algorithm, a weighted polling algorithm, a random algorithm, a source address hash algorithm, and other load balancing algorithms.
S503, determining the target address from the candidate list through a preset random function.
In this embodiment, after the adapter module on the electronic device generates the candidate list according to the weighted values corresponding to the candidate addresses, the target address may be determined from the candidate list by a preset random function.
In one possible implementation manner, after the candidate list is generated, the adaptor module may belong the sequence numbers of the candidate addresses in the candidate list to a preset random function, and generate the target sequence number through the random function. The adapter module may determine, from the candidate list, a target address corresponding to the target sequence number according to the target sequence number.
In this embodiment, the adapter module may determine the target address from the multiple candidate addresses according to the weighted values and the random functions corresponding to the candidate addresses, so that the adapter module may send more call requests to the service node with strong configuration performance, and send fewer call requests to the service node with weak configuration performance, so that a failure caused by excessive load of the service node may be effectively avoided. Meanwhile, the target address is selected through a random function on the basis of the weighted value, so that the load balance of each service node is guaranteed, and the resource utilization rate of each service node can be effectively improved.
Fig. 6 shows a flowchart of a specific implementation of an application function calling method S104 according to a fifth embodiment of the present application. Referring to fig. 6, compared to the embodiment of fig. 1, in the method for calling an application function provided in this embodiment, S104 includes: s1041 to S1042 are specifically described as follows:
s1041, receiving response data returned by the service node based on the call request.
In this embodiment, after the electronic device sends a call request to the service node through the adapter module, response data returned by the service node based on the call request may be received through the adapter module.
In one possible implementation, the electronic device may transmit the invocation request to the service node over a communication link established by the target communication protocol. After receiving the call request, the service node can analyze the call request according to a request analysis mode, and acquire call parameters from the analyzed call request. The call parameters in the call request are generated by converting the request parameters in the function call request by the adapter module according to the request type, and are encapsulated in the call request. The service node can operate the response function in the service node according to the call parameters obtained through analysis, and encapsulate the operation result into response data according to the preset response type. The service node may return response data to the adapter module over a communication link between the service node and the target application.
For example, after the adaptor module generates the encrypted call request through the encrypter () function, the encrypted call request may be sent to the service node where the encryption library is located through the communication link. After receiving the encryption call request, the service node may parse the encryption call request to obtain data to be encrypted. After the service node obtains the data to be encrypted, the encryption () function in the encryption library can be called to encrypt the data to be encrypted, and the encrypted data is generated. The service node may further encapsulate the encrypted data according to a preset response type to generate encrypted response data, and return the encrypted response data to the adapter module of the electronic device through the communication link.
S1042, analyzing the response data to generate a calling result, and calling a functional module corresponding to the calling function to respond to an operation instruction corresponding to the calling function by using the calling result.
In this embodiment, after receiving the response data returned by the service node, the adapter module on the electronic device may parse the response data to generate the call result. Then, the electronic device can call the function module corresponding to the calling function on the target application, so that the function module corresponding to the calling function responds to the operation instruction corresponding to the calling function by using the calling result.
In one possible implementation manner, if the adapter module and the target application are deployed on different electronic devices, that is, the adapter module is deployed on the server and the target application is deployed on the user device, the adapter module may send the call result to the user device that initiates the function call request after parsing the received response data to generate the call result, so that the call function module responds to the operation instruction corresponding to the call function.
In this embodiment, after receiving the response data returned by the service node, the adapter module on the electronic device may parse the response data and generate a call result that may be used between the target applications. The functional module on the target application may execute the corresponding operation instruction using the adapter module to parse the generated call result. Therefore, the method provided by the embodiment can completely decouple the target application from the service node providing the data calling service, so that the service node and the target application are not directly influenced, and the target application is not influenced when the service node is unstable, thereby being beneficial to improving the overall stability of the system.
Fig. 7 is a flowchart showing a specific implementation of an application function calling method S104 according to the sixth embodiment of the present application. Referring to fig. 7, compared with the embodiment of fig. 1, after S104, the method for calling an application function according to the present embodiment includes: s701 to S702 are specifically described as follows:
s701, collecting communication indexes between the electronic equipment and the service node through a monitoring module.
In this embodiment, after the electronic device sends the call request to the service node through the adapter module, the communication index between the electronic device and the service node may also be collected through the monitoring module.
In one possible implementation, the communication metrics collected by the monitoring module on the electronic device may include the response time of the service node. After monitoring that the adapter module sends a call request to the service node, the monitoring module can record the sending time of the call request sent by the adapter module and the call request corresponding to the sending time. When the monitoring module monitors that the adapter module receives the response data returned by the service node, the receiving time of the response data can be recorded. The monitoring module may determine a response time of the service node according to a sending time corresponding to the call request and a receiving time of the response data corresponding to the call request.
In one possible implementation, the communication metrics collected by the monitoring module on the electronic device may also include an error rate of the service node response. When the monitoring module detects that the adapter module sends the call request, the monitoring module can determine the service node corresponding to the call request and update the sending times corresponding to the service node. When the monitoring module monitors that the adapter module receives the response data, the monitoring module can determine the service node corresponding to the response data and update the return times corresponding to the service node. The monitoring module can determine the error rate corresponding to the service node according to the sending times and the returning times corresponding to the same service node.
S702, sending the communication index to the function management system; the communication index is used for visually representing the communication condition between the electronic equipment and the service node in the function management system.
In this embodiment, the monitoring module on the electronic device may send the communication index to the function management system. After receiving the communication indexes sent by the electronic equipment, the function management system can perform visualization processing on various communication indexes and display the various communication indexes in the function management system in the form of a dashboard.
In one possible implementation, the electronic device may send the communication indicator to the function management system at regular time. In addition, various communication indexes can be detected on a monitoring module on the electronic equipment according to a preset alarm rule. Once the monitoring module detects that any communication index meets a preset alarm rule, the monitoring module can initiate alarm notification to the function management system, so that operation and maintenance personnel can timely find out abnormal conditions of the service node.
By the method provided by the embodiment, the operation and maintenance personnel can timely know the communication condition between each service node and the target application through the communication index fed back by the monitoring module, so that the operation and maintenance personnel can timely find out the abnormality of the system, and the reliability of the system can be maintained.
Embodiment two:
fig. 8 is a flowchart showing a specific implementation of a calling method of an application function according to a seventh embodiment of the present application. The calling method can be applied to the service node deployed with the common components or the common database. The method for calling the application function specifically comprises the following steps:
s801, transmitting registration information to a function management system to become the service node; the registration information comprises address information corresponding to the service node, a service label of the service node and a request type corresponding to the service node.
In this embodiment, when a developer deploys a common component or a common database on any node, the node may send registration information to the function management system. The function management system may receive and store registration information transmitted by any node. Any node after sending the registration information to the function management system may become a service node. The registration information sent by the node to the function management system may include address information corresponding to the service node, a service tag corresponding to the service node, and a request type corresponding to the service node.
In one possible implementation, the function management system may store the received registration information after receiving the registration information sent by the node. After the function management system receives the address query instruction sent by the adapter module, a plurality of service nodes required to be used by the target application can be determined from the registration information of each service node according to a plurality of function labels in the address query instruction. The function management system can query the service label of each service node according to the function label, and if the service label in any registration information is consistent with the function label, the function management system can determine that the service node corresponding to the registration information can provide data calling service for the target application. The function management system may generate an address list according to address information of each service node whose service label is consistent with the function label, a request type, and the service label, and transmit the address list to the adapter module.
S802, receiving a call request sent by the electronic equipment, and determining call parameters corresponding to the call request.
In this embodiment, after the node becomes a service node, a call request sent by the electronic device through the adapter module may be received. The service node can analyze the call request through a preset analysis module so as to acquire call parameters contained in the call request. The call parameters in the call request are generated by converting the request parameters in the function call request by the adapter module according to the request type, and are encapsulated in the call request.
S803, response data is generated based on the operation instruction corresponding to the call request responding to the call parameter, and the response data is sent to the electronic equipment.
In this embodiment, after the service node analyzes the call request to obtain the call parameter, response data may be generated based on the operation instruction corresponding to the call request that is responded by the call parameter obtained by the analysis, and the response data may be sent to the electronic device.
In one possible implementation manner, the service node may operate a response function in the service node according to the call parameter obtained by parsing, encapsulate an operation result into response data according to a preset response type, and return the response data to the adapter module on the electronic book device through a communication link between the service node and the target application.
According to the method provided by the embodiment, the service node can provide the data calling service for the target application by receiving the calling request, namely, the service node can exist independently of the target application, so that a developer can independently update and expand each service node according to service requirements, the expandability of the system is improved, and the system can better cope with the continuously-changing service requirements. In addition, in the embodiment provided by the application, the adapter module on the electronic equipment can generate the corresponding call request according to the service node, so that the same service node can provide data call services for different target applications, the system can be better compatible with the target applications and the service nodes in different program languages, and the compatibility of the system is improved.
It should be noted that, the sequence number of each step in the above embodiment does not mean the sequence of execution sequence, and the execution sequence of each process should be determined by its function and internal logic, and should not limit the implementation process of the embodiment of the present application in any way.
Referring to fig. 9, a schematic diagram of an application function calling device provided by an embodiment of the present application is shown, where the virtual device may be applied to a service node. The virtual device may specifically include a determining module 901, a request generating module 902, a sending module 903, and a responding module 904, where:
A determining module 901, configured to determine, in response to a function call request initiated by any calling function in a target application, a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; the target address is the address of a service node for providing the data call service corresponding to the function call request; the calling function is an application function realized by calling a service node in the target application;
a request generating module 902, configured to generate a call request based on a request type corresponding to the target address and a request parameter in the function call request;
a sending module 903, configured to send the call request to a service node corresponding to the target address according to the target address;
and the response module 904 is used for receiving response data returned by the service node based on the call request and calling the target application to respond to the operation instruction corresponding to the calling function by using the response data.
Referring to fig. 10, a schematic diagram of an application function calling device provided by an embodiment of the present application is shown, where the virtual device may be applied to an electronic device. The virtual device specifically may include a registration module 1001, a receiving module 1002, and a response module 1003, where:
A registration module 1001, configured to send registration information to a function management system to become the service node; the registration information comprises address information corresponding to the service node, a service label of the service node and a request type corresponding to the service node;
a receiving module 1002, configured to receive a call request sent by an electronic device, and determine a call parameter corresponding to the call request;
and a response module 1003, configured to generate response data according to the operation instruction corresponding to the call request and send the response data to the electronic device.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference should be made to the description of the method embodiments.
Referring to fig. 11, a schematic diagram of a terminal device provided by an embodiment of the present application is shown. As shown in fig. 11, a terminal apparatus 1100 in an embodiment of the present application includes: a processor 1110, a memory 1120, and a computer program 1121 stored in the memory 1120 and executable on the processor 1110. The processor 1110 implements the steps in the embodiments of the calling method of the application function described above when executing the computer program 1121, for example, steps S101 to S104 shown in fig. 1. Alternatively, the processor 1110, when executing the computer program 1121, performs the functions of the modules/units in the above-described apparatus embodiments, for example, the functions of the modules 901 to 904 shown in fig. 9, or the functions of the modules 1001 to 1003 shown in fig. 10.
Illustratively, the computer program 1121 may be partitioned into one or more modules/units that are stored in the memory 1120 and executed by the processor 1110 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which may be used to describe the execution of the computer program 1121 in the terminal device 1100. For example, the computer program 1121 may be divided into a determination module, a request generation module, a transmission module, and a response module, each of which specifically functions as follows:
the determining module is used for responding to a function call request initiated by any call function in the target application, and determining a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; the target address is the address of a service node for providing the data call service corresponding to the function call request; the calling function is an application function realized by calling a service node in the target application;
the request generation module is used for generating a call request based on the request type corresponding to the target address and the request parameters in the function call request;
The sending module is used for sending the calling request to the service node corresponding to the target address according to the target address;
and the response module is used for receiving response data returned by the service node based on the calling request and calling the target application to respond to the operation instruction corresponding to the calling function by using the response data.
The terminal device 1100 may be an electronic device or a service node in the foregoing embodiments, where the electronic device or the service node may be a computing device such as a desktop computer, a cloud server, or the like. The terminal device 1100 may include, but is not limited to, a processor 1110, a memory 1120. It will be appreciated by those skilled in the art that fig. 11 is merely an example of a terminal device 1100 and is not meant to be limiting of the terminal device 1100, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., the terminal device 1100 may also include input and output devices, network access devices, buses, etc.
The processor 1110 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 1120 may be an internal storage unit of the terminal device 1100, for example, a hard disk or a memory of the terminal device 1100. The memory 1120 may also be an external storage device of the terminal device 1100, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the terminal device 1100. Further, the memory 1120 may also include both an internal storage unit and an external storage device of the terminal device 1100. The memory 1120 is used for storing the computer program 1121 and other programs and data required for the terminal device 1100. The memory 1120 may also be used to temporarily store data that has been output or is to be output.
The embodiment of the application also discloses a terminal device which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the calling method of the application function in the previous embodiments when executing the computer program.
The embodiment of the application also discloses a computer readable storage medium, which stores a computer program, and the computer program realizes the calling method of the application function in the previous embodiments when being executed by a processor.
The embodiment of the application also discloses a computer program product which, when running on a computer, causes the computer to execute the calling method of the application function in each embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and are not limited thereto. Although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. An application function calling method applied to electronic equipment is characterized by comprising the following steps:
responding to a function call request initiated by any call function in a target application, and determining a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; the target address is the address of a service node for providing the data call service corresponding to the function call request; the calling function is an application function realized by calling a service node in the target application;
Generating a call request based on the request type corresponding to the target address and the request parameters in the function call request;
sending the call request to a service node corresponding to the target address according to the target address;
and receiving response data returned by the service node based on the calling request, and calling the target application to respond to an operation instruction corresponding to the calling function by using the response data.
2. The method according to claim 1, wherein before the receiving the function request initiated by the user and determining the target address and the request type corresponding to the target address from the preset address list based on the function request, the method comprises:
generating address inquiry instructions about all calling functions in the target application in response to the running instructions of the target application;
sending the address inquiry instruction to a function management system to determine the address of the service node corresponding to each calling function; the function management system is used for managing a plurality of service nodes;
and receiving and storing the address list fed back by the function management system based on the address inquiry instruction.
3. The method according to claim 1, wherein the sending the call request to the service node corresponding to the target address according to the target address includes:
Determining a target communication protocol corresponding to the target address;
establishing a communication link between the target application and the service node based on the target communication protocol; the communication link is for transmitting the call request and the response data.
4. The method according to claim 1, wherein the determining, in response to a function call request initiated by any calling function in the target application, a target address corresponding to the function request and a request type corresponding to the target address from a preset address list includes:
determining a candidate address from the address list based on a function tag in the function call request;
if the number of the candidate addresses is greater than or equal to 2, generating a candidate list containing a plurality of candidate addresses based on the weighting values corresponding to the candidate addresses; the weighting parameter is determined by the configuration performance of the service node corresponding to the candidate address;
and determining the target address from the candidate list through a preset random function.
5. The method according to claim 1, wherein the receiving response data returned by the service node based on the call request, and invoking the target application to respond to the operation instruction corresponding to the invoking function using the response data, includes:
Receiving response data returned by the service node based on the call request;
analyzing the response data to generate a calling result, and calling a functional module corresponding to the calling function to respond to an operation instruction corresponding to the calling function by using the calling result.
6. The method according to any one of claims 1-5, wherein after the sending the call request to the service node corresponding to the target address according to the target address, the method includes:
collecting communication indexes between the electronic equipment and the service node through a monitoring module;
transmitting the communication index to the function management system; the communication index is used for visually representing the communication condition between the electronic equipment and the service node in the function management system.
7. A method for calling an application function, applied to a service node, comprising:
transmitting registration information to a function management system to become the service node; the registration information comprises address information corresponding to the service node, a service label of the service node and a request type corresponding to the service node;
receiving a call request sent by electronic equipment, and determining call parameters corresponding to the call request;
And generating response data based on the operation instruction corresponding to the call request responding to the call parameter, and sending the response data to the electronic equipment.
8. An application function calling device applied to an electronic device, comprising:
the determining module is used for responding to a function call request initiated by any call function in the target application, and determining a target address corresponding to the function call request and a request type corresponding to the target address from a preset address list; the target address is the address of a service node for providing the data call service corresponding to the function call request; the calling function is an application function realized by calling a service node in the target application;
the request generation module is used for generating a call request based on the request type corresponding to the target address and the request parameters in the function call request;
the sending module is used for sending the calling request to the service node corresponding to the target address according to the target address;
and the response module is used for receiving response data returned by the service node based on the calling request and calling the target application to respond to the operation instruction corresponding to the calling function by using the response data.
9. Terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements a method for invoking application functions according to any of claims 1-7 when executing the computer program.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements a method of invoking application functions according to any of claims 1-7.
CN202310706980.6A 2023-06-14 2023-06-14 Application function calling method and device, terminal equipment and storage medium Pending CN116880970A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310706980.6A CN116880970A (en) 2023-06-14 2023-06-14 Application function calling method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310706980.6A CN116880970A (en) 2023-06-14 2023-06-14 Application function calling method and device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116880970A true CN116880970A (en) 2023-10-13

Family

ID=88259474

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310706980.6A Pending CN116880970A (en) 2023-06-14 2023-06-14 Application function calling method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116880970A (en)

Similar Documents

Publication Publication Date Title
CN107231402B (en) HTTP request processing method, device and system
CN107508795B (en) Cross-container cluster access processing device and method
US10747592B2 (en) Router management by an event stream processing cluster manager
CN107800565B (en) Inspection method, inspection device, inspection system, computer equipment and storage medium
CN106600499B (en) Hospital information integration method based on bus form
US10944655B2 (en) Data verification based upgrades in time series system
US8266630B2 (en) High-performance XML processing in a common event infrastructure
CN113032419B (en) Multi-source data aggregation search method, device, equipment and storage medium
US8543680B2 (en) Migrating device management between object managers
CN114090366A (en) Method, device and system for monitoring data
CN112217847A (en) Micro service platform, implementation method thereof, electronic device and storage medium
CN114490268A (en) Full link monitoring method, device, equipment, storage medium and program product
CN113342547A (en) Remote service calling method and device, electronic equipment and readable storage medium
US9544214B2 (en) System and method for optimized event monitoring in a management environment
US9906604B2 (en) System and method for dynamic discovery of web services for a management console
US20210224102A1 (en) Characterizing operation of software applications having large number of components
CN109324892B (en) Distributed management method, distributed management system and device
CN116880970A (en) Application function calling method and device, terminal equipment and storage medium
US11637737B2 (en) Network data management framework
CN114756301A (en) Log processing method, device and system
CN112416980A (en) Data service processing method, device and equipment
CN115129708A (en) Data processing method, data processing device, storage medium and electronic equipment
CN111858260A (en) Information display method, device, equipment and medium
JP2009100477A (en) Condition dependent data maintenance system for a plurality of functional entities
US10516767B2 (en) Unifying realtime and static data for presenting over a web service

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