CN111158923B - Interface calling method and device, electronic equipment and storage medium - Google Patents

Interface calling method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111158923B
CN111158923B CN201911424430.5A CN201911424430A CN111158923B CN 111158923 B CN111158923 B CN 111158923B CN 201911424430 A CN201911424430 A CN 201911424430A CN 111158923 B CN111158923 B CN 111158923B
Authority
CN
China
Prior art keywords
asynchronous
request
synchronous
processing system
synchronous request
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.)
Active
Application number
CN201911424430.5A
Other languages
Chinese (zh)
Other versions
CN111158923A (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.)
Shenzhen Intellifusion Technologies Co Ltd
Original Assignee
Shenzhen Intellifusion Technologies 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 Intellifusion Technologies Co Ltd filed Critical Shenzhen Intellifusion Technologies Co Ltd
Priority to CN201911424430.5A priority Critical patent/CN111158923B/en
Publication of CN111158923A publication Critical patent/CN111158923A/en
Application granted granted Critical
Publication of CN111158923B publication Critical patent/CN111158923B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application provides an interface calling method, an interface calling device, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving a synchronization request initiated by a client and forwarded by a synchronization interface; adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal, wherein the asynchronous waiting signal comprises the context information of the synchronous request; acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring the context information from the asynchronous waiting signal, and synchronizing the context information; and returning the processing result to the client through the synchronous interface. The embodiment of the application is beneficial to solving the problem of contradiction between synchronous interface and asynchronous interface call based on service.

Description

Interface calling method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of interface calling technologies, and in particular, to an interface calling method, an apparatus, an electronic device, and a storage medium.
Background
In a product system, the requirements of the different components for a synchronous interface and an asynchronous interface are quite different, and the parts close to the user tend to be synchronous interfaces, for example: the hypertext transfer protocol based Restful (a design style and development style of web applications) specification interfaces, while the portions near the bottom layer tend to be asynchronous interfaces, such as: a register interface on the processor. With the popularization of service, more and more bottom functions in system software are provided through service, and different from the interface provision of a software development kit, the provision form of the service interface is synchronous, and the form of bottom calculation is asynchronous, so that the call of two interfaces in the system is contradictory.
Disclosure of Invention
In view of the above problems, the present application provides an interface calling method, an apparatus, an electronic device, and a storage medium, which are favorable for solving the problem of contradiction between synchronous interface and asynchronous interface calling based on service.
To achieve the above object, a first aspect of an embodiment of the present application provides an interface calling method, including:
receiving a synchronization request initiated by a client and forwarded by a synchronization interface;
adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal, wherein the asynchronous waiting signal comprises the context information of the synchronous request;
acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring the context information from the asynchronous waiting signal, and synchronizing the context information;
and returning the processing result to the client through the synchronous interface.
In one possible implementation manner, the issuing the synchronous request to the asynchronous processing system includes:
detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed;
The generating an asynchronous wait signal includes:
generating a target request identifier of the synchronous request;
and generating an asynchronous waiting signal of the synchronous request according to the target request identifier.
In a possible implementation manner, the obtaining the processing result of the synchronous request reported by the asynchronous processing system includes:
receiving a target data block reported by the asynchronous processing system under the condition that the asynchronous processing system triggers a data completion signal, and analyzing the target data block to obtain the target request identification; the target data block is a partial processing result of the synchronous request;
acquiring a target cache block corresponding to the target request identifier from an asynchronous result cache; the asynchronous result cache comprises a plurality of cache blocks, and each cache block comprises a request identifier, a completion degree identifier for processing a synchronous request corresponding to the request identifier by the asynchronous processing system, a data block and an index of the data block;
storing the target data block in the target cache block, and analyzing the target data block to obtain an index of the target data block;
and counting the completion degree identification in the target cache block according to the index of the target data block, if the completion degree identification reaches a completion degree threshold value, obtaining the processing result, and triggering a collection completion signal of the processing result.
In one possible implementation, before the context information is obtained from the asynchronous wait signal and the context information is synchronized, the method further includes:
under the condition of triggering a collection completion signal of the processing result, acquiring the target request identifier carried by the collection completion signal;
and acquiring the asynchronous waiting signal from an asynchronous waiting signal queue according to the target request identification.
In one possible embodiment, the method further comprises:
when each preset time period of the pre-initialized timer is finished, detecting whether the cache queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one possible embodiment, the method further comprises:
under the condition of triggering a collection completion signal of the processing result, detecting whether the buffer queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
Under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one possible implementation, after generating the asynchronous wait signal, the method further comprises:
initializing the semaphore of the asynchronous wait signal;
and storing the context information in the asynchronous waiting signal.
A second aspect of the embodiments of the present application provides an interface calling device, including:
the synchronous request acquisition module is used for receiving a synchronous request initiated by the client and forwarded by the synchronous interface;
the synchronous-asynchronous conversion scheduling module is used for adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system and generating an asynchronous waiting signal, wherein the asynchronous waiting signal comprises the context information of the synchronous request;
the synchronous-asynchronous conversion scheduling module is further used for obtaining a processing result of processing the synchronous request, reported by the asynchronous processing system, and obtaining the context information from the asynchronous waiting signal, and synchronizing the context information;
And the asynchronous result return module is used for returning the processing result to the client through the synchronous interface.
A third aspect of embodiments of the present application provides an electronic device, including: the interface calling method comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the steps in the interface calling method when executing the computer program.
A fourth aspect of the present embodiment provides a computer readable storage medium having a computer program stored thereon, the computer program implementing the steps in the interface calling method described above when executed by a processor.
The scheme of the application at least comprises the following beneficial effects: it can be seen that, compared with the prior art, the synchronization request initiated by the client is forwarded by receiving the synchronization interface; adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal; acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring context information from the asynchronous waiting signal, and synchronizing the context information; and returning the processing result to the client through the synchronous interface. Therefore, when the server receives the synchronous request and returns the processing result, the synchronous request is realized through the synchronous interface, the usability and universality requirements of the product system are met, meanwhile, the synchronous request is issued to the asynchronous processing system for processing through synchronous-asynchronous conversion scheduling in the server, and the processing result reported by the asynchronous processing system is synchronously returned, so that the asynchronous management is realized in the server, the bottom layer resources are fully utilized, and the problem of contradiction between synchronous interface and asynchronous interface call based on service is solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1A is a schematic diagram of an application architecture according to an embodiment of the present application;
FIG. 1B is a schematic diagram of an internal call of a server according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of an interface calling method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a synchronous request buffer queue according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of an asynchronous wait signal queue according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of an asynchronous result cache according to an embodiment of the present disclosure;
FIG. 6 is a flowchart of another method for calling an interface according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an interface calling device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
The terms "comprising" and "having" and any variations thereof, as used in the specification, claims and drawings, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. Furthermore, the terms "first," "second," and "third," etc. are used for distinguishing between different objects and not for describing a particular sequential order.
The network system architecture to which the schemes of embodiments of the present application may be applied is first described by way of example with reference to the accompanying drawings. Referring to fig. 1A, fig. 1A is an application architecture diagram provided in an embodiment of the present application, where the application architecture is shown in fig. 1A and mainly includes a client and a server, and the client and the server mainly interact through a network. Specifically, the clients may be multiple, including but not limited to, desktop computers, notebook computers, smart phones, wearable devices, and personal digital assistants (Personal Digital Assistant, PDA), and the clients are mainly used for initiating a synchronization request for related processing or computation to the server, and synchronously receiving a processing result returned by the server. As shown in FIG. 1B, the service end can perform asynchronous management internally to realize synchronous-asynchronous conversion scheduling, synchronously processes a synchronous request instance initiated by the client through the synchronous domain and forwards the synchronous request instance to the synchronous-asynchronous conversion domain, the synchronous request is issued to an asynchronous processing system of the asynchronous domain by the conversion domain, the synchronous request is mainly managed by the synchronous-asynchronous conversion scheduling module in the conversion domain, asynchronous signal management and synchronous context management are performed on an asynchronous waiting signal queue, the asynchronous result reported by the asynchronous domain is collected and cached, the collected asynchronous result is returned to the synchronous domain, and the synchronous domain returns to the client. Based on the application architecture shown in fig. 1A, the following describes in detail the interface calling method provided in the embodiment of the present application with reference to other drawings.
Referring to fig. 2, fig. 2 is a flow chart of an interface calling method provided in an embodiment of the present application, as shown in fig. 2, including the following steps:
s21, receiving a synchronization request initiated by the client and forwarded by the synchronization interface.
In the embodiment of the application, the client initiates the synchronization request to the server, and the server receives the synchronization request through the synchronization interface, and because the synchronization domain has no actual processing capability, the synchronization request needs to be forwarded to the conversion domain of the back end.
S22, the synchronous request is added into a synchronous request cache queue, the synchronous request is issued to an asynchronous processing system, and an asynchronous waiting signal is generated, wherein the asynchronous waiting signal comprises the context information of the synchronous request.
In the embodiment of the application, after receiving the synchronous request, the conversion domain of the server triggers the synchronous request management flow by the synchronous request, adds the synchronous request into the synchronous request cache queue for caching, so that the processing capacity or throughput of the asynchronous processing system is matched with the synchronous request coming from the outside, a short-time buffering effect is achieved, and then the synchronous request is issued to the asynchronous processing system for asynchronous processing. In addition, the conversion domain also generates an asynchronous waiting and Pending signal of the synchronous request, and the synchronous request waits for the asynchronous waiting and Pending signal, so that the context information of the synchronous request naturally exists in the asynchronous waiting and Pending signal, namely, the thread state of synchronous request execution, the instruction stream of execution and the execution snapshot data when the context information enters the asynchronous waiting and Pending signal.
Specifically, when a synchronous Request is managed, the synchronous Request is defined as a Request (n), the synchronous Request (n) is added into a synchronous Request cache queue, and the scheduling operation of an asynchronous processing system is triggered: firstly judging whether an asynchronous processing system is in a preparation state, if so, taking out a synchronous Request (n) from a synchronous Request cache queue, issuing the synchronous Request (n) to the asynchronous processing system, and if not, exiting the current execution; generating a target Request ID (Identity document, identification) of the synchronous Request (n), generating an asynchronous wait Pending signal of the synchronous Request (n) based on the target Request ID, wherein the asynchronous wait Pending signal exists in an asynchronous wait Pending signal queue, initializing a semaphore, storing context information in the asynchronous wait Pending signal, suspending execution of the synchronous Request (n), waiting for the asynchronous processing system to process the synchronous Request (n) to be completed, and waiting for the next synchronous Request to trigger synchronous Request management.
As shown in fig. 3, the synchronization request buffer queue performs first-in-first-out buffer for the received synchronization request, that is, outputs the received synchronization request according to the order in which the synchronization request is entered, where each storage element of the synchronization request buffer queue includes a request ID and a request parameter (input required for completing the request), where the request ID is a long integer data, typically 64 bits, and 128 bits may also be used for the high frequency synchronization request, which is not limited herein.
As shown in fig. 4, the asynchronous wait Pending signal queue may manage generation, storage, transmission, etc. of asynchronous wait Pending signals, where there are multiple asynchronous wait Pending signals, each with a synchronous request uniquely corresponding thereto, for example: the asynchronous wait Pending signal N may be an asynchronous wait Pending signal for a synchronous request with a request ID of 1, the asynchronous wait Pending signal 2 may be an asynchronous wait Pending signal for a synchronous request with a request ID of 2, each of the asynchronous wait Pending signals is a Map storage structure, a key of Map is a request ID of each synchronous request, and in addition to the request ID, the asynchronous wait Pending signal further includes a semaphore for managing context information and context information, the context information is waiting in the semaphore when a corresponding synchronous processing request does not complete processing, and the context information waits for wakeup in the semaphore when a processing result collection completion signal corresponding to the synchronous processing request is received, and switching or synchronization of the context information is completed.
S23, obtaining a processing result of the synchronous request reported by the asynchronous processing system, obtaining the context information from the asynchronous waiting signal, and synchronizing the context information.
S24, returning the processing result to the client through the synchronous interface.
In the embodiment of the application, each time a part of the synchronous Request (n) is processed, the asynchronous processing system reports the processing result of the part in the form of a data block, and the conversion domain only needs to wait for a data completion signal. When the asynchronous processing system triggers a data completion signal, the conversion domain receives a target data block reported by the asynchronous processing system and analyzes the target data block to obtain a target Request ID, wherein the target data block is a partial processing result of the synchronous Request (n), and the target Request ID is a Request ID of the synchronous Request (n). The conversion domain obtains a target cache block corresponding to the target Request ID from the asynchronous result, where the target cache block is a block in the asynchronous result cache of a part or all of processing results of the synchronous Request (n), as shown in fig. 5, the asynchronous result cache is cached with a plurality of cache blocks of the synchronous Request, each cache block is in a Map storage structure, a key of the Map is still a Request ID, each cache block includes a completion degree identifier of the corresponding synchronous Request, a plurality of data blocks corresponding to the synchronous Request, and an Index of each data block, where the completion degree identifier may be expressed by a percentage, the Index of each data block indicates a part of the whole processing result of the corresponding synchronous Request, and when the completion degree identifier is 100%, it indicates that the synchronous Request corresponding to the cache block has been processed, and all data blocks in the cache block form the processing result of the corresponding synchronous Request. Storing the received target data block in a corresponding target cache block, analyzing the target data block to obtain an Index of the target data block, counting the completion degree identification in the target cache block according to the Index of the target data block, if the completion degree identification reaches 100% of the completion degree threshold value, indicating that the processing of the synchronous Request (n) is completed, collecting the processing result of the synchronous Request (n), triggering a result collecting completion signal, and waiting for a next data completion signal by a conversion domain to collect the processing result of the next synchronous Request.
In addition, when the collection completion signal of the processing result of the synchronous Request (n) is triggered, the conversion domain takes out the carried target Request ID from the collection completion signal, finds the asynchronous waiting and Pending signal of the synchronous Request (n) from the asynchronous waiting and Pending signal queue shown in fig. 4 according to the target Request ID, obtains the context information in the asynchronous waiting and Pending signal, switches the context information to complete synchronization, returns the processing result of the synchronous Request (n) through the synchronous interface of the synchronous domain, and the client obtains the processing result on the synchronous interface.
It can be seen that, in the embodiment of the present application, the synchronization request initiated by the client and forwarded by the synchronization interface is received; adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal; acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring context information from the asynchronous waiting signal, and synchronizing the context information; and returning the processing result to the client through the synchronous interface. Therefore, when the server receives the synchronous request and returns the processing result, the synchronous request is realized through the synchronous interface, the usability and universality requirements of the product system are met, meanwhile, the synchronous request is issued to the asynchronous processing system for processing through synchronous-asynchronous conversion scheduling in the server, and the processing result reported by the asynchronous processing system is synchronously returned, so that the asynchronous management is realized in the server, the bottom layer resources are fully utilized, and the problem of contradiction between synchronous interface and asynchronous interface call based on service is solved.
Referring to fig. 6, fig. 6 is a flowchart of another method for calling an interface according to an embodiment of the present application, as shown in fig. 6, including the following steps:
s61, receiving a synchronization request initiated by a client and forwarded by a synchronization interface;
s62, adding the synchronous request into a synchronous request cache queue;
s63, detecting whether the asynchronous processing system is in a preparation state;
s64, under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out of the cache queue, and the synchronous request is issued to the asynchronous processing system;
s65, generating a target request identifier of the synchronous request, and generating an asynchronous waiting signal of the synchronous request according to the target request identifier, wherein the asynchronous waiting signal comprises context information of the synchronous request;
s66, obtaining a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and obtaining the context information from the asynchronous waiting signal, and synchronizing the context information;
s67, returning the processing result to the client through the synchronous interface.
The steps S61-S67 are described in the embodiment shown in fig. 2, and the same or similar advantages can be achieved, which will not be repeated here.
In one possible embodiment, the method further comprises:
when each preset time period of the pre-initialized timer is finished, detecting whether the cache queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In this embodiment, when the system is initialized, a timer is initialized, and in addition to newly receiving a synchronization request in the conversion domain, the timer triggers the synchronization request management process, and the timer also triggers the synchronization request management. The timer sets a timing period as T, detects whether the synchronous Request cache queue is empty when each T period is finished, if not, detects whether the asynchronous processing system is in a ready state, if so, takes out the synchronous Request (n) from the synchronous Request cache queue and sends the synchronous Request (n) to the asynchronous processing system, generates a target Request ID of the synchronous Request (n), generating an asynchronous waiting and routing signal of the synchronous Request (n), initializing a semaphore, storing context information in the asynchronous waiting and routing signal, suspending execution of the synchronous Request (n), waiting for the synchronous Request (n) to be processed by the asynchronous processing system, and returning to the step of detecting whether the asynchronous processing system is in a preparation state.
In one possible embodiment, the method further comprises:
under the condition of triggering a collection completion signal of the processing result, detecting whether the buffer queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In this embodiment of the present application, a collection completion signal of a processing result is triggered, which indicates that the asynchronous processing system is likely to be in a ready state again, and the switch domain will also enter a synchronous Request management flow, at this time, detect whether a synchronous Request buffer queue is empty, if not, detect whether the asynchronous processing system is in a ready state, if so, take out a synchronous Request (n) from the synchronous Request buffer queue and issue the synchronous Request to the asynchronous processing system, generate a target Request ID of the synchronous Request (n), generate an asynchronous wait Pending signal of the synchronous Request (n), initialize a semaphore, save context information in the asynchronous wait Pending signal, suspend execution of the synchronous Request (n), wait for the asynchronous processing system to process the synchronous Request (n) to complete, and return to the step of detecting whether the asynchronous processing system is in a ready state again.
The embodiment shown in fig. 6 adds a plurality of possible implementation manners on the basis of the embodiment shown in fig. 2, besides that the synchronous request can trigger synchronous request management, the timer and the collection completion signal of the processing result also trigger synchronous request management, and the state of the asynchronous processing system is detected in a plurality of manners, and the operation of issuing the synchronous request is executed whenever the asynchronous processing system is in a ready state, so that the bottom processing resource of the asynchronous processing system is favorably fully utilized.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an interface calling device according to an embodiment of the present application, and as shown in fig. 7, the device includes:
a synchronization request acquisition module 71, configured to receive a synchronization request initiated by a client and forwarded by a synchronization interface;
the synchronous-asynchronous conversion scheduling module 72 is configured to add the synchronous request to a synchronous request cache queue, issue the synchronous request to an asynchronous processing system, and generate an asynchronous wait signal, where the asynchronous wait signal includes context information of the synchronous request;
the synchronous-asynchronous conversion scheduling module 72 is further configured to obtain a processing result of processing the synchronous request reported by the asynchronous processing system, obtain the context information from the asynchronous waiting signal, and synchronize the context information;
An asynchronous result return module 73, configured to return the processing result to the client through the synchronous interface.
It can be seen that the interface calling device provided by the application receives the synchronization request initiated by the client and forwarded by the synchronization interface; adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal; acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring context information from the asynchronous waiting signal, and synchronizing the context information; and returning the processing result to the client through the synchronous interface. Therefore, when the server receives the synchronous request and returns the processing result, the synchronous request is realized through the synchronous interface, the usability and universality requirements of the product system are met, meanwhile, the synchronous request is issued to the asynchronous processing system for processing through synchronous-asynchronous conversion scheduling in the server, and the processing result reported by the asynchronous processing system is synchronously returned, so that the asynchronous management is realized in the server, the bottom layer resources are fully utilized, and the problem of contradiction between synchronous interface and asynchronous interface call based on service is solved.
In one example, in issuing the synchronous request to an asynchronous processing system, the homoasynchronous translation scheduling module 72 is specifically configured to:
detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed;
in generating the asynchronous wait signal, the asynchronization conversion scheduling module 72 is specifically configured to:
generating a target request identifier of the synchronous request;
and generating an asynchronous waiting signal of the synchronous request according to the target request identifier.
In one example, the same asynchronous conversion scheduling module 72 is specifically configured to:
receiving a target data block reported by the asynchronous processing system under the condition that the asynchronous processing system triggers a data completion signal, and analyzing the target data block to obtain the target request identification; the target data block is a partial processing result of the synchronous request;
acquiring a target cache block corresponding to the target request identifier from an asynchronous result cache; the asynchronous result cache comprises a plurality of cache blocks, and each cache block comprises a request identifier, a completion degree identifier for processing a synchronous request corresponding to the request identifier by the asynchronous processing system, a data block and an index of the data block;
Storing the target data block in the target cache block, and analyzing the target data block to obtain an index of the target data block;
and counting the completion degree identification in the target cache block according to the index of the target data block, if the completion degree identification reaches a completion degree threshold value, obtaining the processing result, and triggering a collection completion signal of the processing result.
In one example, the synchronous to asynchronous conversion scheduling module 72 is specifically further configured to:
under the condition of triggering a collection completion signal of the processing result, acquiring the target request identifier carried by the collection completion signal;
and acquiring the asynchronous waiting signal from an asynchronous waiting signal queue according to the target request identification.
In one example, the synchronous to asynchronous conversion scheduling module 72 is specifically further configured to:
when each preset time period of the pre-initialized timer is finished, detecting whether the cache queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one example, the synchronous to asynchronous conversion scheduling module 72 is specifically further configured to:
under the condition of triggering a collection completion signal of the processing result, detecting whether the buffer queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one example, the synchronous to asynchronous conversion scheduling module 72 is specifically further configured to:
initializing the semaphore of the asynchronous wait signal;
and storing the context information in the asynchronous waiting signal.
It should be noted that, each step in the interface calling methods shown in fig. 2 and fig. 6 may be executed by each unit module in the interface calling device provided in the embodiments of the present application, and may achieve the same or similar beneficial effects, for example: step S21 and step S61 may be implemented by the synchronization request acquisition module 71 in the interface calling device, for example: step S22 and step S63 may be implemented with the synchronous asynchronous transfer scheduling module 72 in the interface calling device, and so on. It should be noted that, the interface calling device provided in the embodiment of the present application may be applied in a product system interface calling scenario, and in particular, the interface calling device may be applied in a server, a computer, or other devices capable of performing interface calling.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application, as shown in fig. 8, including: a memory 81 for storing one or more computer programs; a processor 82 for calling the computer program stored in the memory 81 to execute the steps in the above-described interface calling method embodiment; a communication interface 83 for input and output, and the communication interface 83 may be one or more; it will be appreciated that the various parts of the electronic device communicate via a bus connection, respectively. The processor 82 is specifically configured to invoke the computer program to perform the following steps:
receiving a synchronization request initiated by a client and forwarded by a synchronization interface;
adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal, wherein the asynchronous waiting signal comprises the context information of the synchronous request;
acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring the context information from the asynchronous waiting signal, and synchronizing the context information;
and returning the processing result to the client through the synchronous interface.
In one possible implementation, the issuing of the synchronous request to the asynchronous processing system by the processor 82 includes:
detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed;
the processor 82 performs the generating of the asynchronous wait signal, including:
generating a target request identifier of the synchronous request;
and generating an asynchronous waiting signal of the synchronous request according to the target request identifier.
In one possible implementation, the processor 82 performs the obtaining the processing result reported by the asynchronous processing system to process the synchronous request, including:
receiving a target data block reported by the asynchronous processing system under the condition that the asynchronous processing system triggers a data completion signal, and analyzing the target data block to obtain the target request identification; the target data block is a partial processing result of the synchronous request;
acquiring a target cache block corresponding to the target request identifier from an asynchronous result cache; the asynchronous result cache comprises a plurality of cache blocks, and each cache block comprises a request identifier, a completion degree identifier for processing a synchronous request corresponding to the request identifier by the asynchronous processing system, a data block and an index of the data block;
Storing the target data block in the target cache block, and analyzing the target data block to obtain an index of the target data block;
and counting the completion degree identification in the target cache block according to the index of the target data block, if the completion degree identification reaches a completion degree threshold value, obtaining the processing result, and triggering a collection completion signal of the processing result.
In one possible implementation, before the context information is obtained from the asynchronous wait signal and synchronized, the processor 82 is further configured to:
under the condition of triggering a collection completion signal of the processing result, acquiring the target request identifier carried by the collection completion signal;
and acquiring the asynchronous waiting signal from an asynchronous waiting signal queue according to the target request identification.
In one possible implementation, the processor 82 is further configured to:
when each preset time period of the pre-initialized timer is finished, detecting whether the cache queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one possible implementation, the processor 82 is further configured to:
under the condition of triggering a collection completion signal of the processing result, detecting whether the buffer queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one possible implementation, after generating the asynchronous wait signal, the processor 82 is further configured to:
initializing the semaphore of the asynchronous wait signal;
and storing the context information in the asynchronous waiting signal.
The electronic device may be a computer, a notebook computer, a tablet computer, a palm computer, a server, a cloud server, or the like. The electronic device may include, but is not limited to, a memory 81, a processor 82, a communication interface 83. It will be appreciated by those skilled in the art that the schematic diagram is merely an example of an electronic device and is not limiting of an electronic device, and may include more or fewer components than shown, or certain components may be combined, or different components.
It should be noted that, since the steps in the above-mentioned interface calling method are implemented when the processor 82 of the electronic device executes the computer program, the embodiments of the above-mentioned interface calling method are all applicable to the electronic device, and all achieve the same or similar beneficial effects.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes the steps in the interface calling method when being executed by a processor.
In particular, the computer program when executed by the processor performs the steps of:
receiving a synchronization request initiated by a client and forwarded by a synchronization interface;
adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal, wherein the asynchronous waiting signal comprises the context information of the synchronous request;
acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring the context information from the asynchronous waiting signal, and synchronizing the context information;
and returning the processing result to the client through the synchronous interface.
In one example, the computer program when executed by the processor further performs the steps of: detecting whether the asynchronous processing system is in a ready state; under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed;
the computer program when executed by the processor further performs the steps of: generating a target request identifier of the synchronous request; and generating an asynchronous waiting signal of the synchronous request according to the target request identifier.
In one example, the computer program when executed by the processor further performs the steps of: receiving a target data block reported by the asynchronous processing system under the condition that the asynchronous processing system triggers a data completion signal, and analyzing the target data block to obtain the target request identification; the target data block is a partial processing result of the synchronous request; acquiring a target cache block corresponding to the target request identifier from an asynchronous result cache; the asynchronous result cache comprises a plurality of cache blocks, and each cache block comprises a request identifier, a completion degree identifier for processing a synchronous request corresponding to the request identifier by the asynchronous processing system, a data block and an index of the data block; storing the target data block in the target cache block, and analyzing the target data block to obtain an index of the target data block; and counting the completion degree identification in the target cache block according to the index of the target data block, if the completion degree identification reaches a completion degree threshold value, obtaining the processing result, and triggering a collection completion signal of the processing result.
In one example, the computer program when executed by the processor further performs the steps of:
under the condition of triggering a collection completion signal of the processing result, acquiring the target request identifier carried by the collection completion signal; and acquiring the asynchronous waiting signal from an asynchronous waiting signal queue according to the target request identification.
In one example, the computer program when executed by the processor further performs the steps of: when each preset time period of the pre-initialized timer is finished, detecting whether the cache queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state; under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one example, the computer program when executed by the processor further performs the steps of:
under the condition of triggering a collection completion signal of the processing result, detecting whether the buffer queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
Under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
In one example, the computer program when executed by the processor further performs the steps of: initializing the semaphore of the asynchronous wait signal; and storing the context information in the asynchronous waiting signal.
The computer program of the computer readable storage medium may include, for example, computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth.
It should be noted that, since the steps in the above-mentioned interface calling method are implemented when the computer program of the computer readable storage medium is executed by the processor, all embodiments of the above-mentioned interface calling method are applicable to the computer readable storage medium, and the same or similar beneficial effects can be achieved.
The foregoing has outlined rather broadly the more detailed description of embodiments of the present application, wherein specific examples are provided herein to illustrate the principles and embodiments of the present application, the above examples being provided solely to assist in the understanding of the methods of the present application and the core ideas thereof; meanwhile, as those skilled in the art will have modifications in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. An interface calling method, the method comprising:
receiving a synchronization request initiated by a client and forwarded by a synchronization interface;
adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system, and generating an asynchronous waiting signal, wherein the asynchronous waiting signal comprises the context information of the synchronous request;
acquiring a processing result of processing the synchronous request, which is reported by the asynchronous processing system, and acquiring the context information from the asynchronous waiting signal, and synchronizing the context information;
and returning the processing result to the client through the synchronous interface.
2. The method of claim 1, wherein issuing the synchronous request to an asynchronous processing system comprises:
detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed;
the generating an asynchronous wait signal includes:
generating a target request identifier of the synchronous request;
and generating an asynchronous waiting signal of the synchronous request according to the target request identifier.
3. The method according to claim 2, wherein the obtaining the processing result reported by the asynchronous processing system for processing the synchronous request includes:
receiving a target data block reported by the asynchronous processing system under the condition that the asynchronous processing system triggers a data completion signal, and analyzing the target data block to obtain the target request identification; the target data block is a partial processing result of the synchronous request;
acquiring a target cache block corresponding to the target request identifier from an asynchronous result cache; the asynchronous result cache comprises a plurality of cache blocks, and each cache block comprises a request identifier, a completion degree identifier for processing a synchronous request corresponding to the request identifier by the asynchronous processing system, a data block and an index of the data block;
Storing the target data block in the target cache block, and analyzing the target data block to obtain an index of the target data block;
and counting the completion degree identification in the target cache block according to the index of the target data block, if the completion degree identification reaches a completion degree threshold value, obtaining the processing result, and triggering a collection completion signal of the processing result.
4. A method according to claim 3, wherein prior to obtaining the context information from the asynchronous wait signal and synchronizing the context information, the method further comprises:
under the condition of triggering a collection completion signal of the processing result, acquiring the target request identifier carried by the collection completion signal;
and acquiring the asynchronous waiting signal from an asynchronous waiting signal queue according to the target request identification.
5. The method according to claim 1, wherein the method further comprises:
when each preset time period of the pre-initialized timer is finished, detecting whether the cache queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
6. A method according to claim 3, characterized in that the method further comprises:
under the condition of triggering a collection completion signal of the processing result, detecting whether the buffer queue is empty, and if not, detecting whether the asynchronous processing system is in a ready state;
under the condition that the asynchronous processing system is in a ready state, the synchronous request is taken out from the cache queue, and the operation of issuing the synchronous request to the asynchronous processing system is executed; and in the case that the asynchronous processing system is not in a ready state, exiting the current execution.
7. The method of claim 1, wherein after generating the asynchronous wait signal, the method further comprises:
initializing the semaphore of the asynchronous wait signal;
and storing the context information in the asynchronous waiting signal.
8. An interface calling device, the device comprising:
the synchronous request acquisition module is used for receiving a synchronous request initiated by the client and forwarded by the synchronous interface;
the synchronous-asynchronous conversion scheduling module is used for adding the synchronous request into a synchronous request cache queue, issuing the synchronous request to an asynchronous processing system and generating an asynchronous waiting signal, wherein the asynchronous waiting signal comprises the context information of the synchronous request;
The synchronous-asynchronous conversion scheduling module is further used for obtaining a processing result of processing the synchronous request, reported by the asynchronous processing system, and obtaining the context information from the asynchronous waiting signal, and synchronizing the context information;
and the asynchronous result return module is used for returning the processing result to the client through the synchronous interface.
9. An electronic device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, the processor implementing the steps in the interface invocation method of any of claims 1 to 7 when the computer program is executed by the processor.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the interface invocation method of any of claims 1 to 7.
CN201911424430.5A 2019-12-30 2019-12-30 Interface calling method and device, electronic equipment and storage medium Active CN111158923B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911424430.5A CN111158923B (en) 2019-12-30 2019-12-30 Interface calling method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911424430.5A CN111158923B (en) 2019-12-30 2019-12-30 Interface calling method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111158923A CN111158923A (en) 2020-05-15
CN111158923B true CN111158923B (en) 2023-05-12

Family

ID=70560665

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911424430.5A Active CN111158923B (en) 2019-12-30 2019-12-30 Interface calling method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111158923B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1790260A (en) * 2004-12-15 2006-06-21 国际商业机器公司 System and method for generating asynchronous interfaces and methods from synchronous interfaces and methods
CN1933454A (en) * 2005-09-13 2007-03-21 中兴通讯股份有限公司 Synchronous information interface realizing method based on JAVA information service
CN107301444A (en) * 2017-05-25 2017-10-27 北京大学 A kind of ultrahigh frequency RFID coding circuit
CN108694146A (en) * 2017-04-11 2018-10-23 华大半导体有限公司 A kind of asynchronous/synchronous interface circuit

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1790260A (en) * 2004-12-15 2006-06-21 国际商业机器公司 System and method for generating asynchronous interfaces and methods from synchronous interfaces and methods
CN1933454A (en) * 2005-09-13 2007-03-21 中兴通讯股份有限公司 Synchronous information interface realizing method based on JAVA information service
CN108694146A (en) * 2017-04-11 2018-10-23 华大半导体有限公司 A kind of asynchronous/synchronous interface circuit
CN107301444A (en) * 2017-05-25 2017-10-27 北京大学 A kind of ultrahigh frequency RFID coding circuit

Also Published As

Publication number Publication date
CN111158923A (en) 2020-05-15

Similar Documents

Publication Publication Date Title
CN107798108B (en) Asynchronous task query method and device
CN106407201B (en) Data processing method and device and computer readable storage medium
CN110569252B (en) Data processing system and method
CN102801737B (en) A kind of asynchronous network communication means and device
WO2014206289A1 (en) Method and apparatus for outputting log information
CN113687964B (en) Data processing method, device, electronic equipment, storage medium and program product
CN109885535A (en) A kind of method and relevant apparatus of file storage
CN114564435A (en) Inter-core communication method, device and medium for heterogeneous multi-core chip
Mealha et al. Data replication on the cloud/edge
CN114327857A (en) Operation data processing method and device, computer equipment and storage medium
CN110928732A (en) Server cluster performance sampling analysis method and device and electronic equipment
CN111158923B (en) Interface calling method and device, electronic equipment and storage medium
CN110955461B (en) Processing method, device, system, server and storage medium for computing task
CN111209263A (en) Data storage method, device, equipment and storage medium
CN112311619B (en) Network message delay detection method and device and electronic equipment
CN110489219A (en) A kind of method, apparatus, medium and the electronic equipment of scheduling feature object
CN112910855B (en) Sample message processing method and device
CN111177109A (en) Method and device for deleting overdue key
CN114595080A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN114281504A (en) Task scheduling method and device, electronic equipment and computer readable medium
Shaojun et al. Dynamic bandwidth allocation mechanism with parallel and switching for FC-AE-1553 network
Jiang et al. Fast distributed simulation of sensor networks using optimistic synchronization
Ghanbarian et al. On the Performance of Large Loss Systems with Adaptive Multiserver Jobs
CN112559469A (en) Data synchronization method and device
CN113742376A (en) Data synchronization method, first server and data synchronization system

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