@daiso-tech/core 0.26.1 → 0.28.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 +13 -3
- 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 +143 -71
- package/dist/async/utilities/lazy-promise/lazy-promise.js +223 -142
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/retry/retry-or-fail.d.ts +2 -0
- package/dist/async/utilities/retry/retry-or-fail.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 +144 -96
- 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/{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/no-op-cache-adapter/no-op-cache-adapter.d.ts +14 -13
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +19 -17
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-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 -41
- 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 +269 -507
- package/dist/cache/implementations/derivables/cache/cache.js +538 -822
- 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 +69 -105
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +117 -87
- 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 +5 -21
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +12 -8
- 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 +2 -4
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +2 -8
- 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 +85 -289
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +128 -325
- 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 +103 -86
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +135 -77
- 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 +20 -6
- package/dist/lock/contracts/lock.contract.d.ts +37 -8
- 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/_module-exports.d.ts +1 -0
- package/dist/lock/implementations/adapters/_module-exports.js +1 -0
- package/dist/lock/implementations/adapters/_module-exports.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/no-op-lock-adapter/_module.d.ts +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js +2 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/_module.js.map +1 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +17 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +24 -0
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js.map +1 -0
- 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 +14 -20
- 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.js +1 -5
- package/dist/lock/implementations/derivables/lock-provider/is-database-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +181 -369
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +259 -407
- 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 +194 -680
- package/dist/lock/implementations/derivables/lock-provider/lock.js +284 -744
- 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 +106 -143
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +173 -101
- 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 +295 -145
- 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 +3 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +2 -1
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js.map +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 +2 -3
- package/dist/utilities/_module-exports.js +2 -3
- 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/{_constants.d.ts → constants.d.ts} +0 -3
- package/dist/utilities/constants.js +5 -0
- package/dist/utilities/constants.js.map +1 -0
- package/dist/utilities/contracts/_module.d.ts +3 -1
- package/dist/utilities/contracts/_module.js +3 -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/contracts/sqlite-database.contract.d.ts +26 -0
- package/dist/utilities/contracts/sqlite-database.contract.js +5 -0
- package/dist/utilities/contracts/sqlite-database.contract.js.map +1 -0
- package/dist/utilities/functions.d.ts +34 -2
- package/dist/utilities/functions.js +72 -4
- package/dist/utilities/functions.js.map +1 -1
- package/dist/utilities/types.d.ts +49 -16
- 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/utilities/_constants.js +0 -8
- package/dist/utilities/_constants.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,484 +45,274 @@ 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
|
-
private createLayPromise;
|
|
69
64
|
/**
|
|
65
|
+
* You can listen to the following <i>{@link LockEvents}</i> of the <i>{@link Lock}</i> instance.
|
|
66
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
67
|
+
*/
|
|
68
|
+
addListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* You can listen to the following <i>{@link LockEvents}</i> of the <i>{@link Lock}</i> instance.
|
|
71
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
72
|
+
*/
|
|
73
|
+
addListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* You can listen to the following <i>{@link LockEvents}</i> of the <i>{@link Lock}</i> instance.
|
|
76
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
77
|
+
*/
|
|
78
|
+
removeListener<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* You can listen to the following <i>{@link LockEvents}</i> of the <i>{@link Lock}</i> instance.
|
|
81
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
82
|
+
*/
|
|
83
|
+
removeListenerMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* You can listen to the following <i>{@link LockEvents}</i> of lock instance.
|
|
86
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
87
|
+
*/
|
|
88
|
+
listenOnce<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* You can listen to the following <i>{@link LockEvents}</i> of lock instance.
|
|
91
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
92
|
+
*/
|
|
93
|
+
asPromise<TEventClass extends EventClass<LockEvents>>(event: TEventClass): LazyPromise<EventInstance<TEventClass>>;
|
|
94
|
+
/**
|
|
95
|
+
* You can listen to the following <i>{@link LockEvents}</i> of lock instance.
|
|
96
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
97
|
+
*/
|
|
98
|
+
subscribe<TEventClass extends EventClass<LockEvents>>(event: TEventClass, listener: Invokable<EventInstance<TEventClass>>): LazyPromise<Unsubscribe>;
|
|
99
|
+
/**
|
|
100
|
+
* You can listen to the following <i>{@link LockEvents}</i> of lock instance.
|
|
101
|
+
* To understand how this method works, refer to <i>{@link IEventListenable}</i>.
|
|
102
|
+
*/
|
|
103
|
+
subscribeMany<TEventClassArr extends EventClass<LockEvents>[]>(events: [...TEventClassArr], listener: Invokable<EventInstance<Items<TEventClassArr>>>): LazyPromise<Unsubscribe>;
|
|
104
|
+
/**
|
|
105
|
+
* You can pass in a sync function or async function.
|
|
70
106
|
* @example
|
|
71
107
|
* ```ts
|
|
72
|
-
* import {
|
|
73
|
-
* import {
|
|
74
|
-
* import {
|
|
75
|
-
* import
|
|
76
|
-
* import {
|
|
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";
|
|
108
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
109
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
110
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
111
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
112
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
82
113
|
*
|
|
83
|
-
* const
|
|
84
|
-
* adapter: new
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
88
|
-
* serde,
|
|
89
|
-
* adapter: new MemoryLockAdapter({
|
|
90
|
-
* rootGroup: "@global"
|
|
91
|
-
* }),
|
|
92
|
-
* eventBus,
|
|
114
|
+
* const lockProvider = new LockProvider({
|
|
115
|
+
* adapter: new MemoryLockAdapter(),
|
|
116
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
117
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
93
118
|
* });
|
|
94
119
|
*
|
|
95
120
|
* const lock = lockProvider.create("a");
|
|
96
121
|
*
|
|
97
|
-
* async
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* console.log("END: ", 2);
|
|
103
|
-
* });
|
|
104
|
-
* }
|
|
105
|
-
*
|
|
106
|
-
* await Promise.allSettled([
|
|
107
|
-
* fn(),
|
|
108
|
-
* fn(),
|
|
109
|
-
* fn(),
|
|
110
|
-
* fn(),
|
|
111
|
-
* ]);
|
|
122
|
+
* await lock.run(async () => {
|
|
123
|
+
* console.log("START");
|
|
124
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
125
|
+
* console.log("END");
|
|
126
|
+
* });
|
|
112
127
|
* ```
|
|
113
128
|
*
|
|
114
|
-
* You can also pass
|
|
129
|
+
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
115
130
|
* @example
|
|
116
131
|
* ```ts
|
|
117
|
-
* import {
|
|
118
|
-
* import {
|
|
119
|
-
* import {
|
|
120
|
-
* import
|
|
121
|
-
* import {
|
|
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";
|
|
132
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
133
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
134
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
135
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
136
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
130
137
|
*
|
|
131
|
-
* const
|
|
132
|
-
* adapter: new
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
136
|
-
* serde,
|
|
137
|
-
* adapter: new MemoryLockAdapter({
|
|
138
|
-
* rootGroup: "@global"
|
|
139
|
-
* }),
|
|
140
|
-
* eventBus,
|
|
138
|
+
* const lockProvider = new LockProvider({
|
|
139
|
+
* adapter: new MemoryLockAdapter(),
|
|
140
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
141
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
141
142
|
* });
|
|
142
143
|
*
|
|
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
144
|
* const lock = lockProvider.create("a");
|
|
153
145
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* fn(),
|
|
162
|
-
* fn(),
|
|
163
|
-
* fn(),
|
|
164
|
-
* ]);
|
|
146
|
+
* await lock.run(
|
|
147
|
+
* new LazyPromise(async () => {
|
|
148
|
+
* console.log("START");
|
|
149
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
150
|
+
* console.log("END");
|
|
151
|
+
* })
|
|
152
|
+
* );
|
|
165
153
|
* ```
|
|
166
154
|
*/
|
|
167
155
|
run<TValue = void>(asyncFn: LazyPromiseable<TValue>): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
168
156
|
/**
|
|
157
|
+
* You can pass in a sync function or async function.
|
|
169
158
|
* @example
|
|
170
159
|
* ```ts
|
|
171
|
-
* import {
|
|
172
|
-
* import {
|
|
173
|
-
* import {
|
|
174
|
-
* import
|
|
175
|
-
* import {
|
|
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";
|
|
160
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
161
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
162
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
163
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
164
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
181
165
|
*
|
|
182
|
-
* const
|
|
183
|
-
* adapter: new
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
187
|
-
* serde,
|
|
188
|
-
* adapter: new MemoryLockAdapter({
|
|
189
|
-
* rootGroup: "@global"
|
|
190
|
-
* }),
|
|
191
|
-
* eventBus,
|
|
166
|
+
* const lockProvider = new LockProvider({
|
|
167
|
+
* adapter: new MemoryLockAdapter(),
|
|
168
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
169
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
192
170
|
* });
|
|
193
171
|
*
|
|
194
172
|
* const lock = lockProvider.create("a");
|
|
195
173
|
*
|
|
196
|
-
* async
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
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
|
-
* ]);
|
|
174
|
+
* await lock.runOrFail(async () => {
|
|
175
|
+
* console.log("START");
|
|
176
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
177
|
+
* console.log("END");
|
|
178
|
+
* });
|
|
213
179
|
* ```
|
|
214
180
|
*
|
|
215
|
-
* You can also pass
|
|
181
|
+
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
216
182
|
* @example
|
|
217
183
|
* ```ts
|
|
218
|
-
* import {
|
|
219
|
-
* import {
|
|
220
|
-
* import {
|
|
221
|
-
* import
|
|
222
|
-
* import {
|
|
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";
|
|
184
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
185
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
186
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
187
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
188
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
231
189
|
*
|
|
232
|
-
* const
|
|
233
|
-
* adapter: new
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
237
|
-
* serde,
|
|
238
|
-
* adapter: new MemoryLockAdapter({
|
|
239
|
-
* rootGroup: "@global"
|
|
240
|
-
* }),
|
|
241
|
-
* eventBus,
|
|
190
|
+
* const lockProvider = new LockProvider({
|
|
191
|
+
* adapter: new MemoryLockAdapter(),
|
|
192
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
193
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
242
194
|
* });
|
|
243
195
|
*
|
|
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
196
|
* const lock = lockProvider.create("a");
|
|
254
197
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* .
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
* await Promise.allSettled([
|
|
264
|
-
* fn(),
|
|
265
|
-
* fn(),
|
|
266
|
-
* fn(),
|
|
267
|
-
* fn(),
|
|
268
|
-
* ]);
|
|
198
|
+
* await lock.runOrFail(
|
|
199
|
+
* new LazyPromise(async () => {
|
|
200
|
+
* console.log("START");
|
|
201
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
202
|
+
* console.log("END");
|
|
203
|
+
* })
|
|
204
|
+
* );
|
|
269
205
|
* ```
|
|
270
206
|
*/
|
|
271
207
|
runOrFail<TValue = void>(asyncFn: LazyPromiseable<TValue>): LazyPromise<TValue>;
|
|
272
208
|
/**
|
|
209
|
+
* You can pass in a sync function or async function.
|
|
273
210
|
* @example
|
|
274
211
|
* ```ts
|
|
275
|
-
* import {
|
|
276
|
-
* import {
|
|
277
|
-
* import {
|
|
278
|
-
* import
|
|
279
|
-
* import {
|
|
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";
|
|
212
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
213
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
214
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
215
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
216
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
285
217
|
*
|
|
286
|
-
* const
|
|
287
|
-
* adapter: new
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
291
|
-
* serde,
|
|
292
|
-
* adapter: new MemoryLockAdapter({
|
|
293
|
-
* rootGroup: "@global"
|
|
294
|
-
* }),
|
|
295
|
-
* eventBus,
|
|
218
|
+
* const lockProvider = new LockProvider({
|
|
219
|
+
* adapter: new MemoryLockAdapter(),
|
|
220
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
221
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
296
222
|
* });
|
|
297
223
|
*
|
|
298
224
|
* const lock = lockProvider.create("a");
|
|
299
225
|
*
|
|
300
|
-
* async
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* console.log("END: ", 2);
|
|
306
|
-
* });
|
|
307
|
-
* }
|
|
308
|
-
*
|
|
309
|
-
* await Promise.allSettled([
|
|
310
|
-
* fn(),
|
|
311
|
-
* fn(),
|
|
312
|
-
* fn(),
|
|
313
|
-
* fn(),
|
|
314
|
-
* ]);
|
|
226
|
+
* await lock.runBlocking(async () => {
|
|
227
|
+
* console.log("START");
|
|
228
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
229
|
+
* console.log("END");
|
|
230
|
+
* });
|
|
315
231
|
* ```
|
|
316
232
|
*
|
|
317
|
-
* You can also pass
|
|
233
|
+
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
318
234
|
* @example
|
|
319
235
|
* ```ts
|
|
320
|
-
* import {
|
|
321
|
-
* import {
|
|
322
|
-
* import {
|
|
323
|
-
* import
|
|
324
|
-
* import {
|
|
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";
|
|
236
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
237
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
238
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
239
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
240
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
333
241
|
*
|
|
334
|
-
* const
|
|
335
|
-
* adapter: new
|
|
242
|
+
* const lockProvider = new LockProvider({
|
|
243
|
+
* adapter: new MemoryLockAdapter(),
|
|
244
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
245
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
336
246
|
* });
|
|
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
247
|
*
|
|
355
248
|
* const lock = lockProvider.create("a");
|
|
356
249
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* fn(),
|
|
365
|
-
* fn(),
|
|
366
|
-
* fn(),
|
|
367
|
-
* ]);
|
|
250
|
+
* await lock.runBlocking(
|
|
251
|
+
* new LazyPromise(async () => {
|
|
252
|
+
* console.log("START");
|
|
253
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
254
|
+
* console.log("END");
|
|
255
|
+
* })
|
|
256
|
+
* );
|
|
368
257
|
* ```
|
|
369
258
|
*/
|
|
370
259
|
runBlocking<TValue = void>(asyncFn: LazyPromiseable<TValue>, settings?: AquireBlockingSettings): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
371
260
|
/**
|
|
261
|
+
* You can pass in a sync function or async function.
|
|
372
262
|
* @example
|
|
373
263
|
* ```ts
|
|
374
|
-
* import {
|
|
375
|
-
* import {
|
|
376
|
-
* import {
|
|
377
|
-
* import
|
|
378
|
-
* import {
|
|
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";
|
|
264
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
265
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
266
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
267
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
268
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
384
269
|
*
|
|
385
|
-
* const
|
|
386
|
-
* adapter: new
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
390
|
-
* serde,
|
|
391
|
-
* adapter: new MemoryLockAdapter({
|
|
392
|
-
* rootGroup: "@global"
|
|
393
|
-
* }),
|
|
394
|
-
* eventBus,
|
|
270
|
+
* const lockProvider = new LockProvider({
|
|
271
|
+
* adapter: new MemoryLockAdapter(),
|
|
272
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
273
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
395
274
|
* });
|
|
396
275
|
*
|
|
397
276
|
* const lock = lockProvider.create("a");
|
|
398
277
|
*
|
|
399
|
-
* async
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
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
|
-
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,
|
|
278
|
+
* await lock.runBlockingOrFail(async () => {
|
|
279
|
+
* console.log("START");
|
|
280
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
281
|
+
* console.log("END");
|
|
449
282
|
* });
|
|
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
283
|
* ```
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
/**
|
|
284
|
+
*
|
|
285
|
+
* You can also pass in a <i>{@link LazyPromise}</i>. This is useful because all other components in this library returns <i>{@link LazyPromise}</i>.
|
|
478
286
|
* @example
|
|
479
287
|
* ```ts
|
|
480
|
-
* import {
|
|
481
|
-
* import {
|
|
482
|
-
* import {
|
|
483
|
-
* import
|
|
484
|
-
* import {
|
|
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";
|
|
288
|
+
* import { LockProvider } from "@daiso-tech/core/lock";
|
|
289
|
+
* import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
290
|
+
* import { KeyPrefixer, TimeSpan, LazyPromise } from "@daiso-tech/core/utilities";
|
|
291
|
+
* import { Serde } from "@daiso-tech/core/adapter";
|
|
292
|
+
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/adapter/adapters";
|
|
490
293
|
*
|
|
491
|
-
* const
|
|
492
|
-
* adapter: new
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
* const lockProvider: IGroupableLockProvider = new LockProvider({
|
|
496
|
-
* serde,
|
|
497
|
-
* adapter: new MemoryLockAdapter({
|
|
498
|
-
* rootGroup: "@global"
|
|
499
|
-
* }),
|
|
500
|
-
* eventBus,
|
|
294
|
+
* const lockProvider = new LockProvider({
|
|
295
|
+
* adapter: new MemoryLockAdapter(),
|
|
296
|
+
* keyPrefixer: new KeyPrefixer("lock"),
|
|
297
|
+
* serde: new Serde(new SuperJsonSerdeAdapter())
|
|
501
298
|
* });
|
|
502
299
|
*
|
|
503
300
|
* const lock = lockProvider.create("a");
|
|
504
301
|
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
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
|
-
* ]);
|
|
302
|
+
* await lock.runBlockingOrFail(
|
|
303
|
+
* new LazyPromise(async () => {
|
|
304
|
+
* console.log("START");
|
|
305
|
+
* await LazyPromise.delay(TimeSpan.fromSeconds(10));
|
|
306
|
+
* console.log("END");
|
|
307
|
+
* })
|
|
308
|
+
* );
|
|
528
309
|
* ```
|
|
529
310
|
*/
|
|
311
|
+
runBlockingOrFail<TValue = void>(asyncFn: LazyPromiseable<TValue>, settings?: AquireBlockingSettings): LazyPromise<TValue>;
|
|
312
|
+
acquire(): LazyPromise<boolean>;
|
|
313
|
+
acquireOrFail(): LazyPromise<void>;
|
|
530
314
|
acquireBlocking(settings?: AquireBlockingSettings): LazyPromise<boolean>;
|
|
315
|
+
acquireBlockingOrFail(settings?: AquireBlockingSettings): LazyPromise<void>;
|
|
531
316
|
release(): LazyPromise<boolean>;
|
|
532
317
|
releaseOrFail(): LazyPromise<void>;
|
|
533
318
|
forceRelease(): LazyPromise<void>;
|
|
@@ -537,275 +322,4 @@ export declare class Lock implements ILock {
|
|
|
537
322
|
refreshOrFail(ttl?: TimeSpan): LazyPromise<void>;
|
|
538
323
|
getRemainingTime(): LazyPromise<TimeSpan | null>;
|
|
539
324
|
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
325
|
}
|