/
options.ts
63 lines (54 loc) · 1.82 KB
/
options.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
/**
* Options that apply on LockJob
*/
export interface ILockJobOptions {
/**
* How long can jobs wait in queue before timing out. Overrides BetterLockOptions value.
*/
wait_timeout?: number | null;
/**
* How long can a job be executing before timing out. Null to disable timeout. Overrides BetterLockOptions value.
*/
execution_timeout?: number | null;
/**
* In any error produced by BetterLock, extend the stack trace to include incoming trace. Overrides BetterLockOptions value.
*/
extend_stack_traces?: boolean;
}
/**
* Options that apply on BetterLock instance
*/
export interface IOptions extends ILockJobOptions {
/**
* How long can jobs wait in queue before timing out. Null to disable timeout.
*/
wait_timeout?: number | null;
/**
* How long can a job be executing before timing out. Null to disable timeout.
* If you do that, though, and you have a swallowed callback, the lock can remain locked permanently.
*/
execution_timeout?: number | null;
/**
* Max queue size for waiting jobs.
*/
queue_size?: number | null;
/**
* Lock name. This will be written in all logs and error messages, to help you distinguish between different locks
*/
name?: string;
/**
* Whether to log the internal actions. Set to true to use console.log. Alternatively, provide your own function
*/
log?: boolean | ((msg: string) => void);
/**
* In any error produced by BetterLock, extend the stack trace to include incoming trace.
* Defaults to true.
*/
extend_stack_traces?: boolean;
/**
* Function that detects whether value returned by executor is a promise.
* This will ducktype-sniff the returned value. Depending on your Promise library of choice,
* you might want to tighten or loosen this bit.
*/
promise_tester?: (maybePromise: any) => boolean;
}