Skip to content

Commit

Permalink
feat: add Connection#ready
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-greene committed Nov 3, 2023
1 parent f72117b commit 8e3a061
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v4.4.0
Features:
- added a boolean getter, `connection.ready`: True if the connection is established and unblocked. Useful for healthchecks and the like.

# v4.3.0
Consumers now track some simple statistics: total messages acknowledged/requeued/dropped, and the current number of prefetched messages. Find these values in the `consumer.stats` object.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rabbitmq-client",
"version": "4.3.0",
"version": "4.4.0",
"description": "Robust, typed, RabbitMQ (0-9-1) client library",
"homepage": "https://github.com/cody-greene/node-rabbitmq-client",
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions src/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ export class Connection extends EventEmitter {
queueUnbind(params: MethodParams[Cmd.QueueUnbind]): Promise<void> {
return this._lazy().then(ch => ch.queueUnbind(params))
}

/** True if the connection is established and unblocked. See also {@link Connection#on:BLOCKED | Connection#on('connection.blocked')}) */
get ready(): boolean {
return this._state.readyState === READY_STATE.OPEN && !this._socket.writableCorked
}
}

function determineHeartbeat(x: number, y: number): number {
Expand Down

0 comments on commit 8e3a061

Please sign in to comment.