1.0.0 • Published 2 years ago

@lsdsoftware/connection-manager v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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()
1.0.1

2 years ago

1.0.0

2 years ago