QuotaManager
The 4D.QuotaManager class provides you with an interface to configure and monitor some usage limits you apply to your 4D application. Thresholds are useful for example to protect the server from poorly optimized requests or excessive use of server resources. Typically, the quota manager allows you to provide thresholds to ORDA resources a REST server session can access.
4D.QuotaManager objects can be instantiated by the quotas property of a session object.
Historique
| Release | Modifications |
|---|---|
| 21 R4 | Classe ajoutée |
QuotaManager Object
4D.QuotaManager objects provide the following properties:
| currentValues : Object |
| defaultEntitySetTimeout : Integer the default inactivity timeout for REST entity sets stored in memory during the current session (in seconds) |
| maxEntitySetTimeout : Integer the maximum inactivity timeout value for REST entity sets stored in memory during the current session (in seconds) |
| nbEntitySets : Integer |
.currentValues
currentValues : Object
Description
The .currentValues property contains the current values related to the defined quotas properties. This object is automatically updated by the server.
.defaultEntitySetTimeout
defaultEntitySetTimeout : Integer
Description
The .defaultEntitySetTimeout property contains the default inactivity timeout for REST entity sets stored in memory during the current session (in seconds).
By default, this value is 2 hours (7200 seconds). It can also be defined at the entity set creation using the $timeout REST API.
You can change this value dynamically using the quotas.defaultEntitySetTimeout property of the Session, so that it will be used for any entity set created afterwards in the session (existing entity set default timeout values are not modified).
If you define a value higher than the maxEntitySetTimeout property value, it will be aligned with the maxEntitySetTimeout value.
You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass undefined.
Exemple
In some 4D code in a REST process:
Session.quotas.defaultEntitySetTimeout:=1200
.maxEntitySetTimeout
maxEntitySetTimeout : Integer
Description
The .maxEntitySetTimeout property contains the maximum inactivity timeout value for REST entity sets stored in memory during the current session (in seconds).
You can set this value using the quotas.maxEntitySetTimeout property of the Session, so that it will be used for any entity set created afterward in the session (existing entity set maximum timeout values are not modified).
Once the .maxEntitySetTimeout property is set, any entity set created afterward in the session could not have a timeout value longer than the .maxEntitySetTimeout value.
For example, assuming the maximum inactivity timeout is set to 40 minutes (2400 seconds), if an entity set is created with a required timeout which exceeds the maximum value:
http://127.0.0.1/rest/People?$filter=ID>=4&$method=entityset&$timeout=3000
... then the timeout defined in the request is ignored and the entity set will be released after 40 minutes if not used during this period of time.
You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass undefined.
Exemple
In some 4D code in a REST process:
Session.quotas.maxEntitySetTimeout:=2400
.nbEntitySets
nbEntitySets : Integer
Description
The .nbEntitySets property contains the maximum number of REST entity sets allowed in memory for the current session (in seconds).
By default, there is no limit for entity sets stored in memory by REST requests (the value is 0). You can set a limit to control the server payload for a specific session.
When the maximum number of allowed entity sets is reached, a REST request that need to create an entity set will get a 429 HTTP status code and an error response, until at least one entity set is released. You can release an entity set from the cache using the $release REST command.
You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass undefined.
Exemple
In some 4D code in a REST process:
//max 50 entity sets
Session.quotas.nbEntitySets:=50