CN115202894A - Interface service calling method and device, computer equipment and storage medium - Google Patents

Interface service calling method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN115202894A
CN115202894A CN202110377885.7A CN202110377885A CN115202894A CN 115202894 A CN115202894 A CN 115202894A CN 202110377885 A CN202110377885 A CN 202110377885A CN 115202894 A CN115202894 A CN 115202894A
Authority
CN
China
Prior art keywords
service
quota
interface
identifier
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.)
Pending
Application number
CN202110377885.7A
Other languages
Chinese (zh)
Inventor
黎小为
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110377885.7A priority Critical patent/CN115202894A/en
Publication of CN115202894A publication Critical patent/CN115202894A/en
Pending legal-status Critical Current

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/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application relates to interface service calling of a gateway, and provides an interface service calling method, an interface service calling device, computer equipment and a storage medium. The method comprises the following steps: receiving an interface service calling request, and determining a corresponding service routing identifier according to the interface service calling request; acquiring a requester identifier corresponding to the interface service call request, and determining service quota mapping information according to the service routing identifier and the requester identifier; when the service quota corresponding to the service quota mapping information does not exist in the internal memory, accessing and synchronizing the service configuration data cached in the preset quota database; inquiring service configuration data according to the service quota mapping information; and feeding back a calling result prompt according to the query result. By adopting the method, quota management can be realized by only utilizing the service quota in the memory and the service configuration data in the quota database, and resources are saved.

Description

Interface service calling method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to an interface service invoking method and apparatus, a computer device, and a storage medium.
Background
With the development of computer technology, interface service calling technology has emerged. The interface service calling technology is to provide a service calling interface for a service buyer to call, and verify whether the service buyer has the authority of interface service calling in the interface service calling process, namely, perform quota management on the service buyer.
In the conventional technology, quota management is performed by adopting a quota management application including a client and a server, receiving request information of a service purchaser, calling the client to perform remaining quota calculation on a service which the service purchaser needs to use quota, and asynchronously sending the request information to a message queue, so that the server asynchronously counts the request information in the message queue.
However, the conventional method requires more machine resources to specially deploy the client, the server and the message queue, and also requires more technical cost and labor cost to maintain the middleware, which causes a problem of resource waste.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an interface service invoking method, an apparatus, a computer device and a storage medium capable of saving resources.
An interface service invocation method, the method comprising:
receiving an interface service calling request, and determining a corresponding service routing identifier according to the interface service calling request;
acquiring a requester identifier corresponding to the interface service calling request, and determining service quota mapping information according to the service routing identifier and the requester identifier;
when the service quota corresponding to the service quota mapping information does not exist in the internal memory, accessing and synchronizing the service configuration data cached in the preset quota database;
inquiring service configuration data according to the service quota mapping information;
and feeding back a calling result prompt according to the query result.
An interface service invocation apparatus, the apparatus comprising:
the monitoring module is used for receiving the interface service calling request and determining a corresponding service routing identifier according to the interface service calling request;
the processing module is used for acquiring a requester identifier corresponding to the interface service calling request and determining service quota mapping information according to the service routing identifier and the requester identifier;
the synchronization module is used for accessing and synchronizing the service configuration data cached in the preset quota database when the service quota corresponding to the service quota mapping information does not exist in the memory;
the query module is used for querying service configuration data according to the service quota mapping information;
and the deduction module is used for feeding back a calling result prompt according to the query result.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
receiving an interface service calling request, and determining a corresponding service routing identifier according to the interface service calling request;
acquiring a requester identifier corresponding to the interface service calling request, and determining service quota mapping information according to the service routing identifier and the requester identifier;
when the service quota corresponding to the service quota mapping information does not exist in the internal memory, accessing and synchronizing the service configuration data cached in the preset quota database;
inquiring service configuration data according to the service quota mapping information;
and feeding back a calling result prompt according to the query result.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
receiving an interface service calling request, and determining a corresponding service routing identifier according to the interface service calling request;
acquiring a requester identifier corresponding to the interface service call request, and determining service quota mapping information according to the service routing identifier and the requester identifier;
when the service quota corresponding to the service quota mapping information does not exist in the internal memory, accessing and synchronizing the service configuration data cached in the preset quota database;
inquiring service configuration data according to the service quota mapping information;
and feeding back a calling result prompt according to the query result.
According to the interface service calling method, the device, the computer equipment and the storage medium, the corresponding service routing identification is determined according to the interface service calling request, the requester identification is obtained, after the service quota mapping information is determined according to the service routing identification and the requester identification, whether the service quota corresponding to the service quota mapping information exists or not is inquired in the memory, if the service quota does not exist, the service configuration data cached in the preset quota database is accessed and synchronized, whether the service quota corresponding to the service quota mapping information exists or not is inquired in the synchronized service configuration data or not is inquired, and the calling result prompt is fed back according to the inquiring result, so that quota management can be realized only by using the service quota in the memory and the service configuration data in the quota database, excessive middleware does not exist, the middleware does not need to be maintained by more technical cost and labor cost, and resources can be saved.
Drawings
FIG. 1 is a diagram of an application environment for an interface service invocation method in one embodiment;
FIG. 2 is a flow diagram that illustrates a method for interface service invocation in one embodiment;
FIG. 3 is a diagram illustrating an interface service invocation method in one embodiment;
FIG. 4 is a diagram of an interface service invocation method in another embodiment;
FIG. 5 is a diagram illustrating an interface service invocation method in accordance with yet another embodiment;
FIG. 6 is a flowchart illustrating an interface service invocation method according to another embodiment;
FIG. 7 is a block diagram showing the structure of an interface service invocation means in one embodiment;
FIG. 8 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
The technical scheme can be applied to the technical field of cloud computing, wherein the cloud computing refers to a delivery and use mode of an IT infrastructure and refers to the mode that required resources are obtained through a network in an on-demand and easily-extensible mode; the broad cloud computing refers to a delivery and use mode of a service, and refers to obtaining a required service in an on-demand and easily-extensible manner through a network. Such services may be IT and software, internet related, or other services. The cloud Computing is a product of development and fusion of traditional computers and Network Technologies, such as Grid Computing (Grid Computing), distributed Computing (distributed Computing), parallel Computing (Parallel Computing), utility Computing (Utility Computing), network Storage (Network Storage Technologies), virtualization (Virtualization), load balancing (Load Balance), and the like. With the development of diversification of internet, real-time data stream, and connection devices, and the promotion of demands for search services, social networks, mobile commerce, open collaboration, and the like, cloud computing has been rapidly developed. Different from the prior parallel distributed computing, the generation of cloud computing can promote the revolutionary change of the whole internet mode and the enterprise management mode in concept.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
The interface service calling method provided by the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. When a user using the terminal 102 needs to call an interface service, the user sends an interface service call request to the server 104 through the terminal 102, the server 104 receives the interface service call request, determines a corresponding service routing identifier according to the interface service call request, acquires a requester identifier corresponding to the interface service call request, determines service quota mapping information according to the service routing identifier and the requester identifier, accesses and synchronizes service configuration data cached in a preset quota database when a service quota corresponding to the service quota mapping information does not exist in a memory, queries the service configuration data according to the service quota mapping information, and feeds back a call result to prompt the terminal 102 according to a query result. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, big data and artificial intelligence platform. The terminal may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a smart car coupler, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein. Wherein a server may be a node in a blockchain.
In one embodiment, as shown in fig. 2, an interface service invoking method is provided, which is described by taking the application of the method to the server in fig. 1 as an example, and includes the following steps:
step 202, receiving an interface service call request, and determining a corresponding service routing identifier according to the interface service call request.
The interface service calling request refers to a processing request sent by a requester needing interface service calling through a request service interface, and the request service interface refers to an interface for realizing communication between a terminal used by the requester and a server. The service route identifier is an identifier of a server that can provide a service corresponding to the interface service invocation request, and the service route is an address of the server that provides the corresponding service.
Specifically, the server monitors an interface service call request called by the interface service in real time, performs request processing according to the interface service call request when receiving the interface service call request, extracts a routing address from the interface service call request, and determines a service route and a service routing address of the server capable of providing the service corresponding to the interface service call request according to the routing address.
And step 204, acquiring a requester identifier corresponding to the interface service call request, and determining service quota mapping information according to the service routing identifier and the requester identifier.
The identifier of the requester is the identifier of the requester which sends the interface service invocation request. For example, the requestor identifier may specifically be a requestor account. The service quota mapping information refers to a query key for querying a service quota. For example, the service quota mapping information may specifically be combined information formed by a requestor identifier and a service route identifier, and the combined form may be the requestor identifier + the service route identifier.
Specifically, the request message of the interface service invocation request includes a requestor identifier, and after it is determined that a service routing identifier corresponding to the interface service invocation request exists, the server may extract the requestor identifier from the request message, and generate service quota mapping information according to the requestor identifier and the service routing identifier.
In step 206, when the service quota corresponding to the service quota mapping information does not exist in the memory, the service configuration data cached in the preset quota database is accessed and synchronized.
The service quota refers to the number of interface service calls purchased by the service requester, and when the service requester has a demand for interface service calls, service subscription is performed and the service quota is purchased. The service configuration data refers to a service quota data set of all the interface services which can be provided and is obtained after the service quota of all the gateways is deducted in a delayed synchronization mode, and the delayed synchronization mode refers to the fact that the gateways synchronize quota deduction results to a preset quota database within a preset delay range after the service quota deduction, so that the quota database updates service quota data corresponding to the quota deduction results in the service configuration data. The preset quota database refers to a preset database in which service configuration data are stored. For example, the quota database may be Redis.
Specifically, after the service quota mapping information is determined, the server queries whether a corresponding service quota exists in the memory according to the service quota mapping information, performs quota deduction when the corresponding service quota exists in the memory, feeds back an interface call success prompt, synchronizes a quota deduction result to the quota database, and forwards an interface service call request to a server side corresponding to the service routing identifier. When the corresponding service quota does not exist in the internal memory, the server accesses the preset quota database, sends a synchronization request to the preset quota database so as to synchronize service configuration data in the quota database, and further determines whether quota deduction can be performed according to the service configuration data.
And step 208, inquiring service configuration data according to the service quota mapping information.
Specifically, after synchronizing the service configuration data, the server may query the service configuration data according to the service quota mapping information, so as to determine whether a service quota corresponding to the service quota mapping information exists in the service configuration data. Further, the data storage form in the service configuration data may be service quota mapping information — service quota.
And step 210, feeding back a calling result prompt according to the query result.
The query result refers to a result of querying whether the service quota corresponding to the service quota mapping information exists in the service configuration data, and includes a result of existence and a result of nonexistence. The calling result prompt is used for prompting whether calling is successful or not, corresponds to the query result, and feeds back the interface calling success prompt when the query result is present and feeds back the quota use-up prompt when the query result is absent.
Specifically, the server feeds back a calling result prompt corresponding to the query result according to the query result. When the service configuration data has the service quota corresponding to the service quota mapping information, the quota deduction can be performed, the server can perform quota deduction, an interface call success prompt is fed back, a quota deduction result is synchronized to a quota database, the interface service call request is forwarded to the server side corresponding to the service routing identifier, when the service configuration data does not have the service quota corresponding to the service quota mapping information, the quota deduction cannot be performed, and the server can feed back a quota use-up prompt.
According to the interface service calling method, after the corresponding service routing identification is determined according to the interface service calling request and the requester identification is obtained, and the service quota mapping information is determined according to the service routing identification and the requester identification, whether a service quota corresponding to the service quota mapping information exists or not is inquired in the memory, if the service quota mapping information does not exist, the service configuration data cached in the preset quota database is accessed and synchronized, whether a service quota corresponding to the service quota mapping information exists or not is inquired in the synchronized service configuration data or not is inquired, and a calling result prompt is fed back according to the inquiring result, so that quota management can be realized only by using the service quota in the memory and the service configuration data in the quota database, excessive middleware does not exist, the middleware does not need to be maintained by more technical cost and manpower cost, and resources can be saved.
In one embodiment, receiving an interface service invocation request, and determining a corresponding service routing identifier according to the interface service invocation request includes:
receiving an interface service calling request, and extracting a routing address from a request message of the interface service calling request;
traversing preset routing configuration information according to the routing address;
and when the routing address hits a routing rule in the routing configuration information, determining the service route according to the routing rule, and determining a service route identifier corresponding to the service route.
The request message refers to a message sent to the server by the requester when initiating the interface service call request. The routing address refers to a service side address selected by the requester to provide interface service calls. The preset routing configuration information refers to the corresponding relation between the preset routing rule and the service party, and can be set according to the requirement. For example, the routing information is stored in the routing configuration information in the form of routing rule-service route identification. The routing rule refers to a routing address of a service route, and the service route identifier refers to a mark for distinguishing different service routes. For example, the service route identifier may specifically refer to a character string used for distinguishing different service routes.
Specifically, when receiving an interface service call request, the server extracts a routing address from a request message of the interface service call request, traverses preset routing configuration information according to the routing address to detect whether a corresponding routing rule exists in the routing configuration information, when the routing address hits the routing rule in the routing configuration information, the server can determine a service route according to the hit routing rule and determine a service route identifier corresponding to the service route, when the routing address does not hit the routing rule in the routing configuration information, the server feeds back a query failure prompt to the terminal, the query failure prompt is used for prompting a requester using the terminal, and the interface service call corresponding to the routing address cannot be provided currently.
In this embodiment, the routing address is extracted from the request message of the interface service invocation request, and the preset routing configuration information is traversed according to the routing address, so that the service routing and the service routing identifier can be determined when the routing rule is hit.
In one embodiment, obtaining a requestor identifier corresponding to the interface service invocation request, and determining service quota mapping information according to the service routing identifier and the requestor identifier includes:
extracting a requester identifier from a request message of an interface service call request;
and generating service quota mapping information according to the service routing identifier and the requester identifier.
Specifically, after determining that the routing rule is hit, the server may further extract a requestor identifier from a request message of the interface service invocation request, combine the service routing identifier and the requestor identifier, and generate service quota mapping information. The request message includes a request header, and the requestor identifier is included in the request header, for example, the format of the request header may be: x-rio-paasid = xxxx, wherein paasid is the requestor id. For another example, according to different manners of combining the service route identifier and the requestor identifier, the format of the service quota mapping information may specifically be a requestor identifier + a service route identifier, a service route identifier + a requestor identifier, and the like, and the manner of generating the service quota mapping information is not specifically limited in this embodiment.
In this embodiment, the service quota mapping information is generated by extracting the requester identifier from the request message of the interface service invocation request and according to the service routing identifier and the requester identifier, and the service quota mapping information can be acquired.
In one embodiment, after obtaining a requestor identifier corresponding to the interface service invocation request and determining the service quota mapping information according to the service routing identifier and the requestor identifier, the method further includes:
when the service quota corresponding to the service quota mapping information exists in the internal memory, quota deduction is carried out, and an interface calling success prompt is fed back;
and the synchronous quota deduction result is sent to a quota database, and the interface service calling request is forwarded to the service party corresponding to the service routing identifier.
The quota deduction result refers to the remaining service quota after quota deduction.
Specifically, the server also stores a service quota, when quota deduction is performed, the server may first query whether a corresponding service quota exists in the memory according to the service quota mapping information, when a service quota corresponding to the service quota mapping information exists in the memory, quota deduction is directly performed, an interface calling success prompt is fed back, a quota deduction result is sent to the quota database, so that the quota database updates service configuration data according to the quota deduction result, and the interface service calling request is forwarded to the server side corresponding to the service route identifier, so that the server side processes the interface service calling request, and feeds back a service result. Further, after receiving the service result, the server returns the service result to the terminal corresponding to the requester.
In this embodiment, quota deduction is performed, an interface call success prompt is fed back, a quota deduction result is synchronized to a quota database, and an interface service call request is forwarded to a server side corresponding to the service routing identifier, so that synchronization of quota deduction in the quota database and processing of the interface service call request after quota deduction can be achieved.
In one embodiment, according to the query result, the feeding back the call result prompt includes:
when the service quota corresponding to the service quota mapping information exists in the service configuration data, quota deduction is carried out, and an interface calling success prompt is fed back;
and feeding back a quota use-up prompt when the service quota corresponding to the service quota mapping information does not exist in the service configuration data.
The interface call success prompt means quota deduction and can provide a prompt of interface call. The quota use-out prompt is a prompt that the quota has been used up and no service quota exists.
Specifically, when the service configuration data has the service quota corresponding to the service quota mapping information, the quota deduction can be performed, the server performs quota deduction, feeds back an interface call success prompt, synchronizes a quota deduction result to the quota database, and forwards the interface service call request to the server side corresponding to the service routing identifier. When the service quota corresponding to the service quota mapping information does not exist in the service configuration data, the quota does not exist, quota deduction cannot be carried out, and the server feeds back a quota use-up prompt to prompt the requester to carry out service subscription again and obtain the service quota.
In this embodiment, by feeding back the call result prompt according to the query result, the interface call success prompt requester can be fed back to prompt that the interface call is successful or the quota use is fed back to prompt the requester that the service quota is used up and needs to be subscribed again.
In one embodiment, when a service quota corresponding to the service quota mapping information exists in the service configuration data, after performing quota deduction, the method further includes:
the quota deduction result is synchronized to the quota database.
Specifically, when the service quota corresponding to the service quota mapping information exists in the service configuration data, the server may also perform quota deduction and feed back an interface call success prompt, and after the quota deduction is performed, the server may send a quota deduction result to the quota database, so that the quota database updates the service configuration data according to the quota deduction result, and forwards the interface service call request to the service party corresponding to the service routing identifier, so that the service party processes the interface service call request and feeds back a service result. Further, after receiving the service result, the server returns the service result to the terminal corresponding to the requester.
In this embodiment, the quota deduction result is synchronized with the quota database, so that the quota deduction result can be synchronized, and the service quota in the quota database is accurate.
In one embodiment, the interface service calling method further comprises:
when the quota operation request is monitored, performing authority verification on an operator corresponding to the quota operation request;
after the authority of the operator corresponding to the quota operation request is verified, extracting a service subscriber identifier, a service routing identifier and quota operation parameters carried in the quota operation request;
determining a quota to be processed according to the service subscriber identification and the service routing identification;
and processing the quota to be processed according to the quota operation parameters, and synchronizing a quota processing result to the quota database.
The quota operation request refers to a request for operating a service quota, and the operation includes setting, querying, deleting, and the like. Service subscriber identification refers to an identification of a service purchaser subscribing to a service. The quota operation parameter refers to a parameter for operating the service quota, and includes an operation mode, an operation number, and the like. For example, when the quota operation is a quota setting, the quota operation parameter includes that the operation mode is a quota setting, and the operation number is a specific service quota. For another example, when the quota operation is a quota query, the quota operation parameter includes that the operation mode is the quota query, and there is no operation quantity. For another example, when the quota operation is quota deletion, the quota operation includes that the operation mode is quota deletion, and there is no operation number.
The permission verification means that whether a sender sending the quota operation request has quota operation permission or not is verified. The to-be-processed quota refers to a service quota that needs to be processed. The quota processing result refers to a result of processing the to-be-processed quota. For example, when the quota operation is set for a quota, the quota processing result is a reset quota to be processed.
Specifically, the server monitors a quota operation request in real time, when quota operation is required, an operator with an operation authority sends the quota operation request to the server through the terminal, after the server monitors the quota operation request, the server performs authority verification on the operator corresponding to the quota operation request, after the authority verification of the operator passes, the server extracts a service subscriber identifier and a service route identifier carried in the quota operation request, determines a corresponding quota to be processed according to the service subscriber identifier and the service route identifier, processes the quota to be processed according to quota operation parameters in the quota operation request, and synchronizes quota processing results to the quota database. The authority verification of the operator corresponding to the quota operation request may specifically be that the authority verification is performed on the operator according to an operator account and a password of the operator. The operator account and the password may be synchronously sent when the quota operation request is sent, which is not specifically limited in this embodiment. Further, for different quota operations, the server may provide different operation interfaces, for example, the server may provide an interface for setting a service quota, an interface for querying the service quota, and an interface for deleting the service quota.
In this embodiment, when the quota operation request is monitored, after the operator permission corresponding to the quota operation request is verified, the to-be-processed quota is determined according to the extracted service subscriber identifier and the service routing identifier, and the to-be-processed quota is processed according to the quota operation parameter, so that the to-be-processed quota can be processed.
The application also provides an application scenario, as shown in fig. 3, where the application scenario applies the interface service calling method. Specifically, the interface service calling method is applied to the application scenario as follows:
when a service on a request gateway is requested, an interface service calling request is sent to a server by using a request service client, the server monitors a request event called by the interface service in real time, when the interface service calling request is monitored, the interface service calling request is triggered to be processed, a routing address is extracted from a request message of the interface service calling request, preset routing configuration information is traversed according to the routing address, when the routing address hits a routing rule in the routing configuration information, the service routing is determined according to the routing rule, whether quota exists in the service routing (namely the current routing) is judged, when the quota exists, an interface calling success prompt is fed back, the request event is forwarded to the service routing (namely the service address is hit), so that a back-end service processes the request according to the request event, returns a service result, responds to the service result, and returns the service result to the request service client. When the quota does not exist, the server directly returns a quota use-up prompt to the service requesting client.
Wherein, when determining whether the service route has a quota, as shown in fig. 4, the server will first determine a corresponding service route identifier (i.e. current service route rule id) according to the interface service invocation request, obtain a requestor identifier (i.e. past of the request header) corresponding to the request event, determining service quota mapping information according to the service routing identifier and the requester identifier, firstly inquiring whether a service quota corresponding to the service quota mapping information exists in a memory of a server (namely a current node) or not according to the service quota mapping information, when the service quota corresponding to the service quota mapping information exists in the memory, further judging whether the service quota is larger than 0, when the service quota is larger than 0, deducting quota, delaying 1s synchronous quota deduction result to quota database (namely triggering 1s processing synchronous Redis method), and forwarding request event to back-end service processing, returning processing result, when the service quota is less than or equal to 0, the server needs to access and synchronize the service configuration data cached in the preset quota database (i.e. synchronize the Redis configuration to the current node memory), inquiring service configuration data according to the service quota mapping information, determining a synchronous service quota, judging whether the synchronous service quota is larger than 0, when the synchronous service quota is larger than 0, deducting quota, delaying 1s synchronous quota deduction result to quota database (namely triggering 1s processing synchronous Redis method), and forwarding request event to back-end service processing, returning processing result, and when the synchronous service quota is less than or equal to 0, generating quota use end prompt information, and returning the quota use end prompt information to the service requesting client.
As shown in fig. 5, the server in this embodiment may be a gateway node in a gateway cluster, where the gateway cluster includes multiple gateway nodes (gateway 1, gateway 2, gateway 3, and the like) that all can process a request event called by an interface service, and the gateway nodes are connected to a backend service (including service a, service B, service C, and the like).
In an embodiment, as shown in fig. 6, the present application further provides a flowchart to explain the interface service invoking method of the present application, where the interface service invoking method specifically includes the following steps:
step 602, receiving an interface service invocation request, and extracting a routing address from a request message of the interface service invocation request;
step 604, traversing preset routing configuration information according to the routing address;
step 606, when the routing address hits the routing rule in the routing configuration information, determining the service route according to the routing rule, and determining the service route identifier corresponding to the service route;
step 608, extracting the identifier of the requester from the request message of the interface service call request;
step 610, generating service quota mapping information according to the service routing identifier and the requester identifier;
step 612, determining whether a corresponding service quota exists in the memory according to the service quota mapping information, skipping to step 614 when the corresponding service quota exists in the memory, and skipping to step 616 when the corresponding service quota does not exist in the memory;
step 614, quota deduction is carried out, an interface calling success prompt is fed back, a quota deduction result is synchronized to a quota database, and an interface service calling request is forwarded to a service party corresponding to the service routing identifier;
step 616, accessing and synchronizing the service configuration data cached in the preset quota database;
step 618, inquiring service configuration data according to the service quota mapping information;
step 620, determining whether a service quota corresponding to the service quota mapping information exists in the service configuration data, skipping to step 624 when the corresponding service quota exists in the service configuration data, and skipping to step 622 when the corresponding service quota does not exist in the service configuration data;
step 622, feeding back a quota use-up prompt;
step 624, quota deduction is carried out, a feedback interface calls a success prompt, and quota deduction results are synchronized to a quota database;
step 626, when the quota operation request is monitored, performing authority verification on an operator corresponding to the quota operation request;
step 628, after the authority of the operator corresponding to the quota operation request is verified, extracting a service subscriber identifier, a service routing identifier, and a quota operation parameter carried in the quota operation request;
step 630, determining a quota to be processed according to the service subscriber identity and the service routing identity;
step 632, processing the quota to be processed according to the quota operation parameter, and synchronizing the quota processing result to the quota database.
It should be understood that, although the steps in the flowcharts related to the above embodiments are shown in sequence as indicated by the arrows, the steps are not necessarily executed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in each flowchart related to the above embodiment may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a part of the steps or stages in other steps.
In one embodiment, as shown in fig. 7, there is provided an interface service invoking apparatus, which may be a part of a computer device using a software module or a hardware module, or a combination of the two, specifically including: a listening module 702, a processing module 704, a synchronization process 706, a query module 708, and a deduction module 710, wherein:
a monitoring module 702, configured to receive an interface service call request, and determine a corresponding service routing identifier according to the interface service call request;
a processing module 704, configured to obtain a requestor identifier corresponding to the interface service invocation request, and determine service quota mapping information according to the service routing identifier and the requestor identifier;
a synchronization module 706, configured to access and synchronize service configuration data cached in the preset quota database when a service quota corresponding to the service quota mapping information does not exist in the memory;
a query module 708, configured to query service configuration data according to the service quota mapping information;
and the deduction module 710 is configured to feed back the call result prompt according to the query result.
According to the interface service calling method, the device, the computer equipment and the storage medium, the corresponding service routing identification is determined according to the interface service calling request, the requester identification is obtained, after the service quota mapping information is determined according to the service routing identification and the requester identification, whether the service quota corresponding to the service quota mapping information exists or not is inquired in the memory, if the service quota does not exist, the service configuration data cached in the preset quota database is accessed and synchronized, whether the service quota corresponding to the service quota mapping information exists or not is inquired in the synchronized service configuration data or not is inquired, and the calling result prompt is fed back according to the inquiring result, so that quota management can be realized only by using the service quota in the memory and the service configuration data in the quota database, excessive middleware does not exist, the middleware does not need to be maintained by more technical cost and labor cost, and resources can be saved.
In an embodiment, the monitoring module is further configured to receive an interface service invocation request, extract a routing address from a request message of the interface service invocation request, traverse preset routing configuration information according to the routing address, determine a service route according to a routing rule when the routing address hits the routing rule in the routing configuration information, and determine a service route identifier corresponding to the service route.
In an embodiment, the processing module is further configured to extract a requestor identifier from a request message of the interface service invocation request, and generate the service quota mapping information according to the service routing identifier and the requestor identifier.
In an embodiment, the deduction module is further configured to, when a service quota corresponding to the service quota mapping information exists in the memory, deduct a quota, feed back an interface call success prompt, synchronize a quota deduction result to the quota database, and forward the interface service call request to a service party corresponding to the service routing identifier.
In an embodiment, the deduction module is further configured to perform quota deduction when a service quota corresponding to the service quota mapping information exists in the service configuration data, call a success prompt through the feedback interface, and feed back a quota use-up prompt when a service quota corresponding to the service quota mapping information does not exist in the service configuration data.
In one embodiment, the deduction module is further to synchronize the quota deduction result to a quota database.
In an embodiment, the interface service invoking device further includes a quota operation module, where the quota operation module is configured to perform permission verification on an operator corresponding to the quota operation request when the quota operation request is monitored, extract a service subscriber identifier, a service routing identifier, and a quota operation parameter carried in the quota operation request after the operator permission verification corresponding to the quota operation request passes, determine a to-be-processed quota according to the service subscriber identifier and the service routing identifier, process the to-be-processed quota according to the quota operation parameter, and synchronize a quota processing result to the quota database.
For specific definition of the interface service invoking device, reference may be made to the above definition of the interface service invoking method, which is not described herein again. The modules in the interface service invoking device may be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data such as routing configuration information. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an interface service invocation method.
Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In an embodiment, a computer device is further provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer-readable storage medium. The computer instructions are read by a processor of a computer device from a computer-readable storage medium, and the computer instructions are executed by the processor to cause the computer device to perform the steps in the above-mentioned method embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent application shall be subject to the appended claims.

Claims (10)

1. An interface service invocation method, characterized in that the method comprises:
receiving an interface service calling request, and determining a corresponding service routing identifier according to the interface service calling request;
acquiring a requester identifier corresponding to the interface service calling request, and determining service quota mapping information according to the service routing identifier and the requester identifier;
when the service quota corresponding to the service quota mapping information does not exist in the internal memory, accessing and synchronizing the service configuration data cached in the preset quota database;
inquiring the service configuration data according to the service quota mapping information;
and feeding back a calling result prompt according to the query result.
2. The method of claim 1, wherein the receiving an interface service invocation request, and determining a corresponding service routing identifier according to the interface service invocation request comprises:
receiving an interface service calling request, and extracting a routing address from a request message of the interface service calling request;
traversing preset routing configuration information according to the routing address;
and when the routing address hits a routing rule in the routing configuration information, determining a service route according to the routing rule, and determining a service route identifier corresponding to the service route.
3. The method of claim 1, wherein the obtaining a requestor identifier corresponding to the interface service invocation request, and the determining service quota mapping information according to the service routing identifier and the requestor identifier comprises:
extracting a requester identifier from a request message of the interface service calling request;
and generating service quota mapping information according to the service routing identification and the requester identification.
4. The method of claim 1, wherein after obtaining a requestor identifier corresponding to the interface service invocation request and determining service quota mapping information according to the service routing identifier and the requestor identifier, the method further comprises:
when the service quota corresponding to the service quota mapping information exists in the internal memory, quota deduction is carried out, and a feedback interface calls a success prompt;
and synchronizing a quota deduction result to the quota database, and forwarding the interface service calling request to a server side corresponding to the service routing identifier.
5. The method of claim 1, wherein the feeding back a result prompt according to the query result comprises:
when the service configuration data has the service quota corresponding to the service quota mapping information, carrying out quota deduction and feeding back an interface calling success prompt;
and feeding back a quota use-up prompt when the service quota corresponding to the service quota mapping information does not exist in the service configuration data.
6. The method according to claim 1, wherein when there is a service quota corresponding to the service quota mapping information in the service configuration data, after performing quota deduction, the method further includes:
and synchronizing the quota deduction result to the quota database.
7. The method of claim 1, further comprising:
when a quota operation request is monitored, performing authority verification on an operator corresponding to the quota operation request;
after the authority of the operator corresponding to the quota operation request passes verification, extracting a service subscriber identifier, a service routing identifier and quota operation parameters carried in the quota operation request;
determining a quota to be processed according to the service subscriber identifier and the service routing identifier;
and processing the quota to be processed according to the quota operation parameters, and synchronizing a quota processing result to the quota database.
8. An interface service invocation apparatus, characterized in that the apparatus comprises:
the monitoring module is used for receiving an interface service calling request and determining a corresponding service routing identifier according to the interface service calling request;
the processing module is used for acquiring a requester identifier corresponding to the interface service calling request and determining service quota mapping information according to the service routing identifier and the requester identifier;
the synchronization module is used for accessing and synchronizing the service configuration data cached in the preset quota database when the service quota corresponding to the service quota mapping information does not exist in the memory;
the query module is used for querying the service configuration data according to the service quota mapping information;
and the deduction module is used for feeding back a calling result prompt according to the query result.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A computer-readable storage medium, storing a computer program, characterized in that the computer program, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202110377885.7A 2021-04-08 2021-04-08 Interface service calling method and device, computer equipment and storage medium Pending CN115202894A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110377885.7A CN115202894A (en) 2021-04-08 2021-04-08 Interface service calling method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110377885.7A CN115202894A (en) 2021-04-08 2021-04-08 Interface service calling method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115202894A true CN115202894A (en) 2022-10-18

Family

ID=83571216

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110377885.7A Pending CN115202894A (en) 2021-04-08 2021-04-08 Interface service calling method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115202894A (en)

Similar Documents

Publication Publication Date Title
CN108093094B (en) Database instance access method, device, system, storage medium and equipment
US11394805B1 (en) Automatic discovery of API information
CN108833521B (en) Message pushing method, device, system, computer equipment and storage medium
CN108829459B (en) Nginx server-based configuration method and device, computer equipment and storage medium
CN108470298B (en) Method, device and system for transferring resource numerical value
CN108683668B (en) Resource checking method, device, storage medium and equipment in content distribution network
CN110213223B (en) Service management method, device, system, computer equipment and storage medium
CN110430288B (en) Node access method, node access device, computer equipment and storage medium
CN111405019B (en) Data processing method, data processing device, computer equipment and storage medium
CN109587258B (en) Service activity detection method and device
CN110764700A (en) Data storage method and device, computer equipment and storage medium
WO2020253634A1 (en) Data processing method, system and device
CN107395559B (en) Data processing method and device based on redis
CN110213392B (en) Data distribution method and device, computer equipment and storage medium
CN113507475B (en) Cross-domain access method and device
CN112612595A (en) Method and device for establishing micro-service calling relationship, computer equipment and storage medium
CN108595280B (en) Interface adaptation method and device, computer equipment and storage medium
CN113285926B (en) Honey pot trapping method and device for power monitoring system and computer equipment
CN106357539A (en) Data acquisition method and equipment
CN109743357B (en) Method and device for realizing service access continuity
US11206302B2 (en) Method and device for feeding back a resource file
CN107770203B (en) Service request forwarding method, device and system
CN115202894A (en) Interface service calling method and device, computer equipment and storage medium
CN113626188A (en) Task pushing method and device, computer equipment and storage medium
CN114615315A (en) Communication method, device, equipment and storage medium for online conversation

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