CN113177085A - Method, device, equipment and storage medium for calling interface idempotent - Google Patents

Method, device, equipment and storage medium for calling interface idempotent Download PDF

Info

Publication number
CN113177085A
CN113177085A CN202110573873.1A CN202110573873A CN113177085A CN 113177085 A CN113177085 A CN 113177085A CN 202110573873 A CN202110573873 A CN 202110573873A CN 113177085 A CN113177085 A CN 113177085A
Authority
CN
China
Prior art keywords
intention
assertion
coordinator
interface
executed
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.)
Granted
Application number
CN202110573873.1A
Other languages
Chinese (zh)
Other versions
CN113177085B (en
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.)
Shanghai Anchnet Network Technology Co ltd
Original Assignee
Shanghai Anchnet Network 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 Shanghai Anchnet Network Technology Co ltd filed Critical Shanghai Anchnet Network Technology Co ltd
Priority to CN202110573873.1A priority Critical patent/CN113177085B/en
Publication of CN113177085A publication Critical patent/CN113177085A/en
Application granted granted Critical
Publication of CN113177085B publication Critical patent/CN113177085B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems

Abstract

The embodiment of the application relates to the technical field of computers, in particular to a method, a device, equipment and a storage medium for calling interface idempotent, aiming at ensuring the accuracy of calling the interfaces between systems and improving the efficiency of calling the interfaces between systems. The method comprises the following steps: the server side responds to an interface calling request sent by a calling side, packages the interface calling request and related data of a called interface into an intention, and submits the intention to the coordinator; the coordinator verifies the intention, obtains an assertion aiming at the intention and sends the assertion to the service party; and the server side responds to the interface calling request according to the assertion.

Description

Method, device, equipment and storage medium for calling interface idempotent
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method, a device, equipment and a storage medium for calling interface idempotent.
Background
When one system calls another system, if network jitter occurs or the system is temporarily unavailable, the call will fail, and in order to ensure the call is normally performed, multiple call attempts are generally performed on the system by means of retry, but at this time, it must be ensured that the call process is idempotent, that is, the call result must be consistent, and if the call process is not idempotent, the result of two repeated calls may be inconsistent. In the prior art, by performing encoding processing on a calling party and a called party (i.e. a service party), when the calling party calls, encoding verification is performed first on the state of current data, when the called party is called, encoding verification is also performed, and when verification is correct, a calling operation is performed.
The problems existing in the prior art are as follows: when the call between systems is frequent, the number of the called interfaces is very large, each interface is coded by developers, the workload is large, the later maintenance is not facilitated, and errors are easy to occur.
Disclosure of Invention
The embodiment of the application provides a method, a device, equipment and a storage medium for calling interface idempotent, and aims to ensure the accuracy of calling the interfaces between systems and improve the efficiency of calling the interfaces between systems.
A first aspect of an embodiment of the present application provides a method for interface idempotent invocation, where the method includes:
the server side responds to an interface calling request sent by a calling side, packages the interface calling request and related data of a called interface into an intention, and submits the intention to the coordinator;
the coordinator verifies the intention, obtains an assertion aiming at the intention and sends the assertion to the service party;
and the server side responds to the interface calling request according to the assertion.
Optionally, the data related to the interface includes a data source, a data location, and a feature field related to the called interface.
Optionally, the verifying the intention by the coordinator, and obtaining an assertion for the intention includes:
the coordinator verifies whether the operation corresponding to the intention is executed in a data source according to the intention;
when the verification result is that the operation corresponding to the intention is not executed, the coordinator locks the intention and sends an assertion that the operation is not executed to the server side;
and when the operation corresponding to the intention is executed as a verification result, the coordinator sends an assertion that the operation is executed to the server side.
Optionally, the step of responding, by the server, to the interface call request according to the assertion includes:
when the assertion is that the operation is not executed, the service side executes the operation corresponding to the intention and sends a message of successful calling to the calling side;
when the assertion is that an operation has been performed, the service sends a message to the caller that the invocation was successful.
Optionally, the method further comprises:
when the operation execution corresponding to the intention is completed by the service party, an intention unlocking instruction is sent to the coordinator;
and the coordinator unlocks the intention according to the intention unlocking instruction.
Optionally, the method further comprises:
when the coordinator does not receive the intention unlocking instruction within a first preset time period, verifying the intention every other second preset time period to obtain an assertion aiming at the intention;
the coordinator automatically unlocking the intent when the assertion is that an operation has been performed;
and when the assertion is still not executed after the verification of the preset times, the coordinator suspends the intention and sends a manual unlocking notice.
Optionally, the method further comprises:
deploying a plurality of instances in the coordinator;
in the case where the service party submits multiple different intentions to the coordinator, the coordinator verifies the intentions, resulting in an assertion for the intentions, including:
and the coordinator verifies the plurality of different intentions by using different self-deployed examples to obtain a plurality of assertions.
A second aspect of the embodiments of the present application provides an apparatus for interface idempotent invocation, where the apparatus includes:
the intention packaging module is used for responding to an interface calling request sent by a calling party by a service party, packaging the interface calling request and related data of a called interface into an intention, and submitting the intention to the coordinator;
the assertion module is used for verifying the intention by the coordinator, obtaining an assertion aiming at the intention and sending the assertion to the service party;
and the service module is used for responding to the interface calling request by the service party according to the assertion.
Optionally, the data related to the interface includes a data source, a data location, and a feature field related to the called interface.
Optionally, the assertion module comprises:
the operation verification submodule is used for verifying whether the operation corresponding to the intention is executed in a data source according to the intention by the coordinator;
the first assertion submodule is used for locking the intention and sending an assertion that the operation is not executed to the server side by the coordinator when the operation corresponding to the intention is not executed as a verification result;
and the second assertion submodule is used for sending the assertion that the operation is executed to the server side by the coordinator when the operation corresponding to the intention is executed as a verification result.
Optionally, the service module includes:
the operation execution sub-module is used for executing the operation corresponding to the intention by the service party and sending a message of successful calling to the calling party when the assertion is that the operation is not executed;
and the message return submodule is used for sending a message of successful calling to the calling party by the service party when the assertion is that the operation is executed.
Optionally, the apparatus further comprises:
the instruction sending submodule is used for sending an intention unlocking instruction to the coordinator when the operation corresponding to the intention is executed and completed by the server;
and the first intention unlocking submodule is used for unlocking the intention by the coordinator according to the intention unlocking instruction.
Optionally, the apparatus further comprises:
the third assertion submodule is used for verifying the intention every other second preset time period when the coordinator does not receive the intention unlocking instruction within the first preset time period, so as to obtain assertion aiming at the intention;
a second intent unlock submodule to automatically unlock the intent by the coordinator when the assertion is that an operation has been performed;
and the intention suspension sub-module is used for suspending the intention and sending out a manual unlocking notice when the assertion is still not executed by the operation after the verification of the preset times.
Optionally, the method further comprises:
an instance deployment submodule for deploying a plurality of instances in the coordinator;
in the case where the service party submits multiple different intentions to the coordinator, the coordinator verifies the intentions, resulting in an assertion for the intentions, including:
and the fourth assertion submodule is used for verifying the plurality of different intentions by the coordinator by using different deployed examples to obtain a plurality of assertions.
A third aspect of embodiments of the present application provides a readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps in the method according to the first aspect of the present application.
A fourth aspect of the embodiments of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the steps of the method according to the first aspect of the present application.
By adopting the interface idempotent calling method provided by the application, a server side responds to an interface calling request sent by a calling side, encapsulates the interface calling request and related data of a called interface into an intention, and submits the intention to a coordinator; the coordinator verifies the intention, obtains an assertion aiming at the intention and sends the assertion to the service party; and the server side responds to the interface calling request according to the assertion. The calling request and the interface related data are packaged as intentions and sent to the coordinator by the server side for processing, the calling side does not need to be subjected to any special processing, the service logic of the server side does not have any influence, the calling side and the server side do not need to be subjected to coding processing in order to guarantee calling idempotency, and the working efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive exercise.
FIG. 1 is a flow chart of a method for interface idempotent invocation presented in an embodiment of the present application;
fig. 2 is a block diagram of an interface idempotent method according to an embodiment of the present application
Fig. 3 is a schematic diagram of an apparatus for interface idempotent invocation according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart of a method for interface idempotent invocation according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
s11: and the server side responds to the interface calling request sent by the calling side, packages the interface calling request and the related data of the called interface into an intention, and submits the intention to the coordinator.
In this embodiment, the service party belongs to the called party, the interface call request is used to request to call an interface in the service party, the intention is to uniformly describe addition, deletion and modification of data, the intention also includes a query, but the query does not relate to idempotency, and therefore is not discussed here, and three forms of the intention are: adding intention, deleting intention and modifying intention. Information contained in one intent is: the data source where the data is located, the specific location where the data is located (the specific table if the database is the database), and a characteristic field. The characteristic field can be a plurality of fields, and all the characteristic fields can uniquely express the execution result of the intention. The coordinator is a module that verifies and asserts intent. When a caller needs to call, the result of the interface execution can be expressed, and for an interface, if one intention cannot accurately express the result of the interface execution, a plurality of intentions can be used for expression. Encapsulation is the encapsulation of the code as a whole into a program.
In the embodiment of the application, the relevant data of the interface comprises a data source, a data position and a characteristic field related to the called interface.
For example, the caller is an identity information entry system, the caller needs to add new identity information of a user, the caller sends a call request of an interface that needs to be used for adding the new identity information of the user to the server, the server packages the call request, a data source (a user identity information base) related to the interface that needs to be called, a data location (a storage location of the identity information base), and a feature field (a field indicating specific identity information of the user), and the packaging manner is not limited herein, for example, an SDK may be made by using technologies such as AOP, and the intention is packaged in an annotation manner. The packaged intent is sent to the coordinator. The characteristic field may be a name of the user, identity information of the user, native information of the user, and the like.
S12: the coordinator verifies the intention, obtains an assertion aiming at the intention, and sends the assertion to the service party.
In this embodiment, the coordinator is connected to the server and configured to verify an intention sent by the server, a concurrency control module is provided in the coordinator and configured to lock a current intention, and an operation corresponding to the same intention can be executed again only after unlocking. And judging whether the operation corresponding to the current intention is executed or not by an assertion (Assert) pointer.
The specific steps of verifying the intention by the coordinator and obtaining the assertion aiming at the intention are as follows:
s12-1: and the coordinator verifies whether the operation corresponding to the intention is executed in the data source according to the intention.
In this embodiment, after receiving the intention sent by the service side, the coordinator verifies whether the operation corresponding to the intention has been executed according to the data source, the data location, and the feature field included in the intention.
For example, taking a data source included in the intention as an identity information database as an example, when the result of the intention execution is to enter the identity information of the user in the identity information database, the coordinator may query the identity information database to see whether the identity information (name, identity card number, household identity) of the user is already entered in the database.
S12-2: when the operation corresponding to the intention is not executed as a verification result, the coordinator locks the intention and sends an assertion that the operation is not executed to the server side.
In this embodiment, the coordinator searches the feature field according to the received intention in the data source according to the data position, and when the feature field corresponding to the intention is not found in the data source, it determines that the operation corresponding to the intention is not executed, at this time, the intention is locked by a concurrency control module inside the coordinator, and after the intention is locked, before the intention is unlocked, the same intention is to be executed, and it is necessary to wait for the intention to be unlocked. The coordinator sends an assertion that the operation is not performed to the server.
For example, when the result of the intended execution is to add the identity information of the user into the database, the coordinator queries whether the information of the name, the identity card number, the household registration, and the like of the user is entered into the identity information database, and sends an assertion that the operation is not executed to the server side when the identity information of the user cannot be found in the database.
S12-3: and when the operation corresponding to the intention is executed as a verification result, the coordinator sends an assertion that the operation is executed to the server side.
In this embodiment, when the coordinator finds the feature field corresponding to the intention in the data source, it is determined that the operation corresponding to the intention has been executed, and at this time, an assertion that the operation has been executed is sent to the server.
For example, when the result of the intended execution is to add the identity information of the user into the database, the coordinator queries whether the information of the name, the identity card number, the household registration, and the like of the user is entered into the identity information database, and when the corresponding identity information is found, sends the assertion that the operation is executed to the server.
S13: and the server side responds to the interface calling request according to the assertion.
In this embodiment, after receiving the assertion sent by the coordinator, the service side may respond to the interface invocation request according to the assertion, and specifically includes step S13-1 and step S13-2:
step S13-1: when the assertion is that the operation is not executed, the service side executes the operation corresponding to the intention, and sends a message that the calling is successful to the calling side.
In this embodiment, when the assertion received by the server is that the operation is not executed, the server executes the code of the corresponding operation, and performs an operation of adding, deleting, or modifying the data source.
Illustratively, when the result of the intended execution is that the user information is newly added in the database, and the assertion received by the server is that the operation is not executed, the server starts executing the code of the newly added user information in the database, and the identity information of the newly added user in the database.
Step S13-2 is that the service sends a message to the caller that the call was successful when the assertion is that the operation has been performed.
In this embodiment, when the assertion received by the service side is that the operation is executed, the service side sends a message that the invocation is successful to the caller.
For example, when the result of the intended execution is that user information is newly added in the database, the assertion received by the service side is that the operation is executed, and then the service side sends a message that the identity information is successfully entered to the identity information entry system.
In this embodiment, the method further includes the following steps:
and S14-1, when the operation execution corresponding to the intention by the service party is completed, sending an intention unlocking instruction to the coordinator.
S14-2: and the coordinator unlocks the intention according to the intention unlocking instruction.
In this embodiment, after the service side completes execution of the operation corresponding to the intention, an intention unlocking instruction is sent to the coordinator, the coordinator unlocks the intention according to the instruction after receiving the intention unlocking instruction, and after the intention is locked, the operation corresponding to the same intention can be continuously executed.
In this embodiment, the coordinator may be notified of the current intention to unlock in an asynchronous manner, so that normal operation of tasks in the server and the coordinator can be ensured.
For example, when the result of the intention execution is that user information is newly added in the database, and the service party has added the user information in the database at this time, an intention unlocking instruction is sent to the coordinator, and the coordinator unlocks the corresponding intention.
In this embodiment, the method further includes the following steps:
s15-1: and when the coordinator does not receive the intention unlocking instruction within a first preset time period, verifying the intention every other second preset time period to obtain an assertion aiming at the intention.
In this embodiment, the first preset time period and the second preset time period may be set by themselves.
In this embodiment, because of network jitter, the service has already performed an operation and issued an intended unlock instruction, but the coordinator has not received the intended unlock instruction, and therefore the intention is still in a locked state. And when the coordinator does not receive the intention unlocking instruction within the first preset time period, verifying the intention again every other second preset time period to obtain an assertion aiming at the intention.
S15-2: the coordinator automatically unlocks the intent when the assertion is that an operation has been performed.
In this embodiment, when the assertion is that the operation has succeeded, the intention is automatically unlocked, and the service can continue to perform the same operation after unlocking.
S15-3: and when the assertion is still not executed after the verification of the preset times, the coordinator suspends the intention and sends a manual unlocking notice.
In this embodiment, the preset times may be set by itself, when the operation is still not executed after the assertion of the preset times, it may be that a problem occurs and the intention cannot be unlocked, at this time, the intention is suspended, that is, the intention is temporarily suspended, the intention is not processed, a manual unlocking notification is sent, and after receiving the manual unlocking notification, the relevant responsible person manually unlocks the intention.
Illustratively, the service side executes an operation corresponding to an intention, sends an intention unlocking instruction to the coordinator, at this time, the network shakes, the coordinator does not receive the instruction, the coordinator does not receive the intention unlocking instruction within 1 minute, the coordinator verifies the intention, and obtains an assertion that the operation has been executed if the operation corresponding to the intention has been executed, and unlocks the intention. When the coordinator verifies that the operation is not executed, the intention is verified again at intervals of 30 seconds, when the verification results of 3 times of continuous times are that the operation is not executed, the program possibly fails, the intention is hung at the moment, and a manual unlocking notice is sent to a related responsible person.
In another embodiment of the present application, there is the following step:
s21, deploying a plurality of instances in the coordinator.
S22, in case that the service side submits a plurality of different intentions to the coordinator, the coordinator verifies the intentions and obtains an assertion aiming at the intentions, including:
and the coordinator verifies the plurality of different intentions by using different self-deployed examples to obtain a plurality of assertions.
In the embodiment, in consideration of the availability and load pressure of the system, a plurality of instances, namely a plurality of task processes can be deployed in the coordinator, and the task processes can execute tasks in parallel to verify the intention. The server side can send different intentions, namely, the intentions are classified and coded according to the intended hash codes and the intended classification codes to different instances for processing, so that the processing speed can be guaranteed.
Illustratively, the server sends the intention corresponding to the request for adding the user information to the first instance of the coordinator for processing, and sends the intention corresponding to the request for deleting the user information to the second instance of the coordinator for processing.
As shown in fig. 2, fig. 2 is a block diagram of an interface idempotent method according to an embodiment of the present application.
In fig. 2, a calling party sends a calling request to a server, the server packages the calling request and corresponding interface information into an intention and sends the intention to a coordinator, the coordinator verifies whether an operation corresponding to the intention has been executed in a data source according to the intention, after the verification is completed, an assertion is sent to the server, the server responds to the calling request according to the assertion, and an unlocking instruction is sent to the coordinator after the execution operation is successful.
By adopting the interface idempotent calling method in the embodiment, the processing can be performed only in the service party, the calling party does not need to perform any processing, the coding processing can not be performed on the calling party and the called party, and the calling party can perform retry of any number of times to ensure the success of the calling. In the embodiment, the intention is adopted to express the result of the operation which the calling party wants to execute, the assertion is sent to the server after the result is verified, the calling party only needs to send the calling request, and the processing speed is improved. For the service party, the SDK which is non-invasive to the service is adopted, when the calling operation is carried out, the original service of the service party and the called service can be carried out simultaneously, and the original service of the service party cannot be influenced. When the calling party calls the interface, if the feedback of successful operation is not obtained, the calling request can be repeatedly sent for many times until the operation is successfully executed, and the situation that the request is not received due to the jitter of the network is prevented.
In another embodiment of the application, when a user submits a file, the user repeatedly clicks a multiple submission button, the user can be regarded as a caller, when the server receives a submission request of the user, the submission request and corresponding interface information are packaged as intentions and sent to the coordinator, the coordinator verifies whether the file already exists in the database according to the intentions, if the file does not exist, an assertion that the operation is not executed is sent, if the file already exists, the assertion that the operation is executed is sent, and the server adds the file to the database according to the received assertion or returns information that the submission is successful to the user.
In addition, the interface idempotent calling method in the embodiment of the application is also suitable for interface calling among systems in a distributed architecture such as a microservice architecture. In a distributed architecture, frequent calls between systems are required, and when the first call times out, the host system (caller) retries the call considering the call failed, and the first timeout may have been processed by the server system when the host system retries, if the calling process is not idempotent, it may cause the final result of two repeated calls to be inconsistent, in order to ensure the idempotency of the interfaces, developers must perform coding processing on each interface, and by using the scheme, the caller does not need any processing, the server is responsible for encapsulating the intention and sending the intention to the coordinator, and the business logic of the server is not affected, because the coordinator can lock the intention, the calling party can retry for any number of times, the calling success is ensured, and the accuracy and the speed of calling the interface between the distributed systems are obviously improved.
Based on the same inventive concept, an embodiment of the present application provides an apparatus for interface idempotent calling. Referring to fig. 3, fig. 3 is a schematic diagram of an apparatus 300 for interface idempotent invocation according to an embodiment of the present application.
As shown in fig. 3, the apparatus includes:
the intention encapsulating module 301 is used for the server to respond to the interface calling request sent by the caller, encapsulate the interface calling request and the related data of the called interface into an intention, and submit the intention to the coordinator.
An assertion module 302, configured to verify the intention by the coordinator, obtain an assertion for the intention, and send the assertion to the service party;
the service module 303, configured to respond to the interface call request according to the assertion;
optionally, the data related to the interface includes a data source, a data location, and a feature field related to the called interface.
Optionally, the assertion module comprises:
the operation verification submodule is used for verifying whether the operation corresponding to the intention is executed in a data source according to the intention by the coordinator;
the first assertion submodule is used for locking the intention and sending an assertion that the operation is not executed to the server side by the coordinator when the operation corresponding to the intention is not executed as a verification result;
and the second assertion submodule is used for sending the assertion that the operation is executed to the server side by the coordinator when the operation corresponding to the intention is executed as a verification result.
Optionally, the service module includes:
the operation execution sub-module is used for executing the operation corresponding to the intention by the service party and sending a message of successful calling to the calling party when the assertion is that the operation is not executed;
and the message return submodule is used for sending a message of successful calling to the calling party by the service party when the assertion is that the operation is executed.
Optionally, the apparatus further comprises:
the instruction sending submodule is used for sending an intention unlocking instruction to the coordinator when the operation corresponding to the intention is executed and completed by the server;
and the first intention unlocking submodule is used for unlocking the intention by the coordinator according to the intention unlocking instruction.
Optionally, the apparatus further comprises:
the third assertion submodule is used for verifying the intention every other second preset time period when the coordinator does not receive the intention unlocking instruction within the first preset time period, so as to obtain assertion aiming at the intention;
a second intent unlock submodule to automatically unlock the intent by the coordinator when the assertion is that an operation has been performed;
and the intention suspension sub-module is used for suspending the intention and sending out a manual unlocking notice when the assertion is still not executed by the operation after the verification of the preset times.
Optionally, the method further comprises:
an instance deployment submodule for deploying a plurality of instances in the coordinator;
in the case where the service party submits multiple different intentions to the coordinator, the coordinator verifies the intentions, resulting in an assertion for the intentions, including:
and the fourth assertion submodule is used for verifying the plurality of different intentions by the coordinator by using different deployed examples to obtain a plurality of assertions.
Based on the same inventive concept, another embodiment of the present application provides a readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps in the method of interfacing idempotent calls according to any of the above-mentioned embodiments of the present application.
Based on the same inventive concept, another embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and running on the processor, and when the processor executes the computer program, the electronic device implements the steps in the method for interface idempotent call according to any of the above embodiments of the present application.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal 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.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal 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 terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method, the apparatus, the device and the storage medium for invoking interface idempotent provided by the present application are introduced in detail, and a specific example is applied in the present application to explain the principle and the implementation of the present application, and the description of the above embodiment is only used to help understanding the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for interface idempotent calls, the method comprising:
the server side responds to an interface calling request sent by a calling side, packages the interface calling request and related data of a called interface into an intention, and submits the intention to the coordinator;
the coordinator verifies the intention, obtains an assertion aiming at the intention and sends the assertion to the service party;
and the server side responds to the interface calling request according to the assertion.
2. The method of claim 1, wherein the data related to the interface comprises a data source, a data location, and a feature field referred to by the called interface.
3. The method of claim 1, wherein the mediator verifying the intent, resulting in an assertion for the intent, comprises:
the coordinator verifies whether the operation corresponding to the intention is executed in a data source according to the intention;
when the verification result is that the operation corresponding to the intention is not executed, the coordinator locks the intention and sends an assertion that the operation is not executed to the server side;
and when the operation corresponding to the intention is executed as a verification result, the coordinator sends an assertion that the operation is executed to the server side.
4. The method of claim 1, wherein the server responding to the interface invocation request based on the assertion comprises:
when the assertion is that the operation is not executed, the service side executes the operation corresponding to the intention and sends a message of successful calling to the calling side;
when the assertion is that an operation has been performed, the service sends a message to the caller that the invocation was successful.
5. The method according to claim 3 or 4, characterized in that the method further comprises:
when the operation execution corresponding to the intention is completed by the service party, an intention unlocking instruction is sent to the coordinator;
and the coordinator unlocks the intention according to the intention unlocking instruction.
6. The method of claim 5, further comprising:
when the coordinator does not receive the intention unlocking instruction within a first preset time period, verifying the intention every other second preset time period to obtain an assertion aiming at the intention;
the coordinator automatically unlocking the intent when the assertion is that an operation has been performed;
and when the assertion is still not executed after the verification of the preset times, the coordinator suspends the intention and sends a manual unlocking notice.
7. The method according to any one of claims 1-6, further comprising:
deploying a plurality of instances in the coordinator;
in the case where the service party submits multiple different intentions to the coordinator, the coordinator verifies the intentions, resulting in an assertion for the intentions, including:
and the coordinator verifies the plurality of different intentions by using different self-deployed examples to obtain a plurality of assertions.
8. An apparatus for interface idempotent calls, the apparatus comprising:
the intention packaging module is used for responding to an interface calling request sent by a calling party by a service party, packaging the interface calling request and related data of a called interface into an intention, and submitting the intention to the coordinator;
the assertion module is used for verifying the intention by the coordinator, obtaining an assertion aiming at the intention and sending the assertion to the service party;
and the service module is used for responding to the interface calling request by the service party according to the assertion.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method according to any of claims 1 to 7 are implemented when the computer program is executed by the processor.
CN202110573873.1A 2021-05-25 2021-05-25 Method, device, equipment and storage medium for calling interface with idempotent Active CN113177085B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110573873.1A CN113177085B (en) 2021-05-25 2021-05-25 Method, device, equipment and storage medium for calling interface with idempotent

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110573873.1A CN113177085B (en) 2021-05-25 2021-05-25 Method, device, equipment and storage medium for calling interface with idempotent

Publications (2)

Publication Number Publication Date
CN113177085A true CN113177085A (en) 2021-07-27
CN113177085B CN113177085B (en) 2023-04-14

Family

ID=76929977

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110573873.1A Active CN113177085B (en) 2021-05-25 2021-05-25 Method, device, equipment and storage medium for calling interface with idempotent

Country Status (1)

Country Link
CN (1) CN113177085B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116166681A (en) * 2023-04-25 2023-05-26 北京阿帕科蓝科技有限公司 Intersystem data calling method, intersystem data calling system and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885488A (en) * 2016-09-29 2018-04-06 微软技术许可有限责任公司 It is intended to and has intentional lock
CN111415146A (en) * 2020-06-08 2020-07-14 浙江口碑网络技术有限公司 Resource data processing method, device and equipment
CN111865970A (en) * 2020-07-17 2020-10-30 北京百度网讯科技有限公司 Method and apparatus for implementing interface idempotency
CN111984388A (en) * 2020-08-27 2020-11-24 深圳壹账通智能科技有限公司 Method, device and medium for coordinating data consistency in distributed transactions of cloud environment
CN112817995A (en) * 2021-02-22 2021-05-18 北京奇艺世纪科技有限公司 Data processing method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885488A (en) * 2016-09-29 2018-04-06 微软技术许可有限责任公司 It is intended to and has intentional lock
CN111415146A (en) * 2020-06-08 2020-07-14 浙江口碑网络技术有限公司 Resource data processing method, device and equipment
CN111865970A (en) * 2020-07-17 2020-10-30 北京百度网讯科技有限公司 Method and apparatus for implementing interface idempotency
CN111984388A (en) * 2020-08-27 2020-11-24 深圳壹账通智能科技有限公司 Method, device and medium for coordinating data consistency in distributed transactions of cloud environment
CN112817995A (en) * 2021-02-22 2021-05-18 北京奇艺世纪科技有限公司 Data processing method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116166681A (en) * 2023-04-25 2023-05-26 北京阿帕科蓝科技有限公司 Intersystem data calling method, intersystem data calling system and storage medium

Also Published As

Publication number Publication date
CN113177085B (en) 2023-04-14

Similar Documents

Publication Publication Date Title
US10409711B2 (en) Automatically running tests against WEB APIs based on specifications
CN111163129B (en) Resource processing method and device based on cross-link network
US20130246864A1 (en) Method for native program to inherit same transaction context when invoked by primary program running in separate environment
WO2022134186A1 (en) Smart contract calling method and apparatus for blockchains, server, and storage medium
WO2013091195A1 (en) Transaction processing method, device and system in distributed system
CN113177085B (en) Method, device, equipment and storage medium for calling interface with idempotent
CN110609755A (en) Message processing method, device, equipment and medium for cross-block chain node
CN113722114A (en) Data service processing method and device, computing equipment and storage medium
CN111259368A (en) Method and equipment for logging in system
CN107172112B (en) Computer file transmission method and device
CN110619204A (en) Invitation code generation method and device, terminal equipment and storage medium
CN113282436A (en) Event processing method, device, equipment and storage medium
CN110889108B (en) spark task submitting method and device and server
CN111143041B (en) Data consistency method, distributed coordinator and central coordinator
CN110347659B (en) Data processing method and device and transaction data processing method and device
CN109558254B (en) Asynchronous callback method, system, device and computer readable storage medium
CN106843917B (en) Driver loading method and device
CN111638939A (en) Management system and method for application life cycle of Kubernetes container platform
CN107589970B (en) Plug-in calling method and device
CN111191216B (en) OFD signature client with JAVA interface and method and system for signature verification
CN114924783A (en) Interface calling method, device, equipment and storage medium of application program
CN112738181B (en) Method, device and server for cluster external IP access
CN107463438B (en) Information processing method, device and system for multi-Openstack environment
CN113626524A (en) Data processing method and device and data checking system
KR101351867B1 (en) Method of handling step execution result in software and application control management object

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
GR01 Patent grant
GR01 Patent grant