@daiso-tech/core 0.31.0 → 0.32.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/dist/async/_module-exports.d.ts +1 -0
- package/dist/async/_module-exports.js +1 -0
- package/dist/async/_module-exports.js.map +1 -1
- package/dist/async/async.events.d.ts +82 -0
- package/dist/async/async.events.js +59 -0
- package/dist/async/async.events.js.map +1 -0
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.d.ts +15 -0
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js +50 -0
- package/dist/async/utilities/lazy-promise/lazy-promise-event-bus.js.map +1 -0
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.d.ts +23 -0
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js +44 -0
- package/dist/async/utilities/lazy-promise/lazy-promise-listener.contract.js.map +1 -0
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +101 -51
- package/dist/async/utilities/lazy-promise/lazy-promise.js +155 -96
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/retry/retry-or-fail.d.ts +1 -1
- package/dist/async/utilities/retry/retry-or-fail.js +1 -1
- package/dist/async/utilities/retry/retry-or-fail.js.map +1 -1
- package/dist/async/utilities/retry/retry.d.ts +1 -1
- package/dist/async/utilities/retry/retry.js.map +1 -1
- package/dist/cache/contracts/cache.contract.d.ts +2 -2
- package/dist/cache/implementations/derivables/cache/cache.d.ts +20 -159
- package/dist/cache/implementations/derivables/cache/cache.js +14 -174
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +11 -32
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +10 -52
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +5 -5
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +5 -5
- package/dist/collection/implementations/_shared.d.ts +2 -0
- package/dist/collection/implementations/_shared.js +2 -0
- package/dist/collection/implementations/_shared.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +5 -8
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +5 -19
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +5 -5
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +5 -5
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +18 -13
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +14 -33
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +9 -35
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +8 -54
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/lock/contracts/lock.contract.d.ts +4 -4
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +1 -2
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +1 -2
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +47 -24
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +40 -40
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +0 -204
- package/dist/lock/implementations/derivables/lock-provider/lock.js +0 -204
- 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 +11 -37
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +10 -59
- 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 +1 -2
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +1 -2
- 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 +0 -1
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +0 -1
- 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 +1 -1
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +1 -1
- package/dist/serde/contracts/flexible-serde.contract.d.ts +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +7 -7
- package/dist/serde/implementations/derivables/serde.js +7 -7
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +0 -1
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +0 -1
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js.map +1 -1
- package/dist/utilities/classes/_module.d.ts +1 -0
- package/dist/utilities/classes/_module.js +1 -0
- package/dist/utilities/classes/_module.js.map +1 -1
- package/dist/utilities/classes/sync-event-bus/_module.d.ts +1 -0
- package/dist/utilities/classes/sync-event-bus/_module.js +2 -0
- package/dist/utilities/classes/sync-event-bus/_module.js.map +1 -0
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.d.ts +16 -0
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.js +53 -0
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.js.map +1 -0
- package/dist/utilities/contracts/_module.d.ts +1 -0
- package/dist/utilities/contracts/_module.js +1 -0
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +13 -0
- package/dist/utilities/contracts/sync-event-bus-listenable.js +5 -0
- package/dist/utilities/contracts/sync-event-bus-listenable.js.map +1 -0
- package/dist/utilities/functions/invokable.d.ts +4 -0
- package/dist/utilities/functions/invokable.js +9 -0
- package/dist/utilities/functions/invokable.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
|
-
import type { LazyPromiseSettingsBase } from "../../../../async/_module-exports.js";
|
|
5
4
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
6
5
|
import type { EventClass, EventInstance, EventListener, Unsubscribe } from "../../../../event-bus/contracts/_module-exports.js";
|
|
7
6
|
import { type IEventBus, type IGroupableEventBus, type IEventBusAdapter, type BaseEvent } from "../../../../event-bus/contracts/_module-exports.js";
|
|
8
|
-
import type { AsyncFactoryable, IKeyPrefixer, OneOrMore, Items } from "../../../../utilities/_module-exports.js";
|
|
7
|
+
import type { AsyncFactoryable, IKeyPrefixer, OneOrMore, Items, Factory, AsyncLazy } from "../../../../utilities/_module-exports.js";
|
|
9
8
|
/**
|
|
10
9
|
*
|
|
11
10
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
12
11
|
* @group Derivables
|
|
13
12
|
*/
|
|
14
|
-
export type EventBusSettingsBase =
|
|
13
|
+
export type EventBusSettingsBase = {
|
|
15
14
|
keyPrefixer: IKeyPrefixer;
|
|
15
|
+
/**
|
|
16
|
+
* You can pass a <i>{@link Factory}</i> of <i>{@link LazyPromise}</i> to configure default settings for all <i>{@link LazyPromise}</i> instances used in the <i>EventBus</i> class.
|
|
17
|
+
* @default
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { LazyPromise } from "@daiso-tech/core/async";
|
|
20
|
+
*
|
|
21
|
+
* (invokable) => new LazyPromise(invokable)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
lazyPromiseFactory?: Factory<AsyncLazy<any>, LazyPromise<any>>;
|
|
16
25
|
};
|
|
17
26
|
/**
|
|
18
27
|
*
|
|
@@ -36,20 +45,16 @@ export type EventBusSettings = EventBusSettingsBase & {
|
|
|
36
45
|
*/
|
|
37
46
|
export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements IGroupableEventBus<TEvents> {
|
|
38
47
|
private readonly adapterFactoryable;
|
|
39
|
-
private readonly retryAttempts;
|
|
40
|
-
private readonly backoffPolicy;
|
|
41
|
-
private readonly retryPolicy;
|
|
42
|
-
private readonly retryTimeout;
|
|
43
|
-
private readonly totalTimeout;
|
|
44
48
|
private readonly store;
|
|
45
49
|
private readonly adapterPromise;
|
|
50
|
+
private readonly lazyPromiseFactory;
|
|
46
51
|
private keyPrefixer;
|
|
47
52
|
/**
|
|
48
53
|
* @example
|
|
49
54
|
* ```ts
|
|
50
55
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
51
56
|
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
52
|
-
* import { KeyPrefixer } from "@daiso-tech/utilities";
|
|
57
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
53
58
|
*
|
|
54
59
|
* const eventBus = new EventBus({
|
|
55
60
|
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
@@ -63,11 +68,11 @@ export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements
|
|
|
63
68
|
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
64
69
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
65
70
|
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
66
|
-
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/utilities";
|
|
71
|
+
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
67
72
|
*
|
|
68
|
-
* type Store = Partial<Record<string, IEventBusAdapter
|
|
73
|
+
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
69
74
|
*
|
|
70
|
-
*
|
|
75
|
+
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
71
76
|
* return (prefix) => {
|
|
72
77
|
* let adapter = store[prefix];
|
|
73
78
|
* if (adapter === undefined) {
|
|
@@ -91,7 +96,7 @@ export declare class EventBus<TEvents extends BaseEvent = BaseEvent> implements
|
|
|
91
96
|
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
92
97
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
93
98
|
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
94
|
-
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/utilities";
|
|
99
|
+
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
95
100
|
*
|
|
96
101
|
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
97
102
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
5
|
import { UnableToDispatchEventBusError, UnableToRemoveListenerEventBusError, UnableToAddListenerEventBusError, } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
|
-
import { getConstructorName, resolveAsyncFactoryable, resolveInvokable, } from "../../../../utilities/_module-exports.js";
|
|
6
|
+
import { getConstructorName, resolveAsyncFactoryable, resolveFactory, resolveInvokable, } from "../../../../utilities/_module-exports.js";
|
|
7
7
|
import { ListenerStore } from "../../../../event-bus/implementations/derivables/event-bus/listener-store.js";
|
|
8
8
|
/**
|
|
9
9
|
* <i>EventBus</i> class can be derived from any <i>{@link IEventBusAdapter}</i>.
|
|
@@ -13,20 +13,16 @@ import { ListenerStore } from "../../../../event-bus/implementations/derivables/
|
|
|
13
13
|
*/
|
|
14
14
|
export class EventBus {
|
|
15
15
|
adapterFactoryable;
|
|
16
|
-
retryAttempts;
|
|
17
|
-
backoffPolicy;
|
|
18
|
-
retryPolicy;
|
|
19
|
-
retryTimeout;
|
|
20
|
-
totalTimeout;
|
|
21
16
|
store = new ListenerStore();
|
|
22
17
|
adapterPromise;
|
|
18
|
+
lazyPromiseFactory;
|
|
23
19
|
keyPrefixer;
|
|
24
20
|
/**
|
|
25
21
|
* @example
|
|
26
22
|
* ```ts
|
|
27
23
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
28
24
|
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
29
|
-
* import { KeyPrefixer } from "@daiso-tech/utilities";
|
|
25
|
+
* import { KeyPrefixer } from "@daiso-tech/core/utilities";
|
|
30
26
|
*
|
|
31
27
|
* const eventBus = new EventBus({
|
|
32
28
|
* keyPrefixer: new KeyPrefixer("event-bus"),
|
|
@@ -40,11 +36,11 @@ export class EventBus {
|
|
|
40
36
|
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
41
37
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
42
38
|
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
43
|
-
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/utilities";
|
|
39
|
+
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
44
40
|
*
|
|
45
|
-
* type Store = Partial<Record<string, IEventBusAdapter
|
|
41
|
+
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
46
42
|
*
|
|
47
|
-
*
|
|
43
|
+
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
48
44
|
* return (prefix) => {
|
|
49
45
|
* let adapter = store[prefix];
|
|
50
46
|
* if (adapter === undefined) {
|
|
@@ -68,7 +64,7 @@ export class EventBus {
|
|
|
68
64
|
* import type { IEventBusAdapter } from "@daiso-tech/core/event-bus/contracts";
|
|
69
65
|
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
70
66
|
* import { EventBus } from "@daiso-tech/core/event-bus";
|
|
71
|
-
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/utilities";
|
|
67
|
+
* import { KeyPrefixer, type IFactoryObject, type Promiseable } from "@daiso-tech/core/utilities";
|
|
72
68
|
*
|
|
73
69
|
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
74
70
|
*
|
|
@@ -93,33 +89,20 @@ export class EventBus {
|
|
|
93
89
|
* ```
|
|
94
90
|
*/
|
|
95
91
|
constructor(settings) {
|
|
96
|
-
const { keyPrefixer, adapter,
|
|
97
|
-
this.
|
|
92
|
+
const { keyPrefixer, adapter, lazyPromiseFactory = (invokable) => new LazyPromise(invokable), } = settings;
|
|
93
|
+
this.lazyPromiseFactory = resolveFactory(lazyPromiseFactory);
|
|
98
94
|
this.adapterFactoryable = adapter;
|
|
99
95
|
this.keyPrefixer = keyPrefixer;
|
|
100
|
-
this.retryAttempts = retryAttempts;
|
|
101
|
-
this.backoffPolicy = backoffPolicy;
|
|
102
|
-
this.retryPolicy = retryPolicy;
|
|
103
|
-
this.retryTimeout = retryTimeout;
|
|
104
96
|
this.adapterPromise = new LazyPromise(() => resolveAsyncFactoryable(this.adapterFactoryable, this.keyPrefixer.keyPrefix));
|
|
105
97
|
}
|
|
106
98
|
createLazyPromise(asyncFn) {
|
|
107
|
-
return
|
|
108
|
-
retryAttempts: this.retryAttempts,
|
|
109
|
-
backoffPolicy: this.backoffPolicy,
|
|
110
|
-
retryPolicy: this.retryPolicy,
|
|
111
|
-
retryTimeout: this.retryTimeout,
|
|
112
|
-
totalTimeout: this.totalTimeout,
|
|
113
|
-
});
|
|
99
|
+
return this.lazyPromiseFactory(asyncFn);
|
|
114
100
|
}
|
|
115
101
|
withGroup(group) {
|
|
116
102
|
return new EventBus({
|
|
117
103
|
keyPrefixer: this.keyPrefixer.withGroup(group),
|
|
118
104
|
adapter: this.adapterFactoryable,
|
|
119
|
-
|
|
120
|
-
backoffPolicy: this.backoffPolicy,
|
|
121
|
-
retryPolicy: this.retryPolicy,
|
|
122
|
-
retryTimeout: this.retryTimeout,
|
|
105
|
+
lazyPromiseFactory: this.lazyPromiseFactory,
|
|
123
106
|
});
|
|
124
107
|
}
|
|
125
108
|
getGroup() {
|
|
@@ -206,11 +189,9 @@ export class EventBus {
|
|
|
206
189
|
});
|
|
207
190
|
}
|
|
208
191
|
asPromise(event) {
|
|
209
|
-
return
|
|
210
|
-
this.listenOnce(event, resolve).then((
|
|
211
|
-
|
|
212
|
-
reject);
|
|
213
|
-
}));
|
|
192
|
+
return LazyPromise.fromCallback((resolve, reject) => {
|
|
193
|
+
this.listenOnce(event, resolve).then(() => { }, reject);
|
|
194
|
+
});
|
|
214
195
|
}
|
|
215
196
|
subscribeOnce(event, listener) {
|
|
216
197
|
return this.createLazyPromise(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus/event-bus.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus/event-bus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,OAAO,EAKH,6BAA6B,EAC7B,mCAAmC,EACnC,gCAAgC,GACnC,MAAM,0CAA0C,CAAC;AAalD,OAAO,EACH,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,gBAAgB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oEAAoE,CAAC;AAyCnG;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IAGA,kBAAkB,CAA6B;IAC/C,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;IAC5B,cAAc,CAAgC;IAC9C,kBAAkB,CAGjC;IACM,WAAW,CAAe;IAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsEG;IACH,YAAY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CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC5B,SAAS,EAAE,SAAS,CAAC,QAAQ;oBAC7B,KAAK;iBACR,CAAC,CAAC;qBACF,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CACrC,CAAC;gBACN,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACtB,MAAM,IAAI,6BAA6B,CACnC,iBAAiB,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAC1I,KAAK,CACR,CAAC;YACN,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ,CAAC,KAAc;QACnB,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE;YACrC,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module EventBus
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { LazyPromise } from "../../../../async/_module-exports.js";
|
|
5
5
|
import { type IGroupableEventBus, type IEventBusFactory, type BaseEvent } from "../../../../event-bus/contracts/_module-exports.js";
|
|
6
6
|
import { type EventBusAdapterFactoryable, type EventBusSettingsBase } from "../../../../event-bus/implementations/derivables/event-bus/_module.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { AsyncLazy, Factory, KeyPrefixer } from "../../../../utilities/_module-exports.js";
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* IMPORT_PATH: ```"@daiso-tech/core/event-bus"```
|
|
@@ -33,14 +33,14 @@ export declare class EventBusFactory<TAdapters extends string = string> implemen
|
|
|
33
33
|
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
34
34
|
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
35
35
|
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
36
|
-
* import { KeyPrefixer, type
|
|
36
|
+
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
37
37
|
* import { Serde } from "@daiso-tech/core/serde";
|
|
38
38
|
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
39
39
|
* import Redis from "ioredis";
|
|
40
40
|
*
|
|
41
|
-
* type Store = Partial<Record<string, IEventBusAdapter
|
|
41
|
+
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
42
42
|
*
|
|
43
|
-
*
|
|
43
|
+
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
44
44
|
* return (prefix) => {
|
|
45
45
|
* let adapter = store[prefix];
|
|
46
46
|
* if (adapter === undefined) {
|
|
@@ -70,25 +70,21 @@ export declare class EventBusFactory<TAdapters extends string = string> implemen
|
|
|
70
70
|
*/
|
|
71
71
|
constructor(settings: EventBusFactorySettings<TAdapters>);
|
|
72
72
|
setKeyPrefixer(keyPrefixer: KeyPrefixer): EventBusFactory<TAdapters>;
|
|
73
|
-
|
|
74
|
-
setBackoffPolicy(policy: BackoffPolicy): EventBusFactory<TAdapters>;
|
|
75
|
-
setRetryPolicy(policy: RetryPolicy): EventBusFactory<TAdapters>;
|
|
76
|
-
setRetryTimeout(timeout: TimeSpan): EventBusFactory<TAdapters>;
|
|
77
|
-
setTotalTimeout(timeout: TimeSpan): EventBusFactory<TAdapters>;
|
|
73
|
+
setLazyPromiseFactory(factory: Factory<AsyncLazy<any>, LazyPromise<any>>): EventBusFactory<TAdapters>;
|
|
78
74
|
/**
|
|
79
75
|
* @example
|
|
80
76
|
* ```ts
|
|
81
77
|
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
82
78
|
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
83
79
|
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
84
|
-
* import { KeyPrefixer, type
|
|
80
|
+
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
85
81
|
* import { Serde } from "@daiso-tech/core/serde";
|
|
86
82
|
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
87
83
|
* import Redis from "ioredis";
|
|
88
84
|
*
|
|
89
|
-
* type Store = Partial<Record<string, IEventBusAdapter
|
|
85
|
+
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
90
86
|
*
|
|
91
|
-
*
|
|
87
|
+
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
92
88
|
* return (prefix) => {
|
|
93
89
|
* let adapter = store[prefix];
|
|
94
90
|
* if (adapter === undefined) {
|
|
@@ -128,28 +124,6 @@ export declare class EventBusFactory<TAdapters extends string = string> implemen
|
|
|
128
124
|
* await eventBusFactory
|
|
129
125
|
* .use("redis")
|
|
130
126
|
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
131
|
-
*
|
|
132
|
-
* // You can change the default settings of the returned EventBus instance.
|
|
133
|
-
* await eventBusFactory
|
|
134
|
-
* .setRetryAttempts(4)
|
|
135
|
-
* .use("memoryFactory")
|
|
136
|
-
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
137
|
-
*
|
|
138
|
-
* // You can reuse the settings
|
|
139
|
-
* const retryableEventBusFactory = eventBusFactory
|
|
140
|
-
* .setRetryAttempts(4);
|
|
141
|
-
*
|
|
142
|
-
* await retryableEventBusFactory
|
|
143
|
-
* .use()
|
|
144
|
-
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
145
|
-
*
|
|
146
|
-
* // You can extend the settings
|
|
147
|
-
* const extendedEventBusFactory = retryableEventBusFactory
|
|
148
|
-
* .setRetryTimeout(TimeSpan.fromSeconds(1));
|
|
149
|
-
*
|
|
150
|
-
* await extendedEventBusFactory
|
|
151
|
-
* .use()
|
|
152
|
-
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
153
127
|
* ```
|
|
154
128
|
*/
|
|
155
129
|
use<TEvents extends BaseEvent = BaseEvent>(adapterName?: TAdapters | undefined): IGroupableEventBus<TEvents>;
|
|
@@ -17,14 +17,14 @@ export class EventBusFactory {
|
|
|
17
17
|
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
18
18
|
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
19
19
|
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
20
|
-
* import { KeyPrefixer, type
|
|
20
|
+
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
21
21
|
* import { Serde } from "@daiso-tech/core/serde";
|
|
22
22
|
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
23
23
|
* import Redis from "ioredis";
|
|
24
24
|
*
|
|
25
|
-
* type Store = Partial<Record<string, IEventBusAdapter
|
|
25
|
+
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
28
28
|
* return (prefix) => {
|
|
29
29
|
* let adapter = store[prefix];
|
|
30
30
|
* if (adapter === undefined) {
|
|
@@ -61,34 +61,10 @@ export class EventBusFactory {
|
|
|
61
61
|
keyPrefixer,
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
setLazyPromiseFactory(factory) {
|
|
65
65
|
return new EventBusFactory({
|
|
66
66
|
...this.settings,
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
setBackoffPolicy(policy) {
|
|
71
|
-
return new EventBusFactory({
|
|
72
|
-
...this.settings,
|
|
73
|
-
backoffPolicy: policy,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
setRetryPolicy(policy) {
|
|
77
|
-
return new EventBusFactory({
|
|
78
|
-
...this.settings,
|
|
79
|
-
retryPolicy: policy,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
setRetryTimeout(timeout) {
|
|
83
|
-
return new EventBusFactory({
|
|
84
|
-
...this.settings,
|
|
85
|
-
retryTimeout: timeout,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
setTotalTimeout(timeout) {
|
|
89
|
-
return new EventBusFactory({
|
|
90
|
-
...this.settings,
|
|
91
|
-
totalTimeout: timeout,
|
|
67
|
+
lazyPromiseFactory: factory,
|
|
92
68
|
});
|
|
93
69
|
}
|
|
94
70
|
/**
|
|
@@ -97,14 +73,14 @@ export class EventBusFactory {
|
|
|
97
73
|
* import { type IEventBusAdapter, BaseEvent } from "@daiso-tech/core/event-bus/contracts";
|
|
98
74
|
* import { EventBusFactory } from "@daiso-tech/core/event-bus";
|
|
99
75
|
* import { MemoryEventBusAdapter, RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
|
|
100
|
-
* import { KeyPrefixer, type
|
|
76
|
+
* import { KeyPrefixer, type FactoryFn } from "@daiso-tech/core/utilities";
|
|
101
77
|
* import { Serde } from "@daiso-tech/core/serde";
|
|
102
78
|
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
|
|
103
79
|
* import Redis from "ioredis";
|
|
104
80
|
*
|
|
105
|
-
* type Store = Partial<Record<string, IEventBusAdapter
|
|
81
|
+
* type Store = Partial<Record<string, IEventBusAdapter>>;
|
|
106
82
|
*
|
|
107
|
-
*
|
|
83
|
+
* function cahceAdapterFactory(store: Store): FactoryFn<string, IEventBusAdapter> {
|
|
108
84
|
* return (prefix) => {
|
|
109
85
|
* let adapter = store[prefix];
|
|
110
86
|
* if (adapter === undefined) {
|
|
@@ -144,28 +120,6 @@ export class EventBusFactory {
|
|
|
144
120
|
* await eventBusFactory
|
|
145
121
|
* .use("redis")
|
|
146
122
|
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
147
|
-
*
|
|
148
|
-
* // You can change the default settings of the returned EventBus instance.
|
|
149
|
-
* await eventBusFactory
|
|
150
|
-
* .setRetryAttempts(4)
|
|
151
|
-
* .use("memoryFactory")
|
|
152
|
-
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
153
|
-
*
|
|
154
|
-
* // You can reuse the settings
|
|
155
|
-
* const retryableEventBusFactory = eventBusFactory
|
|
156
|
-
* .setRetryAttempts(4);
|
|
157
|
-
*
|
|
158
|
-
* await retryableEventBusFactory
|
|
159
|
-
* .use()
|
|
160
|
-
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
161
|
-
*
|
|
162
|
-
* // You can extend the settings
|
|
163
|
-
* const extendedEventBusFactory = retryableEventBusFactory
|
|
164
|
-
* .setRetryTimeout(TimeSpan.fromSeconds(1));
|
|
165
|
-
*
|
|
166
|
-
* await extendedEventBusFactory
|
|
167
|
-
* .use()
|
|
168
|
-
* .dispatch(new AddEvent({ a: 1, b: 2 }));
|
|
169
123
|
* ```
|
|
170
124
|
*/
|
|
171
125
|
use(adapterName = this.settings.defaultAdapter) {
|
package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAIN,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,QAAQ,GAGX,MAAM,6DAA6D,CAAC;
|
|
1
|
+
{"version":3,"file":"event-bus-factory.js","sourceRoot":"","sources":["../../../../../src/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAIN,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACH,QAAQ,GAGX,MAAM,6DAA6D,CAAC;AAMrE,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gCAAgC,CAAC;AAuBxC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IA6CH;IA1CrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,YACqB,QAA4C;QAA5C,aAAQ,GAAR,QAAQ,CAAoC;IAC9D,CAAC;IAEJ,cAAc,CAAC,WAAwB;QACnC,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,WAAW;SACd,CAAC,CAAC;IACP,CAAC;IAED,qBAAqB,CACjB,OAAkD;QAElD,OAAO,IAAI,eAAe,CAAC;YACvB,GAAG,IAAI,CAAC,QAAQ;YAChB,kBAAkB,EAAE,OAAO;SAC9B,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsDG;IACH,GAAG,CACC,cAAqC,IAAI,CAAC,QAAQ,CAAC,cAAc;QAEjE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,6BAA6B,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,wBAAwB,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC;YAChB,OAAO;YACP,GAAG,IAAI,CAAC,QAAQ;SACnB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -29,26 +29,26 @@ export type AquireBlockingSettings = {
|
|
|
29
29
|
*/
|
|
30
30
|
export type ILock = ILockListenable & {
|
|
31
31
|
/**
|
|
32
|
-
* The <i>run</i> method wraps an
|
|
32
|
+
* The <i>run</i> method wraps an <i>{@link Invokable}</i> or <i>{@link LazyPromise}</i> with the <i>acquire</i> and <i>release</i> method.
|
|
33
33
|
* @throws {UnableToAquireLockError} {@link UnableToAquireLockError}
|
|
34
34
|
* @throws {UnableToReleaseLockError} {@link UnableToReleaseLockError}
|
|
35
35
|
*/
|
|
36
36
|
run<TValue = void>(asyncFn: AsyncLazy<TValue>): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
37
37
|
/**
|
|
38
|
-
* The <i>runOrFail</i> method wraps an
|
|
38
|
+
* The <i>runOrFail</i> method wraps an <i>{@link Invokable}</i> or <i>{@link LazyPromise}</i> with the <i>acquireOrFail</i> and <i>release</i> method.
|
|
39
39
|
* @throws {UnableToAquireLockError} {@link UnableToAquireLockError}
|
|
40
40
|
* @throws {UnableToReleaseLockError} {@link UnableToReleaseLockError}
|
|
41
41
|
* @throws {KeyAlreadyAcquiredLockError} {@link KeyAlreadyAcquiredLockError}
|
|
42
42
|
*/
|
|
43
43
|
runOrFail<TValue = void>(asyncFn: AsyncLazy<TValue>): LazyPromise<TValue>;
|
|
44
44
|
/**
|
|
45
|
-
* The <i>runBlocking</i> method wraps an
|
|
45
|
+
* The <i>runBlocking</i> method wraps an <i>{@link Invokable}</i> or <i>{@link LazyPromise}</i> with the <i>acquireBlocking</i> and <i>release</i> method.
|
|
46
46
|
* @throws {UnableToAquireLockError} {@link UnableToAquireLockError}
|
|
47
47
|
* @throws {UnableToReleaseLockError} {@link UnableToReleaseLockError}
|
|
48
48
|
*/
|
|
49
49
|
runBlocking<TValue = void>(asyncFn: AsyncLazy<TValue>, settings?: AquireBlockingSettings): LazyPromise<Result<TValue, KeyAlreadyAcquiredLockError>>;
|
|
50
50
|
/**
|
|
51
|
-
* The <i>runBlockingOrFail</i> method wraps an
|
|
51
|
+
* The <i>runBlockingOrFail</i> method wraps an <i>{@link Invokable}</i> or <i>{@link LazyPromise}</i> with the <i>acquireBlockingOrFail</i> and <i>release</i> method.
|
|
52
52
|
* @throws {UnableToAquireLockError} {@link UnableToAquireLockError}
|
|
53
53
|
* @throws {UnableToReleaseLockError} {@link UnableToReleaseLockError}
|
|
54
54
|
* @throws {KeyAlreadyAcquiredLockError} {@link KeyAlreadyAcquiredLockError}
|
|
@@ -25,11 +25,10 @@ export declare class RedisLockAdapter implements ILockAdapter {
|
|
|
25
25
|
/**
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|
|
28
|
-
* import { RedisLockAdapter
|
|
28
|
+
* import { RedisLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
29
29
|
* import Redis from "ioredis";
|
|
30
30
|
*
|
|
31
31
|
* const database = new Redis("YOUR_REDIS_CONNECTION_STRING");
|
|
32
|
-
* const serde = new SuperJsonSerde();
|
|
33
32
|
* const lockAdapter = new RedisLockAdapter(database);
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
@@ -14,11 +14,10 @@ export class RedisLockAdapter {
|
|
|
14
14
|
/**
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
17
|
-
* import { RedisLockAdapter
|
|
17
|
+
* import { RedisLockAdapter } from "@daiso-tech/core/lock/adapters";
|
|
18
18
|
* import Redis from "ioredis";
|
|
19
19
|
*
|
|
20
20
|
* const database = new Redis("YOUR_REDIS_CONNECTION_STRING");
|
|
21
|
-
* const serde = new SuperJsonSerde();
|
|
22
21
|
* const lockAdapter = new RedisLockAdapter(database);
|
|
23
22
|
* ```
|
|
24
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis-lock-adapter.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuBH;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;
|
|
1
|
+
{"version":3,"file":"redis-lock-adapter.js","sourceRoot":"","sources":["../../../../../src/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuBH;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAWI;IAV7B;;;;;;;;;OASG;IACH,YAA6B,QAAe;QAAf,aAAQ,GAAR,QAAQ,CAAO;QACxC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC7B,CAAC;IAEO,iBAAiB;QACrB,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,KAAK,UAAU,EAAE,CAAC;YACzD,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,oBAAoB,EAAE;YAC9C,YAAY,EAAE,CAAC;YACf,GAAG,EAAE;;;;;;;;;;;;;;;;;iBAiBA;SACR,CAAC,CAAC;IACP,CAAC;IAEO,kBAAkB;QACtB,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,KAAK,UAAU,EAAE,CAAC;YACzD,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,oBAAoB,EAAE;YAC9C,YAAY,EAAE,CAAC;YACf,GAAG,EAAE;;;;;;;;;;;iBAWA;SACR,CAAC,CAAC;IACP,CAAC;IAEO,iBAAiB;QACrB,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,KAAK,UAAU,EAAE,CAAC;YACzD,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,oBAAoB,EAA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