npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@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~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. |