Quotas & Limits
The majority of APIs define limits on the API usage. Components that call APIs need to make sure that these limits are respected, otherwise their API calls would start failing quickly. The quota.js
module allows you to specify what those limits are on a per-service, per-module or even per-component basis. The Appmixer engine uses this module to make sure API calls are throttled so that the usage limits are respected.
The quota module must be named quota.js
and must be stored under either the service, module or component directory (i.e. [vendor]/[service]/auth.js
, [vendor/[service]/[module]/auth.js
or [vendor/[service]/[module]/[component]/auth.js
.
An example of a quota module:
The quota definition above tells the engine to throttle the receive()
call of the component to a max of 2000-times per day and 3-times per second.
Quota Module Structure
Quota modules are NodeJS modules that return an object with one property rules
.
rules
An array of rules that define usage limits. Each rule can have the following properties:
limit
Maximum number of calls in the time window specified by window
.
window
The time window in milliseconds.
throttling
The throttling mechanism. Can be either a string 'window-sliding'
or an object with type
and getStartOfNextWindow
function. Example of a quota module for LinkedIn:
resource
An identifier of the resource to which the rule applies. The resource is a way for a component to pick rules that apply to that specific component. This can be done in the component manifest file in the quota.resources
section.
Last updated