forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redlock.d.ts
64 lines (43 loc) · 1.64 KB
/
redlock.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Type definitions for Redlock
// Project: https://github.com/mike-marcacci/node-redlock
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../bluebird/bluebird.d.ts" />
/// <reference path="../redis/redis.d.ts" />
declare module "redlock" {
import * as redis from 'redis';
import * as Promise from 'bluebird';
namespace Redlock {
interface Callback<T> {
(err: any, value?: T): void;
}
interface Lock {
redlock: Redlock;
resource: string;
value: any;
expiration: number;
unlock(callback?: Callback<void>): Promise<void>;
extend(ttl: number, callback?: Callback<Lock>): Promise<Lock>;
}
interface Options {
driftFactor?: number;
retryCount?: number;
retryDelay?: number;
}
interface LockError extends Error {}
}
class Redlock {
driftFactor: number;
retryCount: number;
retryDelay: number;
servers: redis.RedisClient[];
constructor(clients: any[], options?: Redlock.Options);
acquire(resource: string, ttl: number, callback?: Redlock.Callback<Redlock.Lock>): Promise<Redlock.Lock>;
lock(resource: string, ttl: number, callback?: Redlock.Callback<Redlock.Lock>): Promise<Redlock.Lock>;
disposer(resource: string, ttl: number, errorHandler?: Redlock.Callback<void>): any; // bluebird Disposer
release(lock: Redlock.Lock, callback?: Redlock.Callback<void>): Promise<void>;
unlock(lock: Redlock.Lock, callback?: Redlock.Callback<void>): Promise<void>;
extend(lock: Redlock.Lock, ttl: number, callback?: Redlock.Callback<Redlock.Lock>): Promise<Redlock.Lock>;
}
export = Redlock;
}