Skip to content

Commit

Permalink
Merge pull request #756 from amqp-node/connection-update-secret
Browse files Browse the repository at this point in the history
Add connection-update-secret
  • Loading branch information
cressie176 authored Apr 11, 2024
2 parents bbe579e + c4da58b commit 992919c
Show file tree
Hide file tree
Showing 6 changed files with 658 additions and 622 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
RABBITMQ_SRC_VERSION=rabbitmq_v3_2_1
RABBITMQ_SRC_VERSION=v3.12.13
JSON=amqp-rabbitmq-0.9.1.json
RABBITMQ_CODEGEN=https://raw.githubusercontent.com/rabbitmq/rabbitmq-codegen
AMQP_JSON=$(RABBITMQ_CODEGEN)/$(RABBITMQ_SRC_VERSION)/$(JSON)
AMQP_JSON=https://raw.githubusercontent.com/rabbitmq/rabbitmq-server/$(RABBITMQ_SRC_VERSION)/deps/rabbitmq_codegen/$(JSON)

NODEJS_VERSIONS='10.21' '11.15' '12.18' '13.14' '14.5' '15.8' '16.3.0' '18.1.0' '20.10.0'

Expand Down
4 changes: 4 additions & 0 deletions lib/callback_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class CallbackModel extends EventEmitter {
this.connection.close(cb);
}

updateSecret(newSecret, reason, cb) {
this.connection._updateSecret(newSecret, reason, cb);
}

createChannel (cb) {
var ch = new Channel(this.connection);
ch.open(function (err, ok) {
Expand Down
4 changes: 4 additions & 0 deletions lib/channel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class ChannelModel extends EventEmitter {
return promisify(this.connection.close.bind(this.connection))();
}

updateSecret(newSecret, reason) {
return promisify(this.connection._updateSecret.bind(this.connection))(newSecret, reason);
}

async createChannel() {
const channel = new Channel(this.connection);
await channel.open();
Expand Down
11 changes: 11 additions & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ class Connection extends EventEmitter {
this.emit('close', maybeErr);
}

_updateSecret(newSecret, reason, cb) {
this.sendMethod(0, defs.ConnectionUpdateSecret, {
newSecret,
reason
});
this.once('update-secret-ok', cb);
}

// ===
startHeartbeater () {
if (this.heartbeat === 0)
Expand Down Expand Up @@ -611,6 +619,9 @@ function channel0(connection) {
else if (f.id === defs.ConnectionUnblocked) {
connection.emit('unblocked');
}
else if (f.id === defs.ConnectionUpdateSecretOk) {
connection.emit('update-secret-ok');
}
else {
connection.closeWithError(
fmt("Unexpected frame on channel 0"),
Expand Down
Loading

0 comments on commit 992919c

Please sign in to comment.