Skip to content

fix #2458 - add support for WAITAOF #2536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/client/lib/client/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ import * as SWAPDB from '../commands/SWAPDB';
import * as TIME from '../commands/TIME';
import * as UNWATCH from '../commands/UNWATCH';
import * as WAIT from '../commands/WAIT';
import * as WAITAOF from '../commands/WAITAOF';

export default {
...CLUSTER_COMMANDS,
Expand Down Expand Up @@ -358,5 +359,7 @@ export default {
UNWATCH,
unwatch: UNWATCH,
WAIT,
wait: WAIT
wait: WAIT,
WAITAOF,
waitAOF: WAITAOF
};
23 changes: 23 additions & 0 deletions packages/client/lib/commands/WAITAOF.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './WAITAOF';

describe('WAITAOF', () => {
testUtils.isVersionGreaterThanHook([7, 2]);

describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments(1, 0, 0),
['WAITAOF', '1', '0', '0']
);
});
});

testUtils.testWithClient('client.wait', async client => {
assert.equal(
await client.waitAOF(1, 0, 0),
[1, 0]
);
}, GLOBAL.SERVERS.OPEN);
});
16 changes: 16 additions & 0 deletions packages/client/lib/commands/WAITAOF.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { RedisCommandArguments } from '.';

export function transformArguments(
numlocal: number,
numreplicas: number,
timeout: number
): RedisCommandArguments {
return [
'WAITAOF',
numlocal.toString(),
numreplicas.toString(),
timeout.toString()
];
}

export declare function transformReply(): Array<[number, number]>;