@mimik/cluster
v5.0.4
Published
cluster management for mimik microservices
Downloads
191
Readme
cluster
Example
import cluster from '@mimik/cluster';
The following environment variables are set:
| Env variable name | Description | Default | Comments |
| ----------------- | ----------- | ------- | -------- |
| REGISTRATION_STATUS | Status of the registration with mIT | | |
| CLUSTER_STATUS_SERVERS | Number of servers in the cluster | | |
| CLUSTER_STATUS_UPDATED_AT | Timestamp of the last cluster status update | | |
| CLUSTER_STATUS_LEASE_TIME | Lease time interval | | |- cluster
- async
- ~rpCluster(options) ⇒ Promise
- ~register(correlationId, retry) ⇒ Promise
- ~unRegister(correlationId) ⇒ Promise
- sync
- async
cluster~rpCluster(options) ⇒ Promise
The response is an object with the following structure:
{
"data": [ 'array of all successful response payloads' ],
"results": [
{
"result": (response from [rp-retry](http://lib.mimik360.com:4873/request-retry)),
"server": (cluster node that produced the result)
}
],
"failures": [
{
"error": (error thrown for a request to a cluster node),
"server": (cluster node that produced the error)
}
]
}Kind: inner method of cluster
Category: async
Requires: module:@mimik/sumologic-winston-logger, module:@mimik/oauth-helper, module:@mimik/response-helper
Fulfil: object - Aggregated response of the request.
| Param | Type | Description | | --- | --- | --- | | options | object | Options for the request (similar to axios options). The only difference is the URL: it must NOT include the base URL, because the cluster provides it. |
cluster~register(correlationId, retry) ⇒ Promise
Register a server with mIT.
Kind: inner method of cluster
Returns: Promise - .
Category: async
Requires: module:@mimik/sumologic-winston-logger, module:@mimik/oauth-helper, module:@mimik/address-helper
Fulfil: null or the response from rpCluster
Registration with mIT is retried at the interval defined by REGISTRATION_RETRY.
When registration completes, a lease call is made to mIT at a regular interval.
The lease interval is defined by mIT; if unspecified, it defaults to 2 hours.
When cluster management is enabled, a concurrent registration is executed after
approximately 60 seconds to guarantee cluster integrity.
| Param | Type | Description | | --- | --- | --- | | correlationId | UUID.<string> | Correlation ID to associate with the request. | | retry | boolean | Flag used when concurrent registration occurs. |
cluster~unRegister(correlationId) ⇒ Promise
The returned object is:
{
nbServers: "number of servers in the cluster",
serverId: "server ID",
errors: "optional array of errors that occurred while unregistering"
}Kind: inner method of cluster
Returns: Promise - .
Category: async
Requires: module:@mimik/sumologic-winston-logger, module:@mimik/oauth-helper
Fulfil: An object containing the number of servers, the serverId, and any errors (if present).
| Param | Type | Description | | --- | --- | --- | | correlationId | UUID.<string> | Correlation ID to associate with the request. |
cluster~createItResource(con, req, res)
Create IT resource endpoint.
Kind: inner method of cluster
Category: sync
Requires: module:@mimik/swagger-helper, module:@mimik/response-helper, module:@mimik/sumologic-winston-logger
| Param | Type | Description | | --- | --- | --- | | con | object | Request context (from OpenAPI). | | req | object | The HTTP request. | | res | object | The HTTP response. |
cluster~deleteServer(con, req, res)
Delete server endpoint.
Kind: inner method of cluster
Category: sync
Requires: module:@mimik/swagger-helper, module:@mimik/response-helper
| Param | Type | Description | | --- | --- | --- | | con | object | Request context (from OpenAPI). | | req | object | The HTTP request. | | res | object | The HTTP response. |
