@mimik/cluster
v4.0.1
Published
cluster management for mimik microservices
Downloads
46
Readme
cluster
Example
const cluster = require('@mimik/cluster);
The following environment variable is set:
| Env variable name | Description | Default | Comments |
| ----------------- | ----------- | ------- | -------- |
| REGISTRATION_STATUS | status of the registration to mIT
| CLUSTER_STATUS_SERVERS | number of servers in the cluster
| CLUSTER_STATUS_UPDATED_AT | last update of the cluster
| 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 that has the following structure:
{
"data": (array of all the data of the result),
"results": [{
"result": ([rp-retry](http://lib.mimik360.com:4873/request-retry) response),
"server": (cluster node that produced the result)
}],
"failures": [{
"error": (error produced by the request to a cluster node)
"server": (cluster node that produced the error)
}]
}
Kind: inner method of cluster
Returns: Promise - .
Category: async
Requires: module:@mimik/sumologic-winston-logger, module:@mimik/oauth-helper, module:@mimik/response-helper
Fulfil: object - Response of the request.
| Param | Type | Description | | --- | --- | --- | | options | object | Options for the request. Similar to axios options. The only difference is about the URL which does not contains the baseUrl, since this is provided by the cluster itself. |
cluster~register(correlationId, retry) ⇒ Promise
Register a server to 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 of rpCluster
The registration to mIT will retry at the frequency defined by REGISTRATION_RETRY. When the registration is completed a lease call in made to mIT on a regular basis. The lease time is defined by mIT. If the lease time is not defined it is set to 2 hours. When the cluster management is on, a concurrent registration is executed after a delay of aproxiatively 60 seconds to garantee the integrity of the cluster.
| Param | Type | Description | | --- | --- | --- | | correlationId | UUID.<string> | Correlation id to associate with the request. | | retry | boolean | Flag used when concurrent registration happens. |
cluster~unRegister(correlationId) ⇒ Promise
the return object is:
{
nbServers: "number of servers in the cluster" ,
serverid: "server Id",
errors: "optional array of errors which have occured while exiting",
}
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 in case of error, and error
| Param | Type | Description | | --- | --- | --- | | correlationId | UUID.<string> | Correlation id to associate with the request. |
cluster~createItResource(c, 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 | | --- | --- | --- | | c | object | context of the request (via openAPI). | | req | object | The HTTP request. | | res | object | The HTTP response. |
cluster~deleteServer(c, req, res)
Delete server endpoint.
Kind: inner method of cluster
Category: sync
Requires: module:@mimik/swagger-helper, module:@mimik/response-helper
| Param | Type | Description | | --- | --- | --- | | c | object | context of the request (via openAPI). | | req | object | The HTTP request. | | res | object | The HTTP response. |