Skip to content

Releases: transcovo/node-amqp-bus

Handling client connection `close` event

07 Mar 14:18
6b1ea1e
Compare
Choose a tag to compare

This release improves how apps handle when the client connection to the server is closed abruptly (such as a restart of the rabbitmq server), by exiting the current process, while giving the app ways to cleanup properly.
(the orchestrator of the env. should then spawn a new instance instead)

Added:

Client EventEmitter interface:

  • close_cleanup: emitted once, when handling a close connection event.
    It provides a timeout (defaut = 200ms) before executing a client.close(forceClose = true),
    for the host app to execute any cleanup operations (such as closing a mongodb client).

Client options:

  • @param {Number|undefined} [options.processExitCleanupTimeout] :
    the time in ms that is (at least) waited for close cleanup operations. (default: 200ms)
  • @param {Number|undefined} [options.processExitTimeout] :
    the time in ms that is (at least) waited before exiting process. (default: 0ms)

Changes:

  • client.close(forceClose = false)
    Closes the client. Returns a Promise. When passing a truthy forceClose, close() will also exit(1) the current process, so when handling erroneous case that you can't recover from, one should call close(true).