@spinajs/queue 2.0.179 → 2.0.181

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.
Files changed (41) hide show
  1. package/lib/cjs/BlackHoleQueueClient.d.ts +11 -11
  2. package/lib/cjs/BlackHoleQueueClient.js +29 -29
  3. package/lib/cjs/BlackHoleQueueClient.js.map +1 -1
  4. package/lib/cjs/config/queue.d.ts +10 -10
  5. package/lib/cjs/config/queue.js +17 -17
  6. package/lib/cjs/decorators.d.ts +19 -19
  7. package/lib/cjs/decorators.js +35 -35
  8. package/lib/cjs/index.d.ts +38 -38
  9. package/lib/cjs/index.js +167 -167
  10. package/lib/cjs/index.js.map +1 -1
  11. package/lib/cjs/interfaces.d.ts +213 -213
  12. package/lib/cjs/interfaces.js +168 -168
  13. package/lib/cjs/interfaces.js.map +1 -1
  14. package/lib/cjs/migrations/Queue_2022_10_18_01_13_00.d.ts +5 -5
  15. package/lib/cjs/migrations/Queue_2022_10_18_01_13_00.js +35 -35
  16. package/lib/cjs/migrations/Queue_2022_10_18_01_13_00.js.map +1 -1
  17. package/lib/cjs/models/JobModel.d.ts +19 -19
  18. package/lib/cjs/models/JobModel.js +46 -46
  19. package/lib/cjs/models/JobModel.js.map +1 -1
  20. package/lib/mjs/BlackHoleQueueClient.d.ts +11 -11
  21. package/lib/mjs/BlackHoleQueueClient.js +26 -26
  22. package/lib/mjs/BlackHoleQueueClient.js.map +1 -1
  23. package/lib/mjs/config/queue.d.ts +10 -10
  24. package/lib/mjs/config/queue.js +15 -15
  25. package/lib/mjs/decorators.d.ts +19 -19
  26. package/lib/mjs/decorators.js +30 -30
  27. package/lib/mjs/index.d.ts +38 -38
  28. package/lib/mjs/index.js +150 -150
  29. package/lib/mjs/index.js.map +1 -1
  30. package/lib/mjs/interfaces.d.ts +213 -213
  31. package/lib/mjs/interfaces.js +156 -156
  32. package/lib/mjs/interfaces.js.map +1 -1
  33. package/lib/mjs/migrations/Queue_2022_10_18_01_13_00.d.ts +5 -5
  34. package/lib/mjs/migrations/Queue_2022_10_18_01_13_00.js +32 -32
  35. package/lib/mjs/migrations/Queue_2022_10_18_01_13_00.js.map +1 -1
  36. package/lib/mjs/models/JobModel.d.ts +19 -19
  37. package/lib/mjs/models/JobModel.js +43 -43
  38. package/lib/mjs/models/JobModel.js.map +1 -1
  39. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  40. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  41. package/package.json +6 -6
@@ -1,214 +1,214 @@
1
- import { AsyncService, Constructor, IInstanceCheck, IMappableService } from '@spinajs/di';
2
- import { DateTime } from 'luxon';
3
- import { Log } from '@spinajs/log';
4
- export declare enum QueueMessageType {
5
- Job = "JOB",
6
- Event = "EVENT"
7
- }
8
- export interface IQueueMessage {
9
- CreatedAt: DateTime;
10
- Name: string;
11
- Type: QueueMessageType;
12
- Persistent: boolean;
13
- Priority: number;
14
- /**
15
- * The time in milliseconds that a message will wait before being scheduled to be delivered by the broker
16
- */
17
- ScheduleDelay?: number;
18
- /**
19
- * The time in milliseconds to wait after the start time to wait before scheduling the message again
20
- */
21
- SchedulePeriod?: number;
22
- /**
23
- * The number of times to repeat scheduling a message for delivery
24
- */
25
- ScheduleRepeat?: number;
26
- /**
27
- * Use a Cron entry to set the schedule
28
- */
29
- ScheduleCron?: string;
30
- }
31
- export interface IQueueJob extends IQueueMessage {
32
- RetryCount: number;
33
- JobId?: string;
34
- }
35
- export declare abstract class QueueService extends AsyncService {
36
- protected Configuration: IQueueConfiguration;
37
- abstract emit(event: IQueueMessage | QueueEvent | QueueJob): Promise<void>;
38
- abstract consume<T extends QueueMessage>(event: Constructor<QueueMessage>, callback?: (message: T) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
39
- abstract stopConsuming(event: Constructor<QueueMessage>): Promise<void>;
40
- abstract get(connection?: string): QueueClient;
41
- protected getConnectionsForMessage(event: IQueueMessage | Constructor<QueueMessage>): string[];
42
- }
43
- export declare function isJob(event: IQueueMessage): event is QueueJob;
44
- /**
45
- * Events are messages send via queue, we do not want to track it, dont care about result, no retry policy on failed execution etc.
46
- */
47
- export declare abstract class QueueMessage implements IQueueMessage {
48
- [key: string]: any;
49
- CreatedAt: DateTime;
50
- Name: string;
51
- Type: QueueMessageType;
52
- Persistent: boolean;
53
- Priority: number;
54
- /**
55
- * The time in milliseconds that a message will wait before being scheduled to be delivered by the broker
56
- */
57
- ScheduleDelay: number;
58
- /**
59
- * The time in milliseconds to wait after the start time to wait before scheduling the message again
60
- */
61
- SchedulePeriod: number;
62
- /**
63
- * The number of times to repeat scheduling a message for delivery
64
- */
65
- ScheduleRepeat: number;
66
- /**
67
- * Use a Cron entry to set the schedule
68
- */
69
- ScheduleCron: string;
70
- constructor();
71
- hydrate(payload: any): void;
72
- }
73
- /**
74
- * events provides a simple observer implementation, allowing you to subscribe and listen
75
- * for various events that occur in your application. Events serve as a great way to decouple
76
- * various aspects of your application, since a single event can have multiple listeners that do not depend on each other.
77
- *
78
- * we can register multiple listeners for a single event and the event helper will dispatch the event to all of its registered
79
- * listeners without us calling them explicitly. where in case of Jobs we would have to call them each one explicitly.
80
- */
81
- export declare abstract class QueueEvent extends QueueMessage {
82
- constructor();
83
- static emit<T extends typeof QueueMessage>(this: T, val: Partial<InstanceType<T>>, options?: IMessageOptions): Promise<void>;
84
- }
85
- /**
86
- * Jobs are executed only once even if multiple listeners waiting for it. usually used for single method call
87
- * or time consuming tasks, that need to checked for result and tracked
88
- *
89
- * Job results are preserved
90
- */
91
- export declare abstract class QueueJob extends QueueMessage implements IQueueJob {
92
- JobId: string;
93
- /**
94
- * Retry count on job failure
95
- */
96
- RetryCount: number;
97
- constructor();
98
- abstract execute(progress: (p: number) => Promise<void>): Promise<unknown>;
99
- static emit<T extends typeof QueueMessage>(this: T, val: Partial<InstanceType<T>>, options?: IMessageOptions): Promise<void>;
100
- }
101
- export declare abstract class QueueClient extends AsyncService implements IInstanceCheck, IMappableService {
102
- Options: IQueueConnectionOptions;
103
- protected Log: Log;
104
- protected Routing: IQueueMessageRoutingOptions;
105
- get Name(): string;
106
- get ServiceName(): string;
107
- constructor(Options: IQueueConnectionOptions);
108
- __checkInstance__(creationOptions: any): boolean;
109
- /**
110
- *
111
- * Dispatches event to queue
112
- *
113
- * @param event - event to dispatch
114
- */
115
- abstract emit(event: IQueueMessage): Promise<void>;
116
- /**
117
- *
118
- * Subscribes to ALL channels that event is assignet to in routing table
119
- *
120
- */
121
- abstract subscribe(event: Constructor<QueueMessage>, callback: (e: IQueueMessage) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
122
- /**
123
- * Subscribes for specific channel in queue server
124
- *
125
- * @param channel - specified channel to subscribe
126
- * @param callback - callback executet when message arrives
127
- * @param subscriptionId - id to identify subscription when using durable events
128
- * @param durable - is durable event ?
129
- */
130
- abstract subscribe(channel: string, callback: (e: IQueueMessage) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
131
- abstract unsubscribe(event: Constructor<QueueMessage>): void;
132
- abstract unsubscribe(channel: string): void;
133
- /**
134
- *
135
- * Gets event channel from routing table or default if non is set
136
- *
137
- * @param event - event to check
138
- */
139
- getChannelForMessage(event: IQueueMessage | Constructor<QueueMessage>): string[];
140
- }
141
- export interface IQueueMessageRoutingOptions {
142
- [key: string]: string | IMessageRoutingOption | string[] | IMessageRoutingOption[];
143
- }
144
- export interface IQueueConfiguration {
145
- default: string;
146
- /**
147
- * Message routing eg. where event/job with given type ( name ) will be send to
148
- * eg. job Email will be sent to /task/mails channel in broker
149
- * If no routing for message is provided, it will be sent to default one.
150
- *
151
- * Also here deat letter channel for message can be configured
152
- *
153
- * Message can be router in multiple destinations
154
- */
155
- routing?: IQueueMessageRoutingOptions;
156
- connections: IQueueConnectionOptions[];
157
- }
158
- export interface IMessageRoutingOption {
159
- channel?: string;
160
- deadLetterChannel?: string;
161
- connection?: string;
162
- }
163
- export interface IQueueConnectionOptions {
164
- transport: string;
165
- name: string;
166
- login?: string;
167
- password?: string;
168
- host?: string;
169
- port?: number;
170
- queue?: string;
171
- options?: any;
172
- type: 'event' | 'job';
173
- debug?: boolean;
174
- /**
175
- * Default topic ( events ) channel in broker
176
- * If no routing for specified event is provided
177
- * it will be send to this channel
178
- */
179
- defaultTopicChannel?: string;
180
- /**
181
- * Default queue ( job ) channel in broker
182
- * If no routing for specified job is provided
183
- * it will be send to this channel
184
- */
185
- defaultQueueChannel?: string;
186
- /**
187
- * If job fails at client side and we dont send ack
188
- * broker will try to send job again ( and probably will fail again )
189
- * In such event, it will reschedule job to deat letter queue for further processing
190
- * and for unblocking source queue
191
- */
192
- defaultQueueDeadLetterChannel?: string;
193
- }
194
- export interface IMessageOptions {
195
- Persistent: boolean;
196
- Priority: number;
197
- /**
198
- * The time in milliseconds that a message will wait before being scheduled to be delivered by the broker
199
- */
200
- ScheduleDelay: number;
201
- /**
202
- * The time in milliseconds to wait after the start time to wait before scheduling the message again
203
- */
204
- SchedulePeriod: number;
205
- /**
206
- * The number of times to repeat scheduling a message for delivery
207
- */
208
- ScheduleRepeat: number;
209
- /**
210
- * Use a Cron entry to set the schedule
211
- */
212
- ScheduleCron: string;
213
- }
1
+ import { AsyncService, Constructor, IInstanceCheck, IMappableService } from '@spinajs/di';
2
+ import { DateTime } from 'luxon';
3
+ import { Log } from '@spinajs/log';
4
+ export declare enum QueueMessageType {
5
+ Job = "JOB",
6
+ Event = "EVENT"
7
+ }
8
+ export interface IQueueMessage {
9
+ CreatedAt: DateTime;
10
+ Name: string;
11
+ Type: QueueMessageType;
12
+ Persistent: boolean;
13
+ Priority: number;
14
+ /**
15
+ * The time in milliseconds that a message will wait before being scheduled to be delivered by the broker
16
+ */
17
+ ScheduleDelay?: number;
18
+ /**
19
+ * The time in milliseconds to wait after the start time to wait before scheduling the message again
20
+ */
21
+ SchedulePeriod?: number;
22
+ /**
23
+ * The number of times to repeat scheduling a message for delivery
24
+ */
25
+ ScheduleRepeat?: number;
26
+ /**
27
+ * Use a Cron entry to set the schedule
28
+ */
29
+ ScheduleCron?: string;
30
+ }
31
+ export interface IQueueJob extends IQueueMessage {
32
+ RetryCount: number;
33
+ JobId?: string;
34
+ }
35
+ export declare abstract class QueueService extends AsyncService {
36
+ protected Configuration: IQueueConfiguration;
37
+ abstract emit(event: IQueueMessage | QueueEvent | QueueJob): Promise<void>;
38
+ abstract consume<T extends QueueMessage>(event: Constructor<QueueMessage>, callback?: (message: T) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
39
+ abstract stopConsuming(event: Constructor<QueueMessage>): Promise<void>;
40
+ abstract get(connection?: string): QueueClient;
41
+ protected getConnectionsForMessage(event: IQueueMessage | Constructor<QueueMessage>): string[];
42
+ }
43
+ export declare function isJob(event: IQueueMessage): event is QueueJob;
44
+ /**
45
+ * Events are messages send via queue, we do not want to track it, dont care about result, no retry policy on failed execution etc.
46
+ */
47
+ export declare abstract class QueueMessage implements IQueueMessage {
48
+ [key: string]: any;
49
+ CreatedAt: DateTime;
50
+ Name: string;
51
+ Type: QueueMessageType;
52
+ Persistent: boolean;
53
+ Priority: number;
54
+ /**
55
+ * The time in milliseconds that a message will wait before being scheduled to be delivered by the broker
56
+ */
57
+ ScheduleDelay: number;
58
+ /**
59
+ * The time in milliseconds to wait after the start time to wait before scheduling the message again
60
+ */
61
+ SchedulePeriod: number;
62
+ /**
63
+ * The number of times to repeat scheduling a message for delivery
64
+ */
65
+ ScheduleRepeat: number;
66
+ /**
67
+ * Use a Cron entry to set the schedule
68
+ */
69
+ ScheduleCron: string;
70
+ constructor();
71
+ hydrate(payload: any): void;
72
+ }
73
+ /**
74
+ * events provides a simple observer implementation, allowing you to subscribe and listen
75
+ * for various events that occur in your application. Events serve as a great way to decouple
76
+ * various aspects of your application, since a single event can have multiple listeners that do not depend on each other.
77
+ *
78
+ * we can register multiple listeners for a single event and the event helper will dispatch the event to all of its registered
79
+ * listeners without us calling them explicitly. where in case of Jobs we would have to call them each one explicitly.
80
+ */
81
+ export declare abstract class QueueEvent extends QueueMessage {
82
+ constructor();
83
+ static emit<T extends typeof QueueMessage>(this: T, val: Partial<InstanceType<T>>, options?: IMessageOptions): Promise<void>;
84
+ }
85
+ /**
86
+ * Jobs are executed only once even if multiple listeners waiting for it. usually used for single method call
87
+ * or time consuming tasks, that need to checked for result and tracked
88
+ *
89
+ * Job results are preserved
90
+ */
91
+ export declare abstract class QueueJob extends QueueMessage implements IQueueJob {
92
+ JobId: string;
93
+ /**
94
+ * Retry count on job failure
95
+ */
96
+ RetryCount: number;
97
+ constructor();
98
+ abstract execute(progress: (p: number) => Promise<void>): Promise<unknown>;
99
+ static emit<T extends typeof QueueMessage>(this: T, val: Partial<InstanceType<T>>, options?: IMessageOptions): Promise<void>;
100
+ }
101
+ export declare abstract class QueueClient extends AsyncService implements IInstanceCheck, IMappableService {
102
+ Options: IQueueConnectionOptions;
103
+ protected Log: Log;
104
+ protected Routing: IQueueMessageRoutingOptions;
105
+ get Name(): string;
106
+ get ServiceName(): string;
107
+ constructor(Options: IQueueConnectionOptions);
108
+ __checkInstance__(creationOptions: any): boolean;
109
+ /**
110
+ *
111
+ * Dispatches event to queue
112
+ *
113
+ * @param event - event to dispatch
114
+ */
115
+ abstract emit(event: IQueueMessage): Promise<void>;
116
+ /**
117
+ *
118
+ * Subscribes to ALL channels that event is assignet to in routing table
119
+ *
120
+ */
121
+ abstract subscribe(event: Constructor<QueueMessage>, callback: (e: IQueueMessage) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
122
+ /**
123
+ * Subscribes for specific channel in queue server
124
+ *
125
+ * @param channel - specified channel to subscribe
126
+ * @param callback - callback executet when message arrives
127
+ * @param subscriptionId - id to identify subscription when using durable events
128
+ * @param durable - is durable event ?
129
+ */
130
+ abstract subscribe(channel: string, callback: (e: IQueueMessage) => Promise<void>, subscriptionId?: string, durable?: boolean): Promise<void>;
131
+ abstract unsubscribe(event: Constructor<QueueMessage>): void;
132
+ abstract unsubscribe(channel: string): void;
133
+ /**
134
+ *
135
+ * Gets event channel from routing table or default if non is set
136
+ *
137
+ * @param event - event to check
138
+ */
139
+ getChannelForMessage(event: IQueueMessage | Constructor<QueueMessage>): string[];
140
+ }
141
+ export interface IQueueMessageRoutingOptions {
142
+ [key: string]: string | IMessageRoutingOption | string[] | IMessageRoutingOption[];
143
+ }
144
+ export interface IQueueConfiguration {
145
+ default: string;
146
+ /**
147
+ * Message routing eg. where event/job with given type ( name ) will be send to
148
+ * eg. job Email will be sent to /task/mails channel in broker
149
+ * If no routing for message is provided, it will be sent to default one.
150
+ *
151
+ * Also here deat letter channel for message can be configured
152
+ *
153
+ * Message can be router in multiple destinations
154
+ */
155
+ routing?: IQueueMessageRoutingOptions;
156
+ connections: IQueueConnectionOptions[];
157
+ }
158
+ export interface IMessageRoutingOption {
159
+ channel?: string;
160
+ deadLetterChannel?: string;
161
+ connection?: string;
162
+ }
163
+ export interface IQueueConnectionOptions {
164
+ transport: string;
165
+ name: string;
166
+ login?: string;
167
+ password?: string;
168
+ host?: string;
169
+ port?: number;
170
+ queue?: string;
171
+ options?: any;
172
+ type: 'event' | 'job';
173
+ debug?: boolean;
174
+ /**
175
+ * Default topic ( events ) channel in broker
176
+ * If no routing for specified event is provided
177
+ * it will be send to this channel
178
+ */
179
+ defaultTopicChannel?: string;
180
+ /**
181
+ * Default queue ( job ) channel in broker
182
+ * If no routing for specified job is provided
183
+ * it will be send to this channel
184
+ */
185
+ defaultQueueChannel?: string;
186
+ /**
187
+ * If job fails at client side and we dont send ack
188
+ * broker will try to send job again ( and probably will fail again )
189
+ * In such event, it will reschedule job to deat letter queue for further processing
190
+ * and for unblocking source queue
191
+ */
192
+ defaultQueueDeadLetterChannel?: string;
193
+ }
194
+ export interface IMessageOptions {
195
+ Persistent: boolean;
196
+ Priority: number;
197
+ /**
198
+ * The time in milliseconds that a message will wait before being scheduled to be delivered by the broker
199
+ */
200
+ ScheduleDelay: number;
201
+ /**
202
+ * The time in milliseconds to wait after the start time to wait before scheduling the message again
203
+ */
204
+ SchedulePeriod: number;
205
+ /**
206
+ * The number of times to repeat scheduling a message for delivery
207
+ */
208
+ ScheduleRepeat: number;
209
+ /**
210
+ * Use a Cron entry to set the schedule
211
+ */
212
+ ScheduleCron: string;
213
+ }
214
214
  //# sourceMappingURL=interfaces.d.ts.map