CN116680330A - Interface calling method, device, equipment and storage medium - Google Patents
Interface calling method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN116680330A CN116680330A CN202310652662.6A CN202310652662A CN116680330A CN 116680330 A CN116680330 A CN 116680330A CN 202310652662 A CN202310652662 A CN 202310652662A CN 116680330 A CN116680330 A CN 116680330A
- Authority
- CN
- China
- Prior art keywords
- interface
- current
- application program
- calling
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 230000008569 process Effects 0.000 claims description 7
- 238000004590 computer program Methods 0.000 claims description 4
- 230000004044 response Effects 0.000 abstract description 5
- 238000010586 diagram Methods 0.000 description 7
- 230000003287 optical effect Effects 0.000 description 6
- 230000001360 synchronised effect Effects 0.000 description 6
- 230000008901 benefit Effects 0.000 description 2
- 238000009530 blood pressure measurement Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 238000003672 processing method Methods 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 241000283973 Oryctolagus cuniculus Species 0.000 description 1
- 230000006978 adaptation Effects 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Stored Programmes (AREA)
Abstract
The embodiment of the invention discloses an interface calling method, an interface calling device, interface calling equipment and a storage medium, and relates to the field of computers, wherein the method comprises the following steps: acquiring the calling times of a current first application program to a current first interface corresponding to the current first application program; under the condition that the calling times do not accord with the current calling times conditions corresponding to the current first interfaces, determining a target first interface from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces; switching the current first application program from the current first interface to the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations. By adopting the technical scheme of the embodiment of the invention, the response speed of each first interface to each matched first application program can be ensured on the whole, and the utilization rate of the same data resources stored in each storage position can be improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to an interface calling method, an interface calling device, interface calling equipment and a storage medium.
Background
As business systems become more complex, their adaptation scenarios become more and more, so too will the amount of data. In the initial use period of the service system, the data resources are stored in the main database, and along with the use of the system, some isomerism is performed on part or all of the data in the main database, such as isomerism to a search engine, a cache or other slave databases, but in terms of data accuracy, the data in the main database is the most accurate, other isomerism storage has a certain delay, and different storage positions have differences in external query performance.
In the prior art, a data interface capable of accessing a data resource of a corresponding storage position is set, and each interface is matched with a corresponding application program, so that the application program accesses the data resource of the corresponding storage position through the corresponding interface.
However, in the practice of the present invention, it has been found that at least the following problems exist in the prior art: since the call volume of each application program to the data interface is not constant, the situation that the data interface is utilized unevenly occurs.
Disclosure of Invention
The embodiment of the invention provides an interface calling method, which aims to solve the problem of unbalanced utilization of a data interface in the prior art.
In a first aspect, an embodiment of the present invention provides an interface calling method, where the method includes:
acquiring the calling times of a current first application program to a current first interface corresponding to the current first application program;
under the condition that the calling times do not accord with the current calling times conditions corresponding to the current first interfaces, determining a target first interface from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces;
switching the current first application program from the current first interface to the target first interface so that the current first application program accesses a data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
In a second aspect, an embodiment of the present invention further provides an interface calling device, where the device includes:
the calling number determining module is used for obtaining the calling number of the current first interface corresponding to the current first application program by the current first application program;
the interface determining module is used for determining a target first interface from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces under the condition that the calling times do not accord with the current calling times conditions corresponding to the current first interface;
The switching module is used for switching the current first application program from the current first interface to the target first interface so that the current first application program accesses data resources by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
one or more processors;
a memory for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the interface invocation methods as provided by any of the embodiments of the invention.
In a fourth aspect, embodiments of the present invention further provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements an interface calling method as provided by any embodiment of the present invention.
The embodiments of the above invention have the following advantages or benefits:
because the different first interfaces are configured to be capable of accessing the same data resources of different storage positions, when the calling times of the current first application program to the corresponding current first interfaces do not accord with the current calling times conditions corresponding to the current first interfaces, determining a target first interface from the other first interfaces based on the calling times and the other calling times conditions respectively corresponding to the other first interfaces; switching the current first application program from the current first interface to the target first interface; the method and the device realize interface switching under the condition that the normal operation of the current first application program is not affected, can avoid the condition that one or more first interfaces crash or respond slowly due to the fact that the calling times are concurrent, and meanwhile, other first interfaces are idle or have less calling quantity, and realize the purpose of ensuring the response speed of each first interface to each matched first application program on the whole and improving the utilization rate of the same data resources stored in each storage position.
Drawings
FIG. 1 is a flow chart of an interface calling method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a further interface calling method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a further interface calling method according to an embodiment of the present invention;
FIG. 4 is a flowchart of a further interface calling method according to an embodiment of the present invention;
FIG. 5A is a schematic diagram of an interface calling device according to an embodiment of the present invention;
FIG. 5B is a schematic diagram of another interface calling device according to an embodiment of the present invention;
FIG. 5C is a schematic diagram of another interface calling device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Fig. 1 is a flowchart of a dialog processing method according to an embodiment of the present invention, where the embodiment is applicable to a case where, on the premise that different first interfaces can access the same data resources stored in different storage locations, the called first interfaces are automatically switched according to the running situation of the first application. The method may be performed by dialog processing means integrated in an electronic device, which means may be implemented in software and/or hardware. As shown in fig. 1, the method specifically includes the following steps:
S110, acquiring the calling times of the current first application program to the current first interface corresponding to the current first application program.
Wherein the first interface is configured as an interface having access to a corresponding storage location storing data resources required by the first application.
The different first interfaces are configured to have access to the same data resources stored in different storage locations. For example, the first interface A is configured to access data resources stored in the database, the first interface B is configured to access data resources stored in the cache, the first interface C is configured to access data resources stored in the set disk, and the first interface D is configured to access data resources stored in the distributed search engine.
In one embodiment, the data resources within the cache, the set-up disk, and the distributed search engine are from data resources of a database. For example, based on actual application requirements, data resources in the database are heterogeneous into a cache, a set disk, or a distributed search engine, so that there may be a delay in the update speed of the data resources in the cache, the set disk, and the distributed search engine compared to the update speed of the data resources in the database.
The present embodiment refers to an application program accessing a first interface as a first application program.
And acquiring the calling times of the current first application program to the corresponding current first interface in real time, or acquiring the calling times of the current first application program to the corresponding current first interface under the condition that each calling period is ended.
And S120, determining a target first interface from other first interfaces based on the calling times and other calling times conditions corresponding to the other first interfaces respectively under the condition that the calling times do not meet the current calling times conditions corresponding to the current first interface.
The calling time condition is a continuous calling time interval in one calling period or a total calling time in one calling period. Continuous calls refer to continuous and uninterrupted calls, or the time interval between two adjacent calls is smaller than a set threshold.
Each first interface is configured with a corresponding call number condition, and the call number of any application program on each first interface should meet the call number condition corresponding to the corresponding first interface.
If the calling times of the current first application program on the current first interface which is called currently accords with the calling times condition corresponding to the current first interface, the current first application program is controlled to call the current first interface continuously; if the calling times of the current first application program on the current first interface which is called currently do not accord with the calling times conditions corresponding to the current first interface, determining the target first interface of the current first application program from other first interfaces based on the calling times and other calling times conditions respectively corresponding to other first interfaces.
In one embodiment, the continuous call number interval configured by the first interface a is 0-N, the continuous call number interval configured by the first interface B is N-M, and the continuous call number interval configured by the first interface C is greater than M, where N is less than M, and both N and M are positive integers greater than 1.
In one embodiment, the call count condition corresponding to each first interface is determined based on pressure measurement data of the storage location corresponding to each first interface. The maximum value of the continuous calling time interval corresponding to each first interface is smaller than or equal to the acceptable maximum calling time, or the P times of the maximum value of the continuous calling time interval corresponding to each first interface is smaller than or equal to the acceptable maximum calling time, wherein P is the maximum number of first application programs which the first interface is allowed to access.
In one embodiment, a user may configure the call count condition corresponding to the interface identifier of each first interface in the first interface configuration file. The first interface configuration file is stored in a set storage location, such as a policy configuration database, and is clocked into the memory cache. The processor is configured to preferentially read the synchronized first interface configuration file from the memory cache so as to improve the file reading speed, and under the condition that the calling number condition of the required first interface does not exist in the first interface configuration file, the first interface configuration file is read from the set storage position so as to cope with the condition that the first interface configuration file is not synchronized timely or the first interface configuration file in the memory cache fails, thereby ensuring the running stability of the system. In this embodiment, the processor is configured to trigger the operation of synchronizing the first interface configuration file from the set storage location, i.e. the operation of synchronizing the first interface configuration file in the set storage location to the first interface configuration file in the memory cache.
S120, switching the current first application program from the current first interface to the target first interface so that the current first application program accesses the data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
And switching the current first application program from the current first interface to the target first interface so as to provide access service of the data resource for the current first application program by the current first interface. Because the different first interfaces are configured to access the same data resources of different storage locations, the normal operation of the current first application program is not affected by switching the current first application program from the current first interface to the target first interface.
From the perspective of each first application program, the target first interface can meet the data resource access requirement of the current first application program because the calling times are matched with the calling times corresponding to the target first interface; in the whole system, the target first interfaces corresponding to the first application programs are determined by matching the calling times of the first application programs to the first interfaces with the calling times corresponding to the first interfaces, so that the utilization rate of system data resources can be improved, the situation that some first interfaces are accessed in a binding way and some first interfaces are not accessed by the application programs or the calling times of the application programs to the first interfaces are less is prevented.
According to the technical scheme of the interface calling method provided by the embodiment of the invention, as different first interfaces are configured to be capable of accessing the same data resources of different storage positions, when the calling times of the current first application program to the corresponding current first interfaces do not accord with the current calling times conditions corresponding to the current first interfaces, the target first interface is determined from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces; switching the current first application program from the current first interface to the target first interface; the method and the device realize interface switching under the condition that the normal operation of the current first application program is not affected, can avoid the condition that one or more first interfaces crash or respond slowly due to the fact that the calling times are concurrent, and meanwhile, other first interfaces are idle or have less calling quantity, and realize the purpose of ensuring the response speed of each first interface to each matched first application program on the whole and improving the utilization rate of the same data resources stored in each storage position.
Fig. 2 is a flowchart of yet another interface calling method according to an embodiment of the present invention, where an interface allocation flow is added to the foregoing embodiment. As shown in fig. 2, the method includes:
S2001, responding to an interface calling instruction of a current first application program to a second interface, and determining an initial first interface identifier corresponding to the current first application program according to a corresponding relation between application identifiers of the application programs and first interface identifiers, wherein the second interface corresponds to at least two callable first interfaces and is configured as a front interface of the first interfaces.
The second interface is configured as a front-end interface of the first interface, i.e. a query interface. Any application, when accessing the required data resources through a first interface, does not directly access a certain first interface, but first accesses the second interface. The processor monitors the access condition of the second interface in real time, queries the second interface configuration file from the cache under the condition that any interface call instruction of the application program to the current second interface is intercepted, and determines the initial first interface identification corresponding to the current first application program according to the corresponding relation between the application identification of the application program in the second interface configuration file and each first interface identification. The second interface configuration file is a configuration file set for the second interface and is used for storing the corresponding relation between the application identifier of the application program and each first interface identifier.
In one embodiment, when a corresponding relation between an application identifier of an application program and each first interface identifier is created, acquiring a continuous calling frequency estimated value of each application program to the first interface in the running process; and determining the corresponding relation between each application program and each first interface according to the continuous calling times estimation value corresponding to each application program and the interface performance of each first interface (or the pressure measurement data of the storage position corresponding to each first interface). The continuous call number estimation value may be determined based on a historical call number of the application program to the first interface during the running process, or based on a historical call number of the application program to the first interface during the running process of the same period, where the same period may be the same period in a period, and the period may be in units of days, weeks, months, years, or the like.
The corresponding relation is obtained through the following steps:
and a1, responding to an interface calling instruction of the current first application program to the second interface, and inquiring the corresponding relation from the cached second interface configuration file according to the application identifier of the current first application program.
And a2, if the corresponding relation does not exist in the cached second interface configuration files, reading the second interface configuration files in the setting storage area through the setting policy query interface, and querying the corresponding relation from the second interface configuration files in the setting storage area.
The user configures the corresponding relation in a second interface configuration file in the setting storage area, and the system synchronizes the second interface configuration file to the cache at regular time. Therefore, for the first application program that first accesses the second interface, the corresponding relationship between the application identifier and the first interface identifier may not be synchronized into the cache, and at this time, the processor cannot query the corresponding relationship from the cached first interface configuration file, and needs to read the corresponding relationship corresponding to the first application program from the second interface configuration file in the set storage area.
S2002, taking the first interface corresponding to the initial first interface identifier as the current first interface corresponding to the current first application program.
And distributing the current first application program to the first interface corresponding to the initial first interface identifier, so that the first interface corresponding to the initial first interface identifier provides data access service for the current first application program.
And carrying out interface access allocation of the application program through the second interface, and preliminarily realizing balanced calling of each first interface through configuration information, so that the utilization rate of data resources stored in different storage positions is balanced.
S210, acquiring the calling times of the current first application program to the current first interface corresponding to the current first application program.
And S220, determining the target first interface from the other first interfaces based on the calling times and other calling times conditions corresponding to the other first interfaces respectively under the condition that the calling times do not meet the current calling times conditions corresponding to the current first interface.
S230, switching the current first application program from the current first interface to the target first interface so that the current first application program accesses the data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
According to the embodiment of the invention, the application identification of the first application program accessing the first interface is obtained by introducing the second interface, and the first interface is distributed for the first application program according to the corresponding relation between the application identification of the pre-established application program and the identifications of the first interface, so that the initial balanced access of the first interface is realized, and the subsequent switching times of the first interface are reduced.
Fig. 3 is a flowchart of yet another interface calling method according to an embodiment of the present invention. The step of increasing the call times of the asynchronous statistical interface based on the previous embodiment comprises the following steps:
s310, the calling times of the current first application program to the current first interface corresponding to the current first application program are obtained.
And S320, determining a target first interface from other first interfaces based on the calling times and other calling times conditions corresponding to the other first interfaces respectively under the condition that the calling times do not meet the current calling times conditions corresponding to the current first interface.
S330, switching the current first application program from the current first interface to the target first interface so that the current first application program accesses the data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
S340, asynchronously counting the calling times of the current first application program to the target first interface in the calling process of the current first application program to the target first interface.
This step aims at asynchronously counting the number of calls made by the first application to the matched first interface during the first application access to the matched first interface without affecting the first application access to the matched first interface, to provide data support for switching the first interface called by the first application.
In one embodiment, counting the number of calls to the target first interface by the current first application is accomplished by:
And b1, under the condition that the first application program is detected to call the target first interface for the first time, adding the application identifier of the current first application program and the interface identifier of the target first interface into a message queue.
The number of times of calling the matched first interface by each first application program is recorded based on the message queue, so that the program identification of the first application program and the interface identification of the matched first interface are added to the message queue under the condition that the first application program is detected to call the matched first interface for the first time.
The Message Queue (MQ) is an important component of the distributed system, and mainly solves the problems of application decoupling, asynchronous message and the like. The message queue may be ActiveMQ (active message queue), rabbitMQ (rabbit message queue), zeroMQ (zero message queue), kafka (Kaff card), metaMQ (Mittal message queue) or RocketMQ (deformation record message queue).
And b2, updating call data of the current first application program to the target first interface in the message queue in real time, wherein the call data comprise call times of the current first application program to the target first interface and the latest call time.
For any calling period, the message queue comprises the identification of the current first application program, the interface identification of the target first interface, the number of times of calling the target first interface by the current first application program and the latest calling time.
In one embodiment, when the current first application program is detected to call the target first interface, the call time is collected, the number of times of call in the message queue is increased by one, and the latest call time in the message queue is modified to be the call time.
In one embodiment, for any calling period, under the condition that the current first application program is detected to call the target first interface, collecting calling time, determining whether the difference between the calling time and the latest calling time in the message queue is within a set time threshold range, if so, adding one to the calling times in the message queue, and simultaneously modifying the latest calling time in the message queue to the calling time; if not, clearing the calling times in the message queue, and simultaneously modifying the latest calling time in the message queue to the calling time. This embodiment is adapted to the case where the call number condition is a continuous call number interval.
And b3, synchronizing the call data into the interface call data of the memory cache under the condition that the call data are changed so as to update the interface call data.
In one embodiment, whether the number of calls of each first application program in the message queue is changed is determined based on the set time interval, and if so, the call data of each first application program in the message queue is synchronized to the interface call data of the memory cache so as to update the interface call data. The processor can acquire the calling times of each first application program to the matched first interface by reading the interface calling data.
In one embodiment, whether the call times of the first application programs in the message queue are changed is determined based on the set time interval, and if so, the call data of the first application programs with the changed call times are synchronized to the interface call data of the memory cache so as to update the interface call data. Therefore, the processor can acquire the calling times of each first application program to the matched first interface by reading the interface calling data, and simultaneously can reduce the synchronous data quantity when the data is called synchronously each time, reduce the data processing quantity of the system and help to improve the running speed of the system.
According to the embodiment of the invention, the calling times of the first application program to the first interface matched with the first application program are asynchronously recorded in the process of calling the first interface of the first application program, so that the interface calling and the interface calling times statistics can be decoupled, and the running speed and the running stability of the system are improved.
Fig. 4 is a flowchart of yet another interface calling method provided by an embodiment of the present invention. This embodiment provides an overall workflow, as shown in fig. 4, the method comprising:
taking the example of the application program A obtaining the item parameter data, the application program is used for responding to the user operation instruction to display the item parameter data of the related items. When the application program A needs to acquire the article parameter data, accessing the second interface, intercepting an access request sent by the application program A to the second interface by the processor through the interceptor, and analyzing the access request to acquire an application identifier of the application program A; then, a second interface configuration file is obtained, and a first interface identifier corresponding to the application identifier is obtained from the second interface configuration file; then switching the application program A to a first interface corresponding to the first interface identifier so that the application program A obtains the article parameter data through the first interface; under the condition that the application program A starts to access the first interface is detected, asynchronously recording the calling times of the application program A to the first interface, and updating the corresponding calling times of the application program A in the interface calling data in the cache according to the calling times; the method comprises the steps that a first interface configuration file is obtained, and under the condition that the calling times do not meet the calling times conditions of interfaces corresponding to the first interface, an application program A is switched to another first interface corresponding to the calling times conditions matched with the calling times, so that the application program A obtains article parameter data through the first interface (namely the another first interface); and then returning to the step of asynchronously recording the number of calls made by application a to the first interface.
The embodiment determines the application identifier of the application program by intercepting an access request of the application program to access the second interface, and switches the application program from the second interface to a first interface according to the application identifier and the second interface configuration file; recording the calling times of the application program to the matched first interface in an asynchronous statistics mode; and determining whether the application program needs to switch the first interface or not according to the call times of the application program to the first interface and the call times of the interfaces corresponding to the first interfaces, and switching the application program to another first interface under the condition that the first interfaces need to be switched. For an application program, the embodiment provides access service of the same data resource for the application program uninterruptedly through allocation and switching of the first interface, so that the imperceptible switching of the first interface is realized, the application program only needs to access the second interface, the call balance degree of each first interface can be improved, and the resource utilization rate of each storage position is improved.
The following is an embodiment of a session processing device provided in the embodiment of the present invention, which belongs to the same inventive concept as the session processing method in the first embodiment, and details of the embodiment of the session processing device, which are not described in detail, may be referred to in the foregoing embodiments.
Fig. 5A is a schematic structural diagram of an apparatus according to an embodiment of the present invention. The device comprises:
a call number determining module 410, configured to obtain call number of a current first interface corresponding to a current first application program by the current first application program;
the interface determining module 420 is configured to determine, when the number of calls does not meet the current number of calls condition corresponding to the current first interface, a target first interface from the other first interfaces based on the number of calls and other number of calls conditions corresponding to the other first interfaces, respectively;
a switching module 430, configured to switch the current first application program from the current first interface to the target first interface, so that the current first application program accesses a data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
In one embodiment, as shown in fig. 5B, the apparatus further comprises:
a first interface identifier determining module 401, configured to determine an initial first interface identifier corresponding to the current first application program according to a correspondence between application identifiers of the current first application program and first interface identifiers, in response to an interface call instruction of the current first application program for a second interface, where the second interface corresponds to at least two callable first interfaces and is configured as a front interface of the first interfaces;
The interface allocation module 402 is configured to take the first interface corresponding to the initial first interface identifier as a current first interface corresponding to the current first application program.
In one embodiment, the first interface identifier determining module is configured to respond to an interface call instruction of the current first application program to the second interface, and query the corresponding relationship from the cached second interface configuration file according to the application identifier of the current first application program; and if the corresponding relation does not exist in the cache, reading a second interface configuration file in a set storage area through a set policy query interface, and querying the corresponding relation from the second interface configuration file.
In one embodiment, as shown in fig. 5C, the apparatus further comprises:
and the recording module 440 is configured to asynchronously count the number of times the current first application program calls the target first interface in the process of calling the target first interface by the current first application program.
In one embodiment, the recording module includes:
the identification adding unit is used for adding the application identification of the current first application program and the interface identification of the target first interface into a message queue under the condition that the current first application program is detected to call the current first interface for the first time;
The updating unit is used for updating the call data of the current first application program to the target first interface in the message queue in real time, wherein the call data comprises the call times of the current first application program to the target first interface and the latest call time;
and the synchronizing unit is used for synchronizing the call data into the interface call data of the memory cache under the condition that the call data are changed so as to update the interface call data.
In one embodiment, the different storage locations include at least two of a database, a cache, a set-up disk, and a distributed search engine.
In one embodiment, the call number condition is a continuous call number interval within one call cycle.
According to the technical scheme of the interface calling device, as different first interfaces are configured to be capable of accessing the same data resources of different storage positions, when the calling times of the current first application program to the corresponding current first interfaces do not accord with the current calling times conditions corresponding to the current first interfaces, the target first interface is determined from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces; switching the current first application program from the current first interface to the target first interface; the method and the device realize interface switching under the condition that the normal operation of the current first application program is not affected, can avoid the condition that one or more first interfaces crash or respond slowly due to the fact that the calling times are concurrent, and meanwhile, other first interfaces are idle or have less calling quantity, and realize the purpose of ensuring the response speed of each first interface to each matched first application program on the whole and improving the utilization rate of the same data resources stored in each storage position.
The interface calling device provided by the embodiment of the invention can execute the interface calling method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing any interface calling method.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. Fig. 6 shows a block diagram of an exemplary server 12 suitable for use in implementing embodiments of the present invention. The server 12 shown in fig. 6 is merely an example, and should not be construed as limiting the functionality and scope of use of embodiments of the present invention.
As shown in fig. 6, the server 12 is in the form of a general purpose computing device. The components of server 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, a bus 18 that connects the various system components, including the system memory 28 and the processing units 16.
Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, and a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Server 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by server 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache memory 32. The server 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 6, commonly referred to as a "hard disk drive"). Although not shown in fig. 6, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of the embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored in, for example, system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods of the embodiments described herein.
The server 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the server 12, and/or any devices (e.g., network card, modem, etc.) that enable the server 12 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. Also, the server 12 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, via a network adapter 20. As shown, network adapter 20 communicates with the other modules of server 12 via bus 18. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with server 12, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 16 executes various functional applications and data processing by running a program stored in the system memory 28, for example, implementing an interface calling method step provided in the first embodiment of the present invention, the method comprising:
acquiring the calling times of a current first application program to a current first interface corresponding to the current first application program;
under the condition that the calling times do not accord with the current calling times conditions corresponding to the current first interfaces, determining a target first interface from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces;
switching the current first application program from the current first interface to the target first interface so that the current first application program accesses a data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
Of course, those skilled in the art will understand that the processor may also implement the technical solution of the interface calling method provided by any embodiment of the present invention.
The present embodiment provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements an interface calling method step as provided by the foregoing embodiment of the present invention, the method comprising:
Acquiring the calling times of a current first application program to a current first interface corresponding to the current first application program;
under the condition that the calling times do not accord with the current calling times conditions corresponding to the current first interfaces, determining a target first interface from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces;
switching the current first application program from the current first interface to the target first interface so that the current first application program accesses a data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
It will be appreciated by those of ordinary skill in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be centralized on a single computing device, or distributed over a network of computing devices, or they may alternatively be implemented in program code executable by a computer device, such that they are stored in a memory device and executed by the computing device, or they may be separately fabricated as individual integrated circuit modules, or multiple modules or steps within them may be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.
Claims (10)
1. An interface calling method, the method comprising:
acquiring the calling times of a current first application program to a current first interface corresponding to the current first application program;
under the condition that the calling times do not accord with the current calling times conditions corresponding to the current first interfaces, determining a target first interface from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces;
switching the current first application program from the current first interface to the target first interface so that the current first application program accesses a data resource by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
2. The method of claim 1, wherein before the step of obtaining the number of calls of the current first application program to the current first interface corresponding to the current first application program, further comprises:
responding to an interface calling instruction of the current first application program to a second interface, and determining an initial first interface identifier corresponding to the current first application program according to a corresponding relation between application identifiers of the application program and first interface identifiers, wherein the second interface corresponds to at least two callable first interfaces and is configured as a front interface of the first interfaces;
And taking the first interface corresponding to the initial first interface identifier as the current first interface corresponding to the current first application program.
3. The method of claim 2, wherein the correspondence is obtained by:
responding to an interface calling instruction of the current first application program to the second interface, and inquiring the corresponding relation from a cached second interface configuration file according to the application identifier of the current first application program;
and if the corresponding relation does not exist in the cached second interface configuration files, reading the second interface configuration files in a setting storage area through a setting strategy query interface, and querying the corresponding relation from the second interface configuration files in the setting storage area.
4. The method as recited in claim 1, further comprising:
and asynchronously counting the calling times of the current first application program to the target first interface in the calling process of the current first application program to the target first interface.
5. The method according to claim 4, wherein asynchronously counting the number of calls made by the current first application to the target first interface during the call made by the current first application to the target first interface comprises:
Under the condition that the current first application program is detected to call the target first interface for the first time, adding an application identifier of the current first application program and an interface identifier of the target first interface into a message queue;
updating call data of the current first application program to the target first interface in the message queue in real time, wherein the call data comprises call times and latest call time of the current first application program to the target first interface;
and under the condition that the call data are changed, synchronizing the call data into interface call data of a memory cache so as to update the interface call data.
6. The method of claim 3, wherein the different storage locations comprise at least two of a database, a cache, a set-up disk, and a distributed search engine.
7. The method according to any one of claims 1-6, wherein the call count condition is a continuous call count interval within one call cycle.
8. An interface calling device, comprising:
the calling number determining module is used for obtaining the calling number of the current first interface corresponding to the current first application program by the current first application program;
The interface determining module is used for determining a target first interface from other first interfaces based on the calling times and other calling times conditions respectively corresponding to the other first interfaces under the condition that the calling times do not accord with the current calling times conditions corresponding to the current first interface;
the switching module is used for switching the current first application program from the current first interface to the target first interface so that the current first application program accesses data resources by calling the target first interface; wherein the different first interfaces are configured to access the same data resources of different storage locations.
9. An electronic device, the electronic device comprising:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, causes the one or more processors to implement the interface invocation method of any of claims 1-7.
10. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the interface invocation method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310652662.6A CN116680330A (en) | 2023-06-02 | 2023-06-02 | Interface calling method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310652662.6A CN116680330A (en) | 2023-06-02 | 2023-06-02 | Interface calling method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116680330A true CN116680330A (en) | 2023-09-01 |
Family
ID=87784876
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310652662.6A Pending CN116680330A (en) | 2023-06-02 | 2023-06-02 | Interface calling method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116680330A (en) |
-
2023
- 2023-06-02 CN CN202310652662.6A patent/CN116680330A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11146502B2 (en) | Method and apparatus for allocating resource | |
US10338958B1 (en) | Stream adapter for batch-oriented processing frameworks | |
US20060059228A1 (en) | Capturing and re-creating the state of a queue when migrating a session | |
CN111431757A (en) | Virtual network flow acquisition method and device | |
CN110119304B (en) | Interrupt processing method and device and server | |
US20160072909A1 (en) | Systems and methods for remote access to ims databases | |
CN108363741B (en) | Big data unified interface method, device, equipment and storage medium | |
CN108563776B (en) | Offline data acquisition method and system, server and storage medium | |
US7752225B2 (en) | Replication and mapping mechanism for recreating memory durations | |
CN116627333A (en) | Log caching method and device, electronic equipment and computer readable storage medium | |
CN111880909A (en) | Distributed data publishing method and device | |
US9893972B1 (en) | Managing I/O requests | |
US20230136226A1 (en) | Techniques for auto-tuning compute load resources | |
CN110750498B (en) | Object access method, device and storage medium | |
US10802874B1 (en) | Cloud agnostic task scheduler | |
CN107656999B (en) | Call history tracing method and device, electronic equipment and storage medium | |
CN116414534A (en) | Task scheduling method, device, integrated circuit, network equipment and storage medium | |
CN116680330A (en) | Interface calling method, device, equipment and storage medium | |
US20190384629A1 (en) | Dynamically determine the transaction coordinator in multitier hybrid transaction processing middleware systems | |
CN112035460A (en) | Identification distribution method, device, equipment and storage medium | |
CN110018782B (en) | Data reading/writing method and related device | |
US10579446B2 (en) | Per-request event detection to improve request-response latency | |
CN110704401A (en) | Data processing method and device, electronic equipment and storage medium | |
US8549537B2 (en) | Middleware bridge system and method | |
CN114338472A (en) | Capacity test method, device, equipment, medium and product of map server |
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 |