A kind of method and system based on terminal type provisioning API resource
Technical field
The present invention relates to information technology fields, and in particular to a kind of method based on terminal type provisioning API resource and is
System.
Background technology
The common application programming interface of industrial quarters (Application Programming Interface, API) is pacified
Be with management platform entirely it is a set of operate in data center, cloud service center application software, for the API producer, API consume
The roles such as person, API managers provide API gateway, API portals, API life cycle managements, API monitoring, API key managements
And the assembly functions such as API practicality situation analysis, Fig. 1 show the structural schematic diagram of API safety and management platform.API safety with
Management platform operation system environments include:Meet J2EE specifications middleware (such as:Tomcat, Weblogic etc.),
Oracle or Mysql databases.It is different that application programming interfaces API is directly invoked from traditional application program, and information centre needs
API safety and management software are first enabled, application program can pass through one before calling the application programming interfaces (API) in resource
A API gateway, the gateway can realize safe access control and the dynamic call to API, i.e. API nets according to certain scheduling strategy
Module is closed to be responsible for carrying out route agent, performance distribution to entire API resources.
As shown in Fig. 2, API gateway is operated in as intermediate node between application program and server A PI resources, play
The important function of API scheduling of resource and control.For example assume 1 API background system, 100 concurrent requests of maximum support per second,
More than this numerical value, system will collapse, therefore limit request.If there are 20 consumers to subscribe at present, ask within average 1 second
1 is asked, peak value request 10 per second, then the request each subscribed to will be limited at 10 or less.Industry generally uses at present
Every layer of service association is arranged by service-level agreement (Service-Level Agreement, SLA) in a kind of " air throttle " technology
The maximum available request number of view.For example, maximum 5000 requests, secondary service are 50 maximum per hour per hour for level-one service
Request.Such as set some API maximum can call number be 50, each Connection Time is 60000 milliseconds.Therefore work as and apply
It when the routine call API is more than 50 times, does not allow for recalling, this application journey to certain specific transactions frequent operations
It is inappropriate for sequence.
Provisioning API resource is realized using services configuration protocol shown in Fig. 2 in the prior art, it is many invalid to cause
API is finally fed back and is responded on API server, and since network identity possessed by different terminals type and API take
The involved personalization of business request also can be different, how to filter out some invalid API requests and configured according to terminal type
In corresponding API resources to terminal, needs to be optimized system and scheme itself and just may be implemented.
Invention content
Technical scheme of the present invention preferably provisioning API resource cannot realize that API resource distributions are right to institute primarily directed to API
On the user terminal answered, each resource end data is obtained according to a time length using elder generation, filters out some illegal API requests,
It is realizing weight computing, API user is enable rationally to utilize server resource, legal API service is then asked into push
Onto user terminal.
The present invention provides a kind of method based on terminal type provisioning API resource, the method includes:
The API resource request messages of corresponding terminal transmission, institute are received within the scope of preset duration based on each application interface
State the network identity and API service request that API resource request messages include counterpart terminal;
Each application interface is asked according to the API of the corresponding terminal of preset duration range generation in each application interface
Packet is sought, and the API request packet is sent to API server;
API server applies for the legitimacy of API based on the API service requests verification user in API request packet;
After the API service request of user passes through legitimate verification, it is corresponding eventually that API server is based on network identity acquisition
The API service type at end, the API service type are configured by the terminal type of counterpart terminal;
The API service type is sent to each application interface by the API server, in each application interface
Each interface calculates occupancy weights of the API request packet on corresponding application interface based on API service type;
Use services configuration protocol for each interface provisioning API visit capacity in each application programming interfaces;
The user terminal corresponding to the API service request by legitimate verification pushes API service response message.
Each application interface is asked according to the API of the corresponding terminal of preset duration range generation in each application interface
The packet is asked to include:
Within the scope of the preset duration, each application interface counts corresponding terminal hair within the scope of preset duration
The API resource request message quantity sent;
When preset duration range reaches, by the network identity of corresponding terminal, API service request, resource request message
Quantity and duration value are encapsulated in API request packet with data structure.
Each interface in each application interface calculates the API request packet corresponding based on API service type
Application interface on occupancy weights include:
Obtain the target type and network identity of terminal corresponding to API service type;
Right to occupation of the API request packet on corresponding application interface is calculated based on target type and network identity
Value.
It is described that API request packet the accounting on corresponding application interface is calculated based on target type and network identity
Include with weights:
Weight coefficient is occupied accordingly based on the target type and network identification match;
Right to occupation of the API request packet on corresponding application interface is calculated based on the occupancy weight coefficient
Value.
The user terminal corresponding to the API service request by legitimate verification pushes API service and includes:
According to the terminal capability parameters where API service acquisition request each user terminal;
The API service response message is split according to the terminal capability parameters where user terminal;
The API service response message generated after fractionation is sent to user terminal.
Correspondingly, the present invention also provides a kind of system based on terminal type provisioning API resource, the system comprises:
API gateway, the API resources sent for receiving corresponding terminal within the scope of preset duration based on each application interface
Request message, the API resource request messages include network identity and the API service request of counterpart terminal;Each application connects
Each application interface generates the API request packet of corresponding terminal according to the preset duration range in mouthful, and by the API request
Packet is sent to API server
API server, the legitimacy for applying for API based on the API service requests verification user in API request packet;
The API service request of user is by the way that after legitimate verification, API server obtains the API clothes of counterpart terminal based on network identity
Service type, the API service type are configured by the terminal type of counterpart terminal;And the API service type is sent
To each application interface;
The API gateway is used to calculate the API based on API service type based on each interface in each application interface
Occupancy weights of the request bag on corresponding application interface;Use services configuration protocol in each application programming interfaces
Each interface provisioning API visit capacity;The user terminal corresponding to the API service request by legitimate verification pushes API service
Response message.
The API gateway is additionally operable within the scope of the preset duration, and each application interface is in preset duration range
The API resource request message quantity that terminal corresponding to interior statistics is sent;When preset duration range reaches, by corresponding terminal
Network identity, API service request, resource request message quantity and duration value are encapsulated in API request packet with data structure.
The API gateway is additionally operable to obtain the target type and network identity of terminal corresponding to API service type;And base
Occupancy weights of the API request packet on corresponding application interface are calculated in target type and network identity.
The API gateway is additionally operable to occupy weight coefficient accordingly based on the target type and network identification match;Base
Occupancy weights of the API request packet on corresponding application interface are calculated in the occupancy weight coefficient.
The API gateway is additionally operable to according to the terminal capability parameters where API service acquisition request each user terminal;Root
The API service response message is split according to the terminal capability parameters where user terminal;The API service that will be generated after fractionation
Response message is sent to user terminal.
Technical solution of the present invention of the embodiment of the present invention is primarily based on each application interface and realizes API resources in preset time
Collection, terminal type involved by object, API service request, network identity to API resource requests etc. formed an API
Request bag, server-side filter out the API request of some incongruent safety standards after receiving request bag, in server end
Packet, then the occupancy weights on each application interface shared by terminal, base are calculated for legal API request packet by each application interface
It completes to push API service to corresponding user terminal in services configuration protocol.Under this pattern, API service can be passed through
Device reduces invalid API applications, can also according to involved by terminal type and the configurations such as network identity reasonably occupy weights,
The feedback effect rate for effectively promoting entire API gateway also reduces invalid API and occupies weights, promotes API gateway to effectively eventually
The API Allocation Efficiencies at end.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with
Other attached drawings are obtained according to these attached drawings.
Fig. 1 is API safety in the prior art and management platform structural schematic diagram;
Fig. 2 is the system structure diagram in the prior art based on SAL provisioning API visit capacities;
Fig. 3 is the system structure diagram based on terminal type provisioning API resource in the embodiment of the present invention;
Fig. 4 is the method flow diagram based on terminal type provisioning API resource in the embodiment of the present invention.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, those of ordinary skill in the art are obtained all other without creative efforts
Embodiment shall fall within the protection scope of the present invention.
The system of dynamic configuration API Access amount as shown in Figure 3, including API gateway, multiple application terminals, multiple services
Device etc., API gateway are connected to multiple application terminals and multiple servers, wherein:It is whole with application that API gateway manages multiple servers
Service between end there are multiple api interfaces to be communicated with corresponding application terminal on API gateway, these application terminals are general
The terminal of all types of addressable networks, such as mobile phone, PAD, PC etc. store on each server in multiple servers multiple
API completes the tune of corresponding API application programs by API resource request messages of the API gateway transmitted by application terminal
With.Gateway is equipped with multiple api interfaces, is connect with multiple application terminals, the calling for receiving API application programs is multiple
Api interface receives the API resource request messages that corresponding terminal is sent within the scope of preset duration based on each application interface, respectively answers
The API request packet of corresponding terminal is generated according to the preset duration range with each application interface in interface;Multiple API services
Device, for storing API resources;There are multiple api interfaces on API gateway or multiple api interfaces can be connected to, and be connected to
Multiple API servers, wherein:
API gateway, the API resources sent for receiving corresponding terminal within the scope of preset duration based on each application interface
Request message, the API resource request messages include network identity and the API service request of counterpart terminal;Each application connects
Each application interface generates the API request packet of corresponding terminal according to the preset duration range in mouthful, and by the API request
Packet is sent to API server;
API server, the legitimacy for applying for API based on the API service requests verification user in API request packet;
The API service request of user is by the way that after legitimate verification, API server obtains the API clothes of counterpart terminal based on network identity
Service type, the API service type are configured by the terminal type of counterpart terminal;And the API service type is sent
To each application interface;
API gateway is asked for calculating the API based on API service type based on each interface in each application interface
Seek occupancy weights of the packet on corresponding application interface;Use services configuration protocol to be every in each application programming interfaces
One interface provisioning API visit capacity;The user terminal corresponding to the API service request by legitimate verification pushes API service and answers
Answer message.
Application program calls the API being deployed on different server by API gateway, and application program is mounted in accordingly
On application terminal, and application terminal is based on corresponding interface and sends corresponding API resource requests to API gateway.The skill of the present invention
Art scheme is realized using services configuration protocol file in API gateway management.API gateway can be when default
In long range, the API resources that corresponding application terminal is sent are counted within the scope of preset duration based on each application interface and are asked
Seek message number;When preset duration range reaches, the network identity of corresponding terminal, API service request, resource request are disappeared
Breath quantity and duration value are encapsulated in API request packet with data structure.
API gateway is in the target type and network identity for obtaining terminal corresponding to API service type;And it is based on target class
Type and network identity calculate occupancy weights of the API request packet on corresponding application interface.
API gateway is based on the target type and network identification match occupies weight coefficient accordingly;Based on the occupancy
Weight coefficient calculates occupancy weights of the API request packet on corresponding application interface.
API gateway is according to the terminal capability parameters where API service acquisition request each user terminal;According to user terminal institute
Terminal capability parameters the API service response message is split;The API service response message generated after fractionation is sent out
It is sent to user terminal.
Correspondingly, Fig. 4 shows the method flow diagram based on terminal type provisioning API resource in the embodiment of the present invention,
Specifically comprise the following steps:
S401, the API resource requests for being received corresponding terminal transmission within the scope of preset duration based on each application interface are disappeared
Breath;
It should be noted that the API resource request messages that application terminal is sent are received within the scope of api interface preset duration,
It is handled as unit of millisecond, for example 50ms or 10ms etc. is that a unit is received, foot for this response time
Enough cope with the time demand of each application terminal.It is general that the API request message transmitted by each application terminal is received based on application interface
Include that the network identity of counterpart terminal and API service request, network identity here generally may relate to arrive application terminal
Network state involved by MAC Address and MAC Address can get the application corresponding to the MAC Address eventually by MAC Address
Relevant performance parameter, such as the network responding ability etc. involved by involved application terminal are held, and API service request is
Refer to the API request object involved by application terminal.Application terminal and involved is generally ignored in API service request involved at present
And terminal actual performance or network response etc., in API request message by network identity and API service request be reported to clothes
Business end may be implemented various to distribute process rationally.
, can be within the scope of preset duration in specific implementation process, each application interface counts within the scope of preset duration
The API resource request message quantity that corresponding terminal is sent;When preset duration range reaches, by the network mark of corresponding terminal
Know, API service is asked, resource request message quantity and duration value are encapsulated in API request packet, entire API request with data structure
Packet covers the SOT state of termination needed for entire API resources, also covers request object.
Each application interface generates the API of corresponding terminal according to the preset duration range in S402, each application interface
Request bag, and API request packet is sent to API server;
It should be noted that within the scope of the preset duration, each application interface in each application interface is when default
The API resource request message quantity that the corresponding terminal of statistics is sent in long range;It, will be corresponding when preset duration range reaches
Terminal type, API resource request messages, resource request message quantity and duration value are encapsulated in API request packet with data structure.This
A little data form an API request packet can be subject to dissection process in API gateway, and these API request packets are on API gateway
After completing dissection process, on being sent to corresponding API server according to the requested API server of API request packet.
S403, API server apply for the legitimacy of API based on the API service requests verification user in API request packet, if
Then enter S404 by verifying;
After API server receives API request packet, it is necessary first to complete legitimate verification process to API request packet, such as
The request of these API services of fruit can illustrate that the request of these API services is effective by the verification of corresponding API server, and
API service request cannot illustrate that the request of these API services is invalid, can not have to enter next step by verification
Occupy weights calculating process, it is only necessary to the connection such as null or other invalid connection status are fed back, it is invalid to reduce
API service asks the calculation processes in API gateway, also avoids the resource consumption etc. for consuming each application interface, API gateway.
S404, API server obtain the API service type of counterpart terminal based on network identity, and API server will be described
API service type is sent to each application interface;
Only legal user just can be resolved out, these API service types be resolved on API server with
Afterwards, you can API service type is sent to the calculating process for completing to occupy weights on each application interface, to realize API Access
The configuration process of amount.
Each interface in S405, each application interface calculates API request packet based on API service type and is answered in corresponding
With the occupancy weights on interface;
Each API service type is sent on each corresponding application interface by API server first, is then answered by each
The target type and network identity of terminal corresponding to API service type, target are obtained with interface or associated API gateway
Type generally relates to processing capacity of terminal, such as various hardware synthesis parameters etc., and network identity generally relate to pair
The network formats answered, for example be 2G, 3G, 4G, WIFI etc. network communication standard etc., corresponding to the combination configuration between the two
Occupancy weights relationship, i.e., the API request packet is calculated in corresponding application interface based on target type and network identity
On occupancy weights.
For example weight coefficient is occupied based on the target type and network identification match accordingly;Based on the occupancy weights
Coefficient calculates occupancy weights etc. of the API request packet on corresponding application interface.For example target type is tablet
Computer or mobile terminal, whole network standard is different, corresponding to api interface from the API request packet of acquisition, occupied by
Type or resource matched coefficient are all different, according to respectively corresponding occupancy weight coefficient or different terminals class
Coefficient ratio possessed by type is also different, then different according to coefficient ratio possessed by each terminal type, you can realizes that application connects
Occupancy weight computing on mouth.
S406, use services configuration protocol for each interface provisioning API visit capacity in each application programming interfaces;
S407, to asked by the API service of legitimate verification corresponding user terminal push API service response and disappear
Breath.
It, can be according to the terminal capability parameters where API service acquisition request each user terminal in specific implementation process;
The API service response message is split according to the terminal capability parameters where user terminal;The API generated after fractionation is taken
Business response message is sent to user terminal etc..
In specific implementation process, it is possible to determine that API resource request message quantity is not up to presetting message number threshold value, and
The available API resource transfers number obtained is more than default available API resource transfer number threshold values.
In specific implementation process, the API resource request messages that can be sent according to each application terminal obtain each respectively
The performance parameter of a terminal, and reach according to the performance parameter the corresponding API of all terminals of parameter preset threshold value
Resource request message generates high priority requests packet;High priority requests packet is sent to API server, and receives API service
The API resource response messages that device is sent;According to the end corresponding to the API resource request messages for including in high priority requests packet
End, splits resource response message;The sub- message of API resource responses generated after fractionation is sent to performance parameter and reaches pre-
The corresponding terminal of setting parameter threshold value.
In specific implementation process, can obtain performance parameter be not up to parameter preset threshold value all terminals it is corresponding
API resource request messages;The corresponding API resource requests of all terminals that parameter preset threshold value is not up to according to performance parameter disappear
Breath generates low priority request packet;After high priority requests packet is sent to API server, low priority request packet is obtained
Corresponding transmission parameter;Parameter threshold level is sent if sending parameter and reaching default, low priority request packet is sent to API clothes
Business device, and receive the API resource response messages of API server transmission;It is asked according to the API resources for including in low priority request packet
The terminal corresponding to message is sought, API resource response messages are split;The sub- message of API resource responses that will be generated after fractionation
It is sent to the corresponding terminal that performance parameter is not up to parameter preset threshold value.
To sum up, the embodiment of the present invention is primarily based on the collection that each application interface realizes API resources in preset time, right
Terminal type, API service request, network identity involved by the object of API resource requests etc. form an API request packet, clothes
End be engaged in after receiving request bag, filters out the API request packet of some incongruent safety standards in server end, then by each
Application interface calculates the occupancy weights on each application interface shared by terminal for legal API request packet, is based on services
Configuration protocol is completed to push API service to corresponding user terminal.Under this pattern, it is invalid to be reduced by API server
API applications, can also according to involved by terminal type and the configurations such as network identity reasonably occupy weights, effectively promoted whole
The feedback effect rate of a API gateway also reduces invalid API and occupies weights, promotes API gateway and is provided to the API of effective terminal
Source allocative efficiency.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment is can
It is completed with instructing relevant hardware by program, which can be stored in a computer readable storage medium, storage
Medium may include:Read-only memory (ROM, Read Only Memory), random access memory (RAM, Random
Access Memory), disk or CD etc..
The method and system based on terminal type provisioning API resource are provided for the embodiments of the invention above to have carried out in detail
Thin to introduce, principle and implementation of the present invention are described for specific case used herein, and above example is said
The bright method and its core concept for being merely used to help understand the present invention;Meanwhile for those of ordinary skill in the art, foundation
The thought of the present invention, there will be changes in the specific implementation manner and application range, in conclusion the content of the present specification is not
It is interpreted as limitation of the present invention.