Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rentspree/lightship

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rentspree/lightship

liveness and readiness wrapper using lightship for node.js

  • 0.2.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41
increased by95.24%
Maintainers
3
Weekly downloads
 
Created
Source

@rentspree/lightship

A lightship module for support kubernetes liveness and readiness by @rentspree

Description

This module is a simple wrapper of the original lightship library which helps to easily initialize the ready callback functions for multiple source of ready interconnected services being used by the application (eg. database) or configuration loading of the application.

Features

  • add createReadiness which help to split lightship signalReady to multiple functions
  • server exposes on paths /health /live and /ready as the original lightship does but listen on port 13000 by default
  • add enableLog option to print lightship logs
  • add randomPortOnLocal to reserve random port behavior when the process is run on local as the original lightship does, default to false

Install

npm install --save @rentspree/lightship

Usage

Readiness
import createLightship from "@rentspree/lightship"

const { createReadiness } = createLightship()
const [ mongooseDbReady, expressReady, senecaReady ] = createReadiness(3)

// for mongoose connection
mongoose.connect(/* connectionString */)
mongoose.connection.on('connected', ()=> mongooseDbReady())

// for express
const app = express();
app.listen(3000, ()=> expressReady())

// for seneca
require('seneca')({ some_options: 123 })
  .use('community-plugin-1', {some_config: SOME_CONFIG})
  .use('community-plugin-2')
  .listen(/* ... */)
  .client(/* ... */)
  .ready(()=> senecaReady())

in case of making service back to not ready state, we get functions by 2 ways ..

const [ mongooseDbReady ] = createReadiness()

// first way, return from ready function call
const mongooseNotReady = mongooseDbReady()
mongooseNotReady()

// second way, by property `toNotReady` of ready function
mongooseDbReady.toNotReady()

License

MIT © RentSpree

Keywords

FAQs

Package last updated on 21 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc