@daiso-tech/core 0.26.0 → 0.27.0
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 +10 -0
- package/dist/async/utilities/delay/delay.d.ts +1 -12
- package/dist/async/utilities/delay/delay.js +1 -12
- package/dist/async/utilities/delay/delay.js.map +1 -1
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +99 -65
- package/dist/async/utilities/lazy-promise/lazy-promise.js +151 -111
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/cache/contracts/_module-exports.d.ts +1 -0
- package/dist/cache/contracts/_module-exports.js +1 -0
- package/dist/cache/contracts/_module-exports.js.map +1 -1
- package/dist/cache/contracts/cache-adapter.contract.d.ts +19 -21
- package/dist/cache/contracts/cache-adapter.contract.js +1 -4
- package/dist/cache/contracts/cache-adapter.contract.js.map +1 -1
- package/dist/cache/contracts/cache-factory.contract.d.ts +1 -1
- package/dist/cache/contracts/cache.contract.d.ts +52 -88
- package/dist/cache/contracts/cache.contract.js +1 -2
- package/dist/cache/contracts/cache.contract.js.map +1 -1
- package/dist/cache/contracts/cache.errors.js +2 -5
- package/dist/cache/contracts/cache.errors.js.map +1 -1
- package/dist/cache/contracts/cache.events.d.ts +10 -10
- package/dist/cache/contracts/cache.events.js +2 -5
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/contracts/database-cache-adapter.contract.d.ts +89 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js +5 -0
- package/dist/cache/contracts/database-cache-adapter.contract.js.map +1 -0
- package/dist/cache/implementations/adapters/_module-exports.d.ts +0 -1
- package/dist/cache/implementations/adapters/_module-exports.js +0 -1
- package/dist/cache/implementations/adapters/_module-exports.js.map +1 -1
- package/dist/cache/implementations/adapters/{kysely-sqlite-cache-adapter → kysely-cache-adapter}/_module.d.ts +1 -1
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js +2 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/_module.js.map +1 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.d.ts +73 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js +224 -0
- package/dist/cache/implementations/adapters/kysely-cache-adapter/kysely-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +29 -39
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +45 -54
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +17 -33
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +43 -52
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js +38 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +27 -33
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +145 -197
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js +39 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-serde.js.map +1 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +16 -22
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +51 -132
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.d.ts +13 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js +69 -0
- package/dist/cache/implementations/adapters/redis-cache-adapter/utilities.js.map +1 -0
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +29 -40
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +46 -55
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/derivables/_module-exports.d.ts +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js +1 -1
- package/dist/cache/implementations/derivables/_module-exports.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/_module.d.ts +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js +1 -0
- package/dist/cache/implementations/derivables/cache/_module.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/cache.d.ts +122 -565
- package/dist/cache/implementations/derivables/cache/cache.js +342 -854
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.d.ts +21 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js +110 -0
- package/dist/cache/implementations/derivables/cache/database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.d.ts +9 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js +20 -0
- package/dist/cache/implementations/derivables/cache/is-database-cache-adapter.js.map +1 -0
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +65 -104
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +101 -85
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/_module-exports.d.ts +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js +1 -0
- package/dist/cache/implementations/test-utilities/_module-exports.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +9 -11
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +246 -247
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +16 -30
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +271 -996
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +60 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +698 -0
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js.map +1 -0
- package/dist/collection/contracts/async-collection.contract.d.ts +2 -3
- package/dist/collection/contracts/async-collection.contract.js +1 -12
- package/dist/collection/contracts/async-collection.contract.js.map +1 -1
- package/dist/collection/contracts/collection.contract.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.d.ts +1 -1
- package/dist/collection/contracts/collection.errors.js +3 -6
- package/dist/collection/contracts/collection.errors.js.map +1 -1
- package/dist/collection/implementations/_shared.d.ts +4 -4
- package/dist/collection/implementations/_shared.js +6 -9
- package/dist/collection/implementations/_shared.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +2 -2
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +6 -5
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +1 -1
- package/dist/collection/implementations/list-collection/list-collection.js +1 -1
- package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +0 -9
- package/dist/event-bus/contracts/event-bus.contract.d.ts +5 -5
- package/dist/event-bus/contracts/event-bus.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.errors.js +2 -5
- package/dist/event-bus/contracts/event-bus.errors.js.map +1 -1
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +9 -29
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +14 -35
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +1 -3
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +1 -7
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +8 -15
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +15 -34
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +78 -267
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +119 -323
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.d.ts +13 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js +42 -0
- package/dist/event-bus/implementations/derivables/event-bus/listener-store.js.map +1 -0
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +70 -96
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +100 -90
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +2 -48
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +31 -122
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +2 -50
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +41 -89
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/database-lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-adapter.contract.d.ts +0 -9
- package/dist/lock/contracts/lock-provider.contract.d.ts +1 -1
- package/dist/lock/contracts/lock.errors.js +2 -5
- package/dist/lock/contracts/lock.errors.js.map +1 -1
- package/dist/lock/contracts/lock.events.js +2 -5
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.d.ts +0 -5
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js +2 -21
- package/dist/lock/implementations/adapters/kysely-lock-adapter/kysely-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +11 -16
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +11 -20
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +7 -26
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +7 -35
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +13 -20
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +13 -37
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +4 -22
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +4 -31
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +12 -17
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +12 -21
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.d.ts +0 -2
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js +2 -8
- package/dist/lock/implementations/derivables/lock-provider/database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.d.ts +9 -0
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js +17 -0
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -0
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +115 -372
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +197 -455
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +15 -17
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js +42 -40
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-state.d.ts +3 -3
- package/dist/lock/implementations/derivables/lock-provider/lock-state.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +30 -754
- package/dist/lock/implementations/derivables/lock-provider/lock.js +94 -812
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +58 -161
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +116 -122
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +4 -5
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +172 -247
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +5 -8
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +93 -98
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js.map +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +15 -20
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +133 -137
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js +1 -2
- package/dist/serde/implementations/adapters/mongodb-serde/mongodb-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +1 -1
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js +1 -2
- package/dist/serde/implementations/adapters/redis-serde/redis-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js +1 -2
- package/dist/serde/implementations/adapters/sql-serde/sql-serde.js.map +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js.map +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +14 -14
- package/dist/serde/implementations/derivables/serde.js +14 -15
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +4 -4
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +5 -5
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +4 -4
- package/dist/utilities/_module-exports.d.ts +1 -2
- package/dist/utilities/_module-exports.js +1 -2
- package/dist/utilities/_module-exports.js.map +1 -1
- package/dist/utilities/classes/_module.d.ts +4 -0
- package/dist/utilities/classes/_module.js +5 -0
- package/dist/utilities/classes/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/_module.d.ts +2 -0
- package/dist/utilities/classes/key-prefixer/_module.js +3 -0
- package/dist/utilities/classes/key-prefixer/_module.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.d.ts +28 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js +5 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.contract.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +73 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +135 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.d.ts +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js +2 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/_module.js.map +1 -0
- package/dist/utilities/classes/kysely-table-name-transformer-plugin/kysely-table-name-transformer-plugin.js.map +1 -0
- package/dist/utilities/classes/pipeline/_module.d.ts +1 -0
- package/dist/utilities/classes/pipeline/_module.js +2 -0
- package/dist/utilities/classes/pipeline/_module.js.map +1 -0
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.d.ts +3 -2
- package/dist/utilities/{pipeline → classes/pipeline}/pipeline.js +3 -2
- package/dist/utilities/classes/pipeline/pipeline.js.map +1 -0
- package/dist/utilities/classes/time-span/_module.d.ts +1 -0
- package/dist/utilities/classes/time-span/_module.js +2 -0
- package/dist/utilities/classes/time-span/_module.js.map +1 -0
- package/dist/utilities/{time-span → classes/time-span}/time-span.d.ts +2 -1
- package/dist/utilities/{time-span → classes/time-span}/time-span.js +1 -0
- package/dist/utilities/classes/time-span/time-span.js.map +1 -0
- package/dist/utilities/contracts/_module.d.ts +2 -1
- package/dist/utilities/contracts/_module.js +2 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/prunable.contract.d.ts +11 -0
- package/dist/utilities/contracts/prunable.contract.js +5 -0
- package/dist/utilities/contracts/prunable.contract.js.map +1 -0
- package/dist/utilities/functions.d.ts +30 -2
- package/dist/utilities/functions.js +66 -4
- package/dist/utilities/functions.js.map +1 -1
- package/dist/utilities/types.d.ts +47 -14
- package/package.json +14 -13
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +0 -61
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +0 -318
- package/dist/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +0 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.d.ts +0 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js +0 -2
- package/dist/cache/implementations/adapters/no-op-cache-adapter/_module.js.map +0 -1
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +0 -22
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +0 -39
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js.map +0 -1
- package/dist/utilities/kysely/_module.d.ts +0 -1
- package/dist/utilities/kysely/_module.js +0 -2
- package/dist/utilities/kysely/_module.js.map +0 -1
- package/dist/utilities/kysely/kysely-table-name-transformer-plugin.js.map +0 -1
- package/dist/utilities/pipeline/_module.d.ts +0 -1
- package/dist/utilities/pipeline/_module.js +0 -2
- package/dist/utilities/pipeline/_module.js.map +0 -1
- package/dist/utilities/pipeline/pipeline.js.map +0 -1
- package/dist/utilities/time-span/_module.d.ts +0 -1
- package/dist/utilities/time-span/_module.js +0 -2
- package/dist/utilities/time-span/_module.js.map +0 -1
- package/dist/utilities/time-span/time-span.js.map +0 -1
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.d.ts +0 -0
- /package/dist/utilities/{kysely → classes/kysely-table-name-transformer-plugin}/kysely-table-name-transformer-plugin.js +0 -0
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Lock
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
5
|
-
import type
|
|
6
|
-
import
|
|
4
|
+
import type { Items, TimeSpan } from "../../../../utilities/_module-exports.js";
|
|
5
|
+
import { type IKey, type Invokable, type LazyPromiseable, type OneOrMore, type Result } from "../../../../utilities/_module-exports.js";
|
|
6
|
+
import { KeyAlreadyAcquiredLockError, type AquireBlockingSettings, type LockEvents } from "../../../../lock/contracts/_module-exports.js";
|
|
7
|
+
import { type ILock, type ILockAdapter } from "../../../../lock/contracts/_module-exports.js";
|
|
7
8
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
8
|
-
import type {
|
|
9
|
-
import {
|
|
10
|
-
import type { EventClass, EventInstance, Unsubscribe, IGroupableEventBus, IEventDispatcher } from "../../../../event-bus/contracts/_module-exports.js";
|
|
11
|
-
import { type ILockStateRecord } from "../../../../lock/implementations/derivables/lock-provider/lock-state.js";
|
|
9
|
+
import type { EventClass, EventInstance, IEventBus, IEventDispatcher, Unsubscribe } from "../../../../event-bus/contracts/_module-exports.js";
|
|
10
|
+
import type { LockState } from "../../../../lock/implementations/derivables/lock-provider/lock-state.js";
|
|
12
11
|
/**
|
|
13
12
|
* @internal
|
|
14
13
|
*/
|
|
15
14
|
export type ISerializedLock = {
|
|
16
|
-
group: string;
|
|
17
|
-
key: string
|
|
15
|
+
group: OneOrMore<string> | null;
|
|
16
|
+
key: OneOrMore<string>;
|
|
18
17
|
owner: string;
|
|
19
18
|
ttlInMs: number | null;
|
|
20
19
|
expirationInMs: number | null;
|
|
@@ -23,23 +22,19 @@ export type ISerializedLock = {
|
|
|
23
22
|
* @internal
|
|
24
23
|
*/
|
|
25
24
|
export type LockSettings = {
|
|
26
|
-
|
|
25
|
+
group: OneOrMore<string> | null;
|
|
26
|
+
createLazyPromise: <TValue = void>(asyncFn: () => PromiseLike<TValue>) => LazyPromise<TValue>;
|
|
27
|
+
adapterPromise: PromiseLike<ILockAdapter>;
|
|
28
|
+
lockState: LockState;
|
|
29
|
+
lockEventBus: IEventBus<LockEvents>;
|
|
27
30
|
lockProviderEventDispatcher: IEventDispatcher<LockEvents>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
key: IKey;
|
|
32
|
+
owner: OneOrMore<string>;
|
|
33
|
+
ttl: TimeSpan | null;
|
|
34
|
+
expirationInMs: number | null;
|
|
31
35
|
defaultBlockingInterval: TimeSpan;
|
|
32
36
|
defaultBlockingTime: TimeSpan;
|
|
33
37
|
defaultRefreshTime: TimeSpan;
|
|
34
|
-
ttl: TimeSpan | null;
|
|
35
|
-
expirationInMs: number | null;
|
|
36
|
-
lazyPromiseSettings: {
|
|
37
|
-
retryAttempts: number | null;
|
|
38
|
-
backoffPolicy: BackoffPolicy | null;
|
|
39
|
-
retryPolicy: RetryPolicy | null;
|
|
40
|
-
timeout: TimeSpan | null;
|
|
41
|
-
};
|
|
42
|
-
stateRecord: ILockStateRecord;
|
|
43
38
|
};
|
|
44
39
|
/**
|
|
45
40
|
* IMPORTANT: This class is not intended to be instantiated directly, instead it should be created by the <i>LockProvider</i> class instance.
|
|
@@ -50,483 +45,35 @@ export declare class Lock implements ILock {
|
|
|
50
45
|
* @internal
|
|
51
46
|
*/
|
|
52
47
|
static serialize(deserializedValue: Lock): ISerializedLock;
|
|
53
|
-
private readonly
|
|
48
|
+
private readonly createLazyPromise;
|
|
49
|
+
private readonly adapterPromise;
|
|
50
|
+
private readonly lockState;
|
|
54
51
|
private readonly lockEventBus;
|
|
55
|
-
private readonly
|
|
52
|
+
private readonly lockProviderEventDispatcher;
|
|
56
53
|
private readonly key;
|
|
57
54
|
private readonly owner;
|
|
58
55
|
private readonly ttl;
|
|
59
56
|
private readonly defaultBlockingInterval;
|
|
60
57
|
private readonly defaultBlockingTime;
|
|
61
58
|
private readonly defaultRefreshTime;
|
|
62
|
-
private readonly
|
|
63
|
-
private readonly state;
|
|
59
|
+
private readonly group;
|
|
64
60
|
/**
|
|
65
61
|
* @internal
|
|
66
62
|
*/
|
|
67
63
|
constructor(settings: LockSettings);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
77
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
78
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
79
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
80
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
81
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
82
|
-
*
|
|
83
|
-
* const eventBus = new EventBus({
|
|
84
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
85
|
-
* });
|
|
86
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
87
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
88
|
-
* serde,
|
|
89
|
-
* adapter: new MemoryLockAdapter({
|
|
90
|
-
* rootGroup: "@global"
|
|
91
|
-
* }),
|
|
92
|
-
* eventBus,
|
|
93
|
-
* });
|
|
94
|
-
*
|
|
95
|
-
* const lock = lockProvider.create("a");
|
|
96
|
-
*
|
|
97
|
-
* async function fn(): Promise<void> {
|
|
98
|
-
* await lock.run(async () => {
|
|
99
|
-
* console.log("START: ", 1);
|
|
100
|
-
* // Let’s pretend we’re doing async database work.
|
|
101
|
-
* await delay(TimeSpan.fromSeconds(2));
|
|
102
|
-
* console.log("END: ", 2);
|
|
103
|
-
* });
|
|
104
|
-
* }
|
|
105
|
-
*
|
|
106
|
-
* await Promise.allSettled([
|
|
107
|
-
* fn(),
|
|
108
|
-
* fn(),
|
|
109
|
-
* fn(),
|
|
110
|
-
* fn(),
|
|
111
|
-
* ]);
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* You can also pass an <i>{@link LazyPromise}</i> instead of async function.
|
|
115
|
-
* @example
|
|
116
|
-
* ```ts
|
|
117
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
118
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
119
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
120
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
121
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
122
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
123
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
124
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
125
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
126
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
127
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
128
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
129
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
130
|
-
*
|
|
131
|
-
* const eventBus = new EventBus({
|
|
132
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
133
|
-
* });
|
|
134
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
135
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
136
|
-
* serde,
|
|
137
|
-
* adapter: new MemoryLockAdapter({
|
|
138
|
-
* rootGroup: "@global"
|
|
139
|
-
* }),
|
|
140
|
-
* eventBus,
|
|
141
|
-
* });
|
|
142
|
-
*
|
|
143
|
-
* const cache: IGroupableCache = new Cache({
|
|
144
|
-
* // Let's pretend when the cache adapter increments a key it will occur in 2 async, get the value, increment the value in memory and update the key.
|
|
145
|
-
* adapter: new MemoryCacheAdapter({
|
|
146
|
-
* rootGroup: "@global"
|
|
147
|
-
* }),
|
|
148
|
-
* eventBus,
|
|
149
|
-
* });
|
|
150
|
-
* await cache.put("a", 0);
|
|
151
|
-
*
|
|
152
|
-
* const lock = lockProvider.create("a");
|
|
153
|
-
*
|
|
154
|
-
* async function fn(): Promise<void> {
|
|
155
|
-
* // The lock will ensure the key will be incremented correctly
|
|
156
|
-
* await lock.run(cache.increment("a", 1));
|
|
157
|
-
* }
|
|
158
|
-
*
|
|
159
|
-
* await Promise.allSettled([
|
|
160
|
-
* fn(),
|
|
161
|
-
* fn(),
|
|
162
|
-
* fn(),
|
|
163
|
-
* fn(),
|
|
164
|
-
* ]);
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
64
|
+
addListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
65
|
+
addListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
66
|
+
removeListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
67
|
+
removeListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
68
|
+
listenOnce<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
69
|
+
asPromise<TEventClass extends EventClass<LockEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
70
|
+
subscribe<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
71
|
+
subscribeMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
167
72
|
run<TValue = void>(asyncFn: LazyPromiseable<TValue>): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
168
|
-
/**
|
|
169
|
-
* @example
|
|
170
|
-
* ```ts
|
|
171
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
172
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
173
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
174
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
175
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
176
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
177
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
178
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
179
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
180
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
181
|
-
*
|
|
182
|
-
* const eventBus = new EventBus({
|
|
183
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
184
|
-
* });
|
|
185
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
186
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
187
|
-
* serde,
|
|
188
|
-
* adapter: new MemoryLockAdapter({
|
|
189
|
-
* rootGroup: "@global"
|
|
190
|
-
* }),
|
|
191
|
-
* eventBus,
|
|
192
|
-
* });
|
|
193
|
-
*
|
|
194
|
-
* const lock = lockProvider.create("a");
|
|
195
|
-
*
|
|
196
|
-
* async function fn(): Promise<void> {
|
|
197
|
-
* await lock.runOrFail(async () => {
|
|
198
|
-
* console.log("START: ", 1);
|
|
199
|
-
* // Let’s pretend we’re doing async database work.
|
|
200
|
-
* await delay(TimeSpan.fromSeconds(2));
|
|
201
|
-
* console.log("END: ", 2);
|
|
202
|
-
* })
|
|
203
|
-
* // Retries 4 times to acquire the lock, then throws an error.
|
|
204
|
-
* .setRetryAttempts(4);
|
|
205
|
-
* }
|
|
206
|
-
*
|
|
207
|
-
* await Promise.allSettled([
|
|
208
|
-
* fn(),
|
|
209
|
-
* fn(),
|
|
210
|
-
* fn(),
|
|
211
|
-
* fn(),
|
|
212
|
-
* ]);
|
|
213
|
-
* ```
|
|
214
|
-
*
|
|
215
|
-
* You can also pass an <i>{@link LazyPromise}</i> instead of async function.
|
|
216
|
-
* @example
|
|
217
|
-
* ```ts
|
|
218
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
219
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
220
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
221
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
222
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
223
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
224
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
225
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
226
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
227
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
228
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
229
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
230
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
231
|
-
*
|
|
232
|
-
* const eventBus = new EventBus({
|
|
233
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
234
|
-
* });
|
|
235
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
236
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
237
|
-
* serde,
|
|
238
|
-
* adapter: new MemoryLockAdapter({
|
|
239
|
-
* rootGroup: "@global"
|
|
240
|
-
* }),
|
|
241
|
-
* eventBus,
|
|
242
|
-
* });
|
|
243
|
-
*
|
|
244
|
-
* const cache: IGroupableCache = new Cache({
|
|
245
|
-
* // Let's pretend when the cache adapter increments a key it will occur in 2 async, get the value, increment the value in memory and update the key.
|
|
246
|
-
* adapter: new MemoryCacheAdapter({
|
|
247
|
-
* rootGroup: "@global"
|
|
248
|
-
* }),
|
|
249
|
-
* eventBus,
|
|
250
|
-
* });
|
|
251
|
-
* await cache.put("a", 0);
|
|
252
|
-
*
|
|
253
|
-
* const lock = lockProvider.create("a");
|
|
254
|
-
*
|
|
255
|
-
* async function fn(): Promise<void> {
|
|
256
|
-
* await lock
|
|
257
|
-
* // The lock will ensure the key will be incremented correctly
|
|
258
|
-
* .runOrFail(cache.increment("a", 1));
|
|
259
|
-
* // Retries 4 times to acquire the lock, then throws an error.
|
|
260
|
-
* .setRetryAttempts(4);
|
|
261
|
-
* }
|
|
262
|
-
*
|
|
263
|
-
* await Promise.allSettled([
|
|
264
|
-
* fn(),
|
|
265
|
-
* fn(),
|
|
266
|
-
* fn(),
|
|
267
|
-
* fn(),
|
|
268
|
-
* ]);
|
|
269
|
-
* ```
|
|
270
|
-
*/
|
|
271
73
|
runOrFail<TValue = void>(asyncFn: LazyPromiseable<TValue>): LazyPromise<TValue>;
|
|
272
|
-
/**
|
|
273
|
-
* @example
|
|
274
|
-
* ```ts
|
|
275
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
276
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
277
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
278
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
279
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
280
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
281
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
282
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
283
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
284
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
285
|
-
*
|
|
286
|
-
* const eventBus = new EventBus({
|
|
287
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
288
|
-
* });
|
|
289
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
290
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
291
|
-
* serde,
|
|
292
|
-
* adapter: new MemoryLockAdapter({
|
|
293
|
-
* rootGroup: "@global"
|
|
294
|
-
* }),
|
|
295
|
-
* eventBus,
|
|
296
|
-
* });
|
|
297
|
-
*
|
|
298
|
-
* const lock = lockProvider.create("a");
|
|
299
|
-
*
|
|
300
|
-
* async function fn(): Promise<void> {
|
|
301
|
-
* await lock.runBlocking(async () => {
|
|
302
|
-
* console.log("START: ", 1);
|
|
303
|
-
* // Let’s pretend we’re doing async database work.
|
|
304
|
-
* await delay(TimeSpan.fromSeconds(2));
|
|
305
|
-
* console.log("END: ", 2);
|
|
306
|
-
* });
|
|
307
|
-
* }
|
|
308
|
-
*
|
|
309
|
-
* await Promise.allSettled([
|
|
310
|
-
* fn(),
|
|
311
|
-
* fn(),
|
|
312
|
-
* fn(),
|
|
313
|
-
* fn(),
|
|
314
|
-
* ]);
|
|
315
|
-
* ```
|
|
316
|
-
*
|
|
317
|
-
* You can also pass an <i>{@link LazyPromise}</i> instead of async function.
|
|
318
|
-
* @example
|
|
319
|
-
* ```ts
|
|
320
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
321
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
322
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
323
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
324
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
325
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
326
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
327
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
328
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
329
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
330
|
-
* import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
|
|
331
|
-
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
|
|
332
|
-
* import type { IGroupableCache } from "@daiso-tech/core/cache/contracts";
|
|
333
|
-
*
|
|
334
|
-
* const eventBus = new EventBus({
|
|
335
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
336
|
-
* });
|
|
337
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
338
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
339
|
-
* serde,
|
|
340
|
-
* adapter: new MemoryLockAdapter({
|
|
341
|
-
* rootGroup: "@global"
|
|
342
|
-
* }),
|
|
343
|
-
* eventBus,
|
|
344
|
-
* });
|
|
345
|
-
*
|
|
346
|
-
* const cache: IGroupableCache = new Cache({
|
|
347
|
-
* // Let's pretend when the cache adapter increments a key it will occur in 2 async, get the value, increment the value in memory and update the key.
|
|
348
|
-
* adapter: new MemoryCacheAdapter({
|
|
349
|
-
* rootGroup: "@global"
|
|
350
|
-
* }),
|
|
351
|
-
* eventBus,
|
|
352
|
-
* });
|
|
353
|
-
* await cache.put("a", 0);
|
|
354
|
-
*
|
|
355
|
-
* const lock = lockProvider.create("a");
|
|
356
|
-
*
|
|
357
|
-
* async function fn(): Promise<void> {
|
|
358
|
-
* // The lock will ensure the key will be incremented correctly
|
|
359
|
-
* await lock.runBlocking(cache.increment("a", 1));
|
|
360
|
-
* }
|
|
361
|
-
*
|
|
362
|
-
* await Promise.allSettled([
|
|
363
|
-
* fn(),
|
|
364
|
-
* fn(),
|
|
365
|
-
* fn(),
|
|
366
|
-
* fn(),
|
|
367
|
-
* ]);
|
|
368
|
-
* ```
|
|
369
|
-
*/
|
|
370
74
|
runBlocking<TValue = void>(asyncFn: LazyPromiseable<TValue>, settings?: AquireBlockingSettings): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
371
|
-
/**
|
|
372
|
-
* @example
|
|
373
|
-
* ```ts
|
|
374
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
375
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
376
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
377
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
378
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
379
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
380
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
381
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
382
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
383
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
384
|
-
*
|
|
385
|
-
* const eventBus = new EventBus({
|
|
386
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
387
|
-
* });
|
|
388
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
389
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
390
|
-
* serde,
|
|
391
|
-
* adapter: new MemoryLockAdapter({
|
|
392
|
-
* rootGroup: "@global"
|
|
393
|
-
* }),
|
|
394
|
-
* eventBus,
|
|
395
|
-
* });
|
|
396
|
-
*
|
|
397
|
-
* const lock = lockProvider.create("a");
|
|
398
|
-
*
|
|
399
|
-
* async function fn(): Promise<void> {
|
|
400
|
-
* // Use try-finally when acquiring a lock to ensure it’s released if an error happens.
|
|
401
|
-
* try {
|
|
402
|
-
* const hasAquired = await lock.acquire();
|
|
403
|
-
* if (!hasAquired) {
|
|
404
|
-
* return;
|
|
405
|
-
* }
|
|
406
|
-
* console.log("START: ", 1);
|
|
407
|
-
* // Let’s pretend we’re doing async database work.
|
|
408
|
-
* await delay(TimeSpan.fromSeconds(2));
|
|
409
|
-
* console.log("END: ", 2);
|
|
410
|
-
* }
|
|
411
|
-
* finally {
|
|
412
|
-
* await lock.release();
|
|
413
|
-
* }
|
|
414
|
-
* }
|
|
415
|
-
*
|
|
416
|
-
* await Promise.allSettled([
|
|
417
|
-
* fn(),
|
|
418
|
-
* fn(),
|
|
419
|
-
* fn(),
|
|
420
|
-
* fn(),
|
|
421
|
-
* ]);
|
|
422
|
-
* ```
|
|
423
|
-
*/
|
|
424
75
|
acquire(): LazyPromise<boolean>;
|
|
425
|
-
/**
|
|
426
|
-
* @example
|
|
427
|
-
* ```ts
|
|
428
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
429
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
430
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
431
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
432
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
433
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
434
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
435
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
436
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
437
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
438
|
-
*
|
|
439
|
-
* const eventBus = new EventBus({
|
|
440
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
441
|
-
* });
|
|
442
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
443
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
444
|
-
* serde,
|
|
445
|
-
* adapter: new MemoryLockAdapter({
|
|
446
|
-
* rootGroup: "@global"
|
|
447
|
-
* }),
|
|
448
|
-
* eventBus,
|
|
449
|
-
* });
|
|
450
|
-
*
|
|
451
|
-
* const lock = lockProvider.create("a");
|
|
452
|
-
*
|
|
453
|
-
* async function fn(): Promise<void> {
|
|
454
|
-
* // Use try-finally when acquiring a lock to ensure it’s released if an error happens.
|
|
455
|
-
* try {
|
|
456
|
-
* // Retries 4 times to acquire the lock, then throws an error.
|
|
457
|
-
* await lock.acquireOrFail().setRetryAttempts(4);
|
|
458
|
-
* console.log("START: ", 1);
|
|
459
|
-
* // Let’s pretend we’re doing async database work.
|
|
460
|
-
* await delay(TimeSpan.fromSeconds(2));
|
|
461
|
-
* console.log("END: ", 2);
|
|
462
|
-
* }
|
|
463
|
-
* finally {
|
|
464
|
-
* await lock.release();
|
|
465
|
-
* }
|
|
466
|
-
* }
|
|
467
|
-
*
|
|
468
|
-
* await Promise.allSettled([
|
|
469
|
-
* fn(),
|
|
470
|
-
* fn(),
|
|
471
|
-
* fn(),
|
|
472
|
-
* fn(),
|
|
473
|
-
* ]);
|
|
474
|
-
* ```
|
|
475
|
-
*/
|
|
476
76
|
acquireOrFail(): LazyPromise<void>;
|
|
477
|
-
/**
|
|
478
|
-
* @example
|
|
479
|
-
* ```ts
|
|
480
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
481
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
482
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
483
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
484
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
485
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
486
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
487
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
488
|
-
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
489
|
-
* import { delay } from "@daiso-tech/core/async";
|
|
490
|
-
*
|
|
491
|
-
* const eventBus = new EventBus({
|
|
492
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
493
|
-
* });
|
|
494
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
495
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
496
|
-
* serde,
|
|
497
|
-
* adapter: new MemoryLockAdapter({
|
|
498
|
-
* rootGroup: "@global"
|
|
499
|
-
* }),
|
|
500
|
-
* eventBus,
|
|
501
|
-
* });
|
|
502
|
-
*
|
|
503
|
-
* const lock = lockProvider.create("a");
|
|
504
|
-
*
|
|
505
|
-
* async function fn(): Promise<void> {
|
|
506
|
-
* // Use try-finally when acquiring a lock to ensure it’s released if an error happens.
|
|
507
|
-
* try {
|
|
508
|
-
* const hasAquired = await lock.acquireBlocking();
|
|
509
|
-
* if (!hasAquired) {
|
|
510
|
-
* return;
|
|
511
|
-
* }
|
|
512
|
-
* console.log("START: ", 1);
|
|
513
|
-
* // Let’s pretend we’re doing async database work.
|
|
514
|
-
* await delay(TimeSpan.fromSeconds(2));
|
|
515
|
-
* console.log("END: ", 2);
|
|
516
|
-
* }
|
|
517
|
-
* finally {
|
|
518
|
-
* await lock.release();
|
|
519
|
-
* }
|
|
520
|
-
* }
|
|
521
|
-
*
|
|
522
|
-
* await Promise.allSettled([
|
|
523
|
-
* fn(),
|
|
524
|
-
* fn(),
|
|
525
|
-
* fn(),
|
|
526
|
-
* fn(),
|
|
527
|
-
* ]);
|
|
528
|
-
* ```
|
|
529
|
-
*/
|
|
530
77
|
acquireBlocking(settings?: AquireBlockingSettings): LazyPromise<boolean>;
|
|
531
78
|
release(): LazyPromise<boolean>;
|
|
532
79
|
releaseOrFail(): LazyPromise<void>;
|
|
@@ -537,275 +84,4 @@ export declare class Lock implements ILock {
|
|
|
537
84
|
refreshOrFail(ttl?: TimeSpan): LazyPromise<void>;
|
|
538
85
|
getRemainingTime(): LazyPromise<TimeSpan | null>;
|
|
539
86
|
getOwner(): LazyPromise<string>;
|
|
540
|
-
/**
|
|
541
|
-
* You can listen to different events of the current <i>Lock</i> class instance.
|
|
542
|
-
*
|
|
543
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
544
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
545
|
-
* @example
|
|
546
|
-
* ```ts
|
|
547
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
548
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
549
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
550
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
551
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
552
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
553
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
554
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
555
|
-
*
|
|
556
|
-
* const eventBus = new EventBus({
|
|
557
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
558
|
-
* });
|
|
559
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
560
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
561
|
-
* serde,
|
|
562
|
-
* adapter: new MemoryLockAdapter({
|
|
563
|
-
* rootGroup: "@global"
|
|
564
|
-
* }),
|
|
565
|
-
* eventBus,
|
|
566
|
-
* });
|
|
567
|
-
*
|
|
568
|
-
* const lock = lockProvider.create("a");
|
|
569
|
-
*
|
|
570
|
-
* const listener: Invokable <LockEvents> = event => {
|
|
571
|
-
* console.log(event);
|
|
572
|
-
* }
|
|
573
|
-
* await lock.addListener(KeyAcquiredLockEvent, listener);
|
|
574
|
-
* await lock.acquire();
|
|
575
|
-
* ```
|
|
576
|
-
*/
|
|
577
|
-
addListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
578
|
-
/**
|
|
579
|
-
* You can listen to different events of the current <i>Lock</i> class instance.
|
|
580
|
-
*
|
|
581
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
582
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
583
|
-
* @example
|
|
584
|
-
* ```ts
|
|
585
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
586
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
587
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
588
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
589
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
590
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
591
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
592
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
593
|
-
*
|
|
594
|
-
* const eventBus = new EventBus({
|
|
595
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
596
|
-
* });
|
|
597
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
598
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
599
|
-
* serde,
|
|
600
|
-
* adapter: new MemoryLockAdapter({
|
|
601
|
-
* rootGroup: "@global"
|
|
602
|
-
* }),
|
|
603
|
-
* eventBus,
|
|
604
|
-
* });
|
|
605
|
-
*
|
|
606
|
-
* const lock = lockProvider.create("a");
|
|
607
|
-
*
|
|
608
|
-
* const listener: Invokable <LockEvents> = event => {
|
|
609
|
-
* console.log(event);
|
|
610
|
-
* }
|
|
611
|
-
* await lock.addListenerMany([KeyAcquiredLockEvent], listener);
|
|
612
|
-
* await lock.acquire();
|
|
613
|
-
* ```
|
|
614
|
-
*/
|
|
615
|
-
addListenerMany<TEventClass extends EventClass<LockEvents>>(events: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
616
|
-
/**
|
|
617
|
-
* You can listen to different events of the current <i>Lock</i> class instance.
|
|
618
|
-
*
|
|
619
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
620
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
621
|
-
* @example
|
|
622
|
-
* ```ts
|
|
623
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
624
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
625
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
626
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
627
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
628
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
629
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
630
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
631
|
-
*
|
|
632
|
-
* const eventBus = new EventBus({
|
|
633
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
634
|
-
* });
|
|
635
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
636
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
637
|
-
* serde,
|
|
638
|
-
* adapter: new MemoryLockAdapter({
|
|
639
|
-
* rootGroup: "@global"
|
|
640
|
-
* }),
|
|
641
|
-
* eventBus,
|
|
642
|
-
* });
|
|
643
|
-
*
|
|
644
|
-
* const lock = lockProvider.create("a");
|
|
645
|
-
*
|
|
646
|
-
* const listener: Invokable <LockEvents> = event => {
|
|
647
|
-
* console.log(event);
|
|
648
|
-
* }
|
|
649
|
-
* await lock.addListener(KeyAcquiredLockEvent, listener);
|
|
650
|
-
* await lock.removeListener(KeyAcquiredLockEvent, listener);
|
|
651
|
-
* await lock.acquire();
|
|
652
|
-
* ```
|
|
653
|
-
*/
|
|
654
|
-
removeListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
655
|
-
/**
|
|
656
|
-
* You can listen to different events of the current <i>Lock</i> class instance.
|
|
657
|
-
*
|
|
658
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
659
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
660
|
-
* @example
|
|
661
|
-
* ```ts
|
|
662
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
663
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
664
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
665
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
666
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
667
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
668
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
669
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
670
|
-
*
|
|
671
|
-
* const eventBus = new EventBus({
|
|
672
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
673
|
-
* });
|
|
674
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
675
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
676
|
-
* serde,
|
|
677
|
-
* adapter: new MemoryLockAdapter({
|
|
678
|
-
* rootGroup: "@global"
|
|
679
|
-
* }),
|
|
680
|
-
* eventBus,
|
|
681
|
-
* });
|
|
682
|
-
*
|
|
683
|
-
* const lock = lockProvider.create("a");
|
|
684
|
-
*
|
|
685
|
-
* const listener: Invokable <LockEvents> = event => {
|
|
686
|
-
* console.log(event);
|
|
687
|
-
* }
|
|
688
|
-
* await lock.addListenerMany([KeyAcquiredLockEvent], listener);
|
|
689
|
-
* await lock.removeListenerMany([KeyAcquiredLockEvent], listener);
|
|
690
|
-
* await lock.acquire();
|
|
691
|
-
* ```
|
|
692
|
-
*/
|
|
693
|
-
removeListenerMany<TEventClass extends EventClass<LockEvents>>(events: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
694
|
-
/**
|
|
695
|
-
* You can listen to different events of the current <i>Lock</i> class instance.
|
|
696
|
-
*
|
|
697
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
698
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
699
|
-
* @example
|
|
700
|
-
* ```ts
|
|
701
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
702
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
703
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
704
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
705
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
706
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
707
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
708
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
709
|
-
*
|
|
710
|
-
* const eventBus = new EventBus({
|
|
711
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
712
|
-
* });
|
|
713
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
714
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
715
|
-
* serde,
|
|
716
|
-
* adapter: new MemoryLockAdapter({
|
|
717
|
-
* rootGroup: "@global"
|
|
718
|
-
* }),
|
|
719
|
-
* eventBus,
|
|
720
|
-
* });
|
|
721
|
-
*
|
|
722
|
-
* const lock = lockProvider.create("a");
|
|
723
|
-
*
|
|
724
|
-
* const listener: Invokable <LockEvents> = event => {
|
|
725
|
-
* console.log(event);
|
|
726
|
-
* }
|
|
727
|
-
* await lock.listenOnce(KeyAcquiredLockEvent, listener);
|
|
728
|
-
* await lock.acquire();
|
|
729
|
-
* ```
|
|
730
|
-
*/
|
|
731
|
-
listenOnce<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
732
|
-
asPromise<TEventClass extends EventClass<LockEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
733
|
-
/**
|
|
734
|
-
* You can listen to different events of the current <i>Lock</i> class instance.
|
|
735
|
-
*
|
|
736
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
737
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
738
|
-
* @example
|
|
739
|
-
* ```ts
|
|
740
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
741
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
742
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
743
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
744
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
745
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
746
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
747
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
748
|
-
*
|
|
749
|
-
* const eventBus = new EventBus({
|
|
750
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
751
|
-
* });
|
|
752
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
753
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
754
|
-
* serde,
|
|
755
|
-
* adapter: new MemoryLockAdapter({
|
|
756
|
-
* rootGroup: "@global"
|
|
757
|
-
* }),
|
|
758
|
-
* eventBus,
|
|
759
|
-
* });
|
|
760
|
-
*
|
|
761
|
-
* const lock = lockProvider.create("a");
|
|
762
|
-
*
|
|
763
|
-
* const listener: Invokable <LockEvents> = event => {
|
|
764
|
-
* console.log(event);
|
|
765
|
-
* }
|
|
766
|
-
* const unsubscribe = await lock.subscribe(KeyAcquiredLockEvent, listener);
|
|
767
|
-
* await lock.acquire();
|
|
768
|
-
* await unsubscribe();
|
|
769
|
-
* ```
|
|
770
|
-
*/
|
|
771
|
-
subscribe<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
772
|
-
/**
|
|
773
|
-
* You can listen to different events of the current <i>Lock</i> class instance.
|
|
774
|
-
*
|
|
775
|
-
* Refer to <i>{@link LockEvents}</i>, to se all events dispatched by <i>LockProvider</i> class instance.
|
|
776
|
-
* Refer to <i>{@link IEventListenable}</i> for details on how the method works.
|
|
777
|
-
* @example
|
|
778
|
-
* ```ts
|
|
779
|
-
* import { type IGroupableLockProvider, type LockEvents, KeyAcquiredLockEvent } from "@daiso-tech/core/lock/contracts";
|
|
780
|
-
* import { LockProvider } from "@daiso-tech/core/lock/implementations/derivables";
|
|
781
|
-
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/implementations/adapters";
|
|
782
|
-
* import type { Invokable } from "@daiso-tech/core/event-bus/contracts";
|
|
783
|
-
* import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
|
|
784
|
-
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
|
|
785
|
-
* import { Serde } from "@daiso-tech/core/serde/implementations/derivables";
|
|
786
|
-
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/implementations/adapters";
|
|
787
|
-
*
|
|
788
|
-
* const eventBus = new EventBus({
|
|
789
|
-
* adapter: new MemoryEventBusAdapter({ rootGroup: "@global" })
|
|
790
|
-
* });
|
|
791
|
-
* const serde = new Serde(SuperJsonSerdeAdapter);
|
|
792
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
793
|
-
* serde,
|
|
794
|
-
* adapter: new MemoryLockAdapter({
|
|
795
|
-
* rootGroup: "@global"
|
|
796
|
-
* }),
|
|
797
|
-
* eventBus,
|
|
798
|
-
* });
|
|
799
|
-
*
|
|
800
|
-
* const lock = lockProvider.create("a");
|
|
801
|
-
*
|
|
802
|
-
* const listener: Invokable <LockEvents> = event => {
|
|
803
|
-
* console.log(event);
|
|
804
|
-
* }
|
|
805
|
-
* const unsubscribe = await lock.subscribeMany([KeyAcquiredLockEvent], listener);
|
|
806
|
-
* await lock.acquire();
|
|
807
|
-
* await unsubscribe();
|
|
808
|
-
* ```
|
|
809
|
-
*/
|
|
810
|
-
subscribeMany<TEventClass extends EventClass<LockEvents>>(events: TEventClass[], listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
811
87
|
}
|