Skip to content

Commit 0ce0dd4

Browse files
authored
Merge pull request #211 from shenie/master
Make it possible to wait until all redis instances finish the quit routine
2 parents 7e67cdc + e2733cf commit 0ce0dd4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/redis-pubsub.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ export class RedisPubSub implements PubSubEngine {
147147
return this.redisPublisher;
148148
}
149149

150-
public close(): void {
151-
this.redisPublisher.quit();
152-
this.redisSubscriber.quit();
150+
public close(): Promise<any> {
151+
return Promise.all([
152+
this.redisPublisher.quit(),
153+
this.redisSubscriber.quit(),
154+
]);
153155
}
154156

155157
private onMessage(pattern: string, channel: string, message: string) {

src/test/tests.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ describe('RedisPubSub', () => {
5353

5454
it('should verify close calls pub and sub quit methods', done => {
5555
const pubSub = new RedisPubSub(mockOptions);
56-
pubSub.close();
57-
expect(quitSpy.callCount).to.equal(2);
58-
done();
56+
57+
pubSub.close()
58+
.then(() => {
59+
expect(quitSpy.callCount).to.equal(2);
60+
done();
61+
})
62+
.catch(done);
5963
});
6064

6165
it('can subscribe to specific redis channel and called when a message is published on it', done => {

0 commit comments

Comments
 (0)