@mimik/cluster
v5.1.4
Published
cluster management for mimik microservices
Readme
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 | | |
Example
import cluster from '@mimik/cluster';cluster~rpCluster(options) ⇒ Promise
The response is an object with the following structure:
{
"data": [ 'array of all successful response payloads' ],
"results": [
{
"result": (response from the underlying HTTP client),
"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 url MUST be a path only; the base URL is supplied by each cluster node. If options.token is provided, it is augmented with { cluster: true }; otherwise a { cluster: true } token is attached. |
cluster~createItResource(con, req, res)
Create IT resource endpoint.
Kind: inner method of cluster
Category: async
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: async
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. |
cluster~register(correlationId, retry) ⇒ Promise
Register a server with mIT.
Kind: inner method of cluster
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 config.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 | string | Correlation ID to associate with the request. |
| retry | boolean | Pass false for the initial registration. Used internally when the module recursively invokes itself for concurrent registration (~60s after first success) to guarantee cluster integrity. |
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
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 | string | Correlation ID to associate with the request. |
