Skip to content

Commit

Permalink
feat: Implement CLIENT GETREDIR (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Pastro authored Feb 21, 2021
1 parent bb046fb commit b372711
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,12 @@ XRANGE somestream - +
*/
clientGetName(): Promise<Bulk>;

/**
* Returns the client ID we are redirecting our tracking notifications to.
* @see https://redis.io/commands/client-getredir
*/
clientGetRedir(): Promise<Integer>;

/**
* Returns the id of the current redis connection.
*/
Expand Down
4 changes: 4 additions & 0 deletions redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ export class RedisImpl implements Redis {
return this.execBulkReply("CLIENT", "GETNAME");
}

clientGetRedir() {
return this.execIntegerReply("CLIENT", "GETREDIR");
}

clientID() {
return this.execIntegerReply("CLIENT", "ID");
}
Expand Down
15 changes: 15 additions & 0 deletions tests/connection_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ suite.test("client setname & getname", async () => {
assertEquals(await client.clientGetName(), "deno-redis");
});

suite.test("client getredir with no redirect", async () => {
assertEquals(await client.clientGetRedir(), -1);
});

suite.test("client getredir with redirect", async () => {
const tempClient = await newClient({ hostname: "127.0.0.1", port: 7003 });
try {
const id = await tempClient.clientID();
await client.clientTracking({ mode: "ON", redirect: id });
assertEquals(await client.clientGetRedir(), id);
} finally {
tempClient.close();
}
});

suite.test("client pause", async () => {
assertEquals(await client.clientPause(10), "OK");
});
Expand Down

0 comments on commit b372711

Please sign in to comment.