@orpc/experimental-lock 2.0.0-beta.47 → 2.0.0-beta.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/adapters/base-redis.d.mts +58 -62
- package/dist/adapters/base-redis.mjs +35 -37
- package/dist/adapters/memory.d.mts +31 -35
- package/dist/adapters/memory.mjs +72 -68
- package/dist/adapters/redis.d.mts +22 -26
- package/dist/adapters/redis.mjs +39 -36
- package/dist/adapters/upstash.d.mts +21 -25
- package/dist/adapters/upstash.mjs +26 -26
- package/dist/error.d.mts +12 -0
- package/dist/error.mjs +10 -0
- package/dist/index.d.mts +3 -81
- package/dist/index.mjs +3 -49
- package/dist/middleware.d.mts +69 -0
- package/dist/middleware.mjs +46 -0
- package/dist/types.d.mts +43 -0
- package/dist/types.mjs +1 -0
- package/package.json +5 -5
- package/dist/adapters/base-redis.d.ts +0 -66
- package/dist/adapters/memory.d.ts +0 -38
- package/dist/adapters/redis.d.ts +0 -28
- package/dist/adapters/upstash.d.ts +0 -27
- package/dist/index.d.ts +0 -81
- package/dist/shared/experimental-lock.CoYbYjCJ.mjs +0 -13
- package/dist/shared/experimental-lock.D9u4cJfq.d.mts +0 -46
- package/dist/shared/experimental-lock.D9u4cJfq.d.ts +0 -46
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Promisable } from '@orpc/shared';
|
|
2
|
-
|
|
3
|
-
interface LockOptions {
|
|
4
|
-
/**
|
|
5
|
-
* How long the lock is held before it expires automatically, in milliseconds.
|
|
6
|
-
* Guards against holders that never release the lock, such as a crashed process.
|
|
7
|
-
*
|
|
8
|
-
* @default the adapter default
|
|
9
|
-
*/
|
|
10
|
-
ttl?: number | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* How long to wait for the lock to become available, in milliseconds.
|
|
13
|
-
*
|
|
14
|
-
* @default the adapter default
|
|
15
|
-
*/
|
|
16
|
-
timeout?: number | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Aborts waiting for the lock. Has no effect once the lock is acquired.
|
|
19
|
-
*/
|
|
20
|
-
signal?: AbortSignal | undefined;
|
|
21
|
-
}
|
|
22
|
-
interface LockCallbackOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Whether the lock was acquired only after waiting for another holder to release it.
|
|
25
|
-
* `false` means the lock was acquired immediately.
|
|
26
|
-
*/
|
|
27
|
-
waited: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Standard interface for running work under a lock, so that work sharing
|
|
31
|
-
* the same key never runs concurrently.
|
|
32
|
-
* Implement it for custom strategies, or use one of the provided adapters.
|
|
33
|
-
*
|
|
34
|
-
* @see {@link https://orpc.dev/docs/helpers/lock | Lock Helpers}
|
|
35
|
-
*/
|
|
36
|
-
interface Locker {
|
|
37
|
-
/**
|
|
38
|
-
* Runs `fn` while holding the lock for `key`, and releases the lock afterwards,
|
|
39
|
-
* even when `fn` throws.
|
|
40
|
-
*
|
|
41
|
-
* @throws {LockTimeoutError} when the lock cannot be acquired before the timeout elapses
|
|
42
|
-
*/
|
|
43
|
-
lock<T>(key: string, fn: (options: LockCallbackOptions) => Promisable<T>, options?: LockOptions): Promise<T>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type { Locker as L, LockCallbackOptions as a, LockOptions as b };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Promisable } from '@orpc/shared';
|
|
2
|
-
|
|
3
|
-
interface LockOptions {
|
|
4
|
-
/**
|
|
5
|
-
* How long the lock is held before it expires automatically, in milliseconds.
|
|
6
|
-
* Guards against holders that never release the lock, such as a crashed process.
|
|
7
|
-
*
|
|
8
|
-
* @default the adapter default
|
|
9
|
-
*/
|
|
10
|
-
ttl?: number | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* How long to wait for the lock to become available, in milliseconds.
|
|
13
|
-
*
|
|
14
|
-
* @default the adapter default
|
|
15
|
-
*/
|
|
16
|
-
timeout?: number | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Aborts waiting for the lock. Has no effect once the lock is acquired.
|
|
19
|
-
*/
|
|
20
|
-
signal?: AbortSignal | undefined;
|
|
21
|
-
}
|
|
22
|
-
interface LockCallbackOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Whether the lock was acquired only after waiting for another holder to release it.
|
|
25
|
-
* `false` means the lock was acquired immediately.
|
|
26
|
-
*/
|
|
27
|
-
waited: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Standard interface for running work under a lock, so that work sharing
|
|
31
|
-
* the same key never runs concurrently.
|
|
32
|
-
* Implement it for custom strategies, or use one of the provided adapters.
|
|
33
|
-
*
|
|
34
|
-
* @see {@link https://orpc.dev/docs/helpers/lock | Lock Helpers}
|
|
35
|
-
*/
|
|
36
|
-
interface Locker {
|
|
37
|
-
/**
|
|
38
|
-
* Runs `fn` while holding the lock for `key`, and releases the lock afterwards,
|
|
39
|
-
* even when `fn` throws.
|
|
40
|
-
*
|
|
41
|
-
* @throws {LockTimeoutError} when the lock cannot be acquired before the timeout elapses
|
|
42
|
-
*/
|
|
43
|
-
lock<T>(key: string, fn: (options: LockCallbackOptions) => Promisable<T>, options?: LockOptions): Promise<T>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type { Locker as L, LockCallbackOptions as a, LockOptions as b };
|