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.
Historia
| Lanzamiento | Modificaciones |
|---|---|
| 21 R4 | Clase añadida |
Objeto QuotaManager
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
Descripción
The .currentValues property contains the current values related to the defined quotas properties. This object is automatically updated by the server.
.defaultEntitySetTimeout
defaultEntitySetTimeout : Integer
Descripción
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).
Si se define un valor superior al de la propiedad maxEntitySetTimeout, dicho valor se ajustará al de maxEntitySetTimeout.
No se puede pasar un valor <=0 (en ese caso se produce un error). Para restablecer el valor de la propiedad para la sesión, pase undefined.
Ejemplo
En un código 4D de un proceso REST:
Session.quotas.defaultEntitySetTimeout:=1200
.maxEntitySetTimeout
maxEntitySetTimeout : Integer
Descripción
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.
No se puede pasar un valor <=0 (en ese caso se produce un error). Para restablecer el valor de la propiedad para la sesión, pase undefined.
Ejemplo
En un código 4D de un proceso REST:
Session.quotas.maxEntitySetTimeout:=2400
.nbEntitySets
nbEntitySets : Integer
Descripción
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). Puede definir un límite para controlar la carga útil del servidor para una sesión específica.
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.
No se puede pasar un valor <=0 (en ese caso se produce un error). Para restablecer el valor de la propiedad para la sesión, pase undefined.
Ejemplo
En un código 4D de un proceso REST:
//max 50 entity sets
Session.quotas.nbEntitySets:=50