@lsdsoftware/connection-manager
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Connection Manager

Maintaining connection state is a royal pain in the behind. This utility class takes a connect() method and:

  • Only call it to create a connection when needed
  • Automatically retry on failure
  • Automatically reconnect if the previous connection was closed
  • Properly handle shutdown sequence

Usage

const conMgr = new ConnectionManager({
  async connect() {
    //...
    return connection
  },
  retryDelay: 10*1000
})

//wherever you need the connection
const connection = await conMgr.get()

//shutdown
conMgr.shutdown()

Readme

Keywords

none

Package Sidebar

Install

npm i @lsdsoftware/connection-manager

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

8.97 kB

Total Files

10

Last publish

Collaborators

  • ken107