@ti-engine/core 1.8.1 → 1.9.1

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 (53) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/components/auditing.js +2 -4
  3. package/components/definitions.types.js +19 -4
  4. package/components/exchange/default/default-message-exchange.js +2 -0
  5. package/components/exchange/default/default-message-receiver.js +2 -0
  6. package/components/exchange/default/default-message-sender.js +2 -0
  7. package/components/exchange/message-dispatcher.js +4 -0
  8. package/components/exchange/message-exchange.js +4 -0
  9. package/components/exchange/message-handler.js +7 -5
  10. package/components/exchange/message-memory-cache.js +3 -0
  11. package/components/exchange/message-observer.js +2 -0
  12. package/components/exchange/message-receiver.js +2 -1
  13. package/components/exchange/message-sender.js +2 -2
  14. package/components/exchange/message-tracer.js +2 -3
  15. package/components/service-caller.js +2 -5
  16. package/components/service-consumer.js +2 -0
  17. package/components/service-executor.js +3 -5
  18. package/components/service-instance.js +2 -4
  19. package/components/service-provider.js +3 -0
  20. package/integrations/redis-integration.js +1 -5
  21. package/package.json +152 -36
  22. package/types/bin/start-instance.d.ts +1 -0
  23. package/types/components/auditing.d.ts +30 -0
  24. package/types/components/connection-observer.d.ts +49 -0
  25. package/types/components/definitions.types.d.ts +444 -0
  26. package/types/components/exchange/default/default-message-exchange.d.ts +61 -0
  27. package/types/components/exchange/default/default-message-receiver.d.ts +49 -0
  28. package/types/components/exchange/default/default-message-sender.d.ts +50 -0
  29. package/types/components/exchange/message-dispatcher.d.ts +77 -0
  30. package/types/components/exchange/message-exchange.d.ts +306 -0
  31. package/types/components/exchange/message-handler.d.ts +132 -0
  32. package/types/components/exchange/message-memory-cache.d.ts +84 -0
  33. package/types/components/exchange/message-observer.d.ts +87 -0
  34. package/types/components/exchange/message-receiver.d.ts +91 -0
  35. package/types/components/exchange/message-sender.d.ts +68 -0
  36. package/types/components/exchange/message-tracer.d.ts +84 -0
  37. package/types/components/service-caller.d.ts +68 -0
  38. package/types/components/service-consumer.d.ts +81 -0
  39. package/types/components/service-executor.d.ts +101 -0
  40. package/types/components/service-instance.d.ts +111 -0
  41. package/types/components/service-provider.d.ts +120 -0
  42. package/types/integrations/redis-integration.d.ts +223 -0
  43. package/types/utils/cache.d.ts +320 -0
  44. package/types/utils/config.d.ts +40 -0
  45. package/types/utils/exceptions.d.ts +224 -0
  46. package/types/utils/localization.d.ts +194 -0
  47. package/types/utils/logger.d.ts +24 -0
  48. package/types/utils/tools.d.ts +70 -0
  49. package/utils/cache.js +0 -1
  50. package/utils/exceptions.js +2 -0
  51. package/utils/localization.js +2 -0
  52. package/utils/logger.js +2 -0
  53. package/utils/tools.js +10 -8
@@ -0,0 +1,444 @@
1
+ /// <reference types="node" />
2
+ import type { TiException } from "#exceptions";
3
+ import type { TiLocalizationLanguage } from "#localization";
4
+ import type { TiLogSeverity } from "#logger";
5
+ import type { ServiceHandlerMethod } from "#service-executor";
6
+ export type EnvironmentVariable = string;
7
+ export type Environment = NodeJS.Process;
8
+ export type SettingsMain = {
9
+ auditing: SettingsAuditing;
10
+ gcloudIntegration: SettingsGcloudIntegration;
11
+ localization: SettingsLocalization;
12
+ memoryCache: SettingsMemoryCache;
13
+ messageExchange: SettingsMessageExchange;
14
+ serviceConfig: SettingsServiceConfig;
15
+ operationMode: string;
16
+ };
17
+ export type SettingsAuditing = {
18
+ logConsoleEnabled: boolean;
19
+ logDetails: boolean;
20
+ logMinLevel: TiLogSeverity;
21
+ logUsesJSON: boolean;
22
+ };
23
+ export type SettingsGcloudIntegration = {
24
+ apiKey: string;
25
+ projectID: string;
26
+ };
27
+ export type SettingsLocalization = {
28
+ labelsPath: Array<string>;
29
+ language: TiLocalizationLanguage;
30
+ };
31
+ export type SettingsMemoryCache = {
32
+ authKey: string;
33
+ redisDB: number;
34
+ redisHost: string;
35
+ redisPort: number;
36
+ retryMaxAttempts: number;
37
+ retryMaxInterval: number;
38
+ user: string;
39
+ };
40
+ export type SettingsMessageExchange = {
41
+ messageQueuePrefix: string;
42
+ messageStore: string;
43
+ securityHashEnabled: boolean;
44
+ securityHashKey: string;
45
+ traceExpirationTime: number;
46
+ traceLogEnabled: boolean;
47
+ traceRepository: string;
48
+ };
49
+ export type SettingsServiceConfig = {
50
+ executionTimeout: number;
51
+ healthCheckAddress: string;
52
+ healthCheckInterval: CronString;
53
+ healthCheckTimeout: number;
54
+ serviceRegistryAddress: string;
55
+ };
56
+ export type CronString = string;
57
+ export type TiEnumValue = {
58
+ value: number | string;
59
+ name: string;
60
+ description?: string;
61
+ };
62
+ export type TiEnum = {
63
+ properties: Record<string, TiEnumValue>;
64
+ name: (enumValue: number | string, placeholder?: string) => string | undefined;
65
+ description: (enumValue: number | string, placeholder?: string) => string | undefined;
66
+ contains: (enumValue: number | string) => boolean;
67
+ };
68
+ export type TiEnumOf<T extends Record<string, any>> = {
69
+ [K in keyof T]: number | string;
70
+ } & TiEnum;
71
+ export type TiLogEntry = {
72
+ /**
73
+ * Unique identifier that can be used to identify the document in a NoSQL database.
74
+ */
75
+ _id: string;
76
+ /**
77
+ * The log severity level.
78
+ */
79
+ severity: TiLogSeverity;
80
+ /**
81
+ * The categorization of the log message.
82
+ */
83
+ thread: string;
84
+ reporter: string;
85
+ /**
86
+ * The actual log message.
87
+ */
88
+ message: string;
89
+ /**
90
+ * The timestamp of the log entry in UTC time.
91
+ */
92
+ timestamp: number;
93
+ /**
94
+ * Additional JSON data to go with the message.
95
+ */
96
+ data: Object;
97
+ };
98
+ export type TiTraceEntry = {
99
+ chainID: string;
100
+ dispatchEvent: string;
101
+ fromAddress: string;
102
+ messageID: string;
103
+ messageSnapshot: Object;
104
+ messageState: string;
105
+ messageType: string;
106
+ toAddress: string;
107
+ traceID: string;
108
+ traceTimestamp: number;
109
+ };
110
+ export type TiLocalizedLabel = Record<TiLocalizationLanguage, string>;
111
+ export type TiLabelsTree = {
112
+ [label: string]: TiLocalizedLabel | TiLabelsTree;
113
+ };
114
+ export type ServiceAddress = {
115
+ /**
116
+ * A valid service alias.
117
+ */
118
+ serviceAlias: string;
119
+ /**
120
+ * A valid service domain name.
121
+ */
122
+ serviceDomainName: string;
123
+ /**
124
+ * Optional service version. If not provided, the latest version will be assumed as a target.
125
+ */
126
+ serviceVersion: number | undefined;
127
+ };
128
+ export type ServiceExecContext = {
129
+ /**
130
+ * A valid authentication token that initialized the service call (if applicable).
131
+ */
132
+ authToken: string | undefined;
133
+ /**
134
+ * The previous service call in the execution chain (if such exists).
135
+ */
136
+ previousServiceCall: ServiceCallPredecessor | undefined;
137
+ };
138
+ export type ServiceCallPredecessor = Message;
139
+ export type ServiceCall = ServiceCallPredecessor;
140
+ export type ServiceCallResult = {
141
+ /**
142
+ * If there was exception during the service call processing, it will be set here. Otherwise, it will be 'undefined'.
143
+ */
144
+ exception: TiException | undefined;
145
+ /**
146
+ * A flag indicating if this service call can be considered successful or not.
147
+ */
148
+ isSuccessful: boolean;
149
+ /**
150
+ * The payload containing the results from the service call processing. If a string, it is ID of the payload in the memory cache instead.
151
+ */
152
+ payload: Object | string | undefined;
153
+ };
154
+ export type ServiceDefinition = {
155
+ /**
156
+ * Service alias.
157
+ */
158
+ serviceAlias: string;
159
+ /**
160
+ * The JS file containing the service itself. This has to be exposed via package.json import structure!
161
+ */
162
+ serviceFile: string;
163
+ /**
164
+ * Service version.
165
+ */
166
+ serviceVersion?: number;
167
+ };
168
+ export type ServiceInterface = Record<string, ServiceInterfaceVersion>;
169
+ export type ServiceInterfaceVersion = Record<number, ServiceHandlerMethod>;
170
+ export type ServiceConfiguration = {
171
+ /**
172
+ * A list of service definitions to be registered with the {@link ServiceProvider}.
173
+ */
174
+ services?: ServiceDefinition[];
175
+ };
176
+ export type MessageDestination = {
177
+ /**
178
+ * The instance ID of the message exchange by which the message was received (available after acceptance).
179
+ */
180
+ instanceID?: string | undefined;
181
+ /**
182
+ * The route to destination for the message. The exact structure will depend on the implementation of the message exchange.
183
+ */
184
+ route: string;
185
+ };
186
+ export type MessageSource = {
187
+ /**
188
+ * The instance ID of the message exchange from which the service call originated.
189
+ */
190
+ instanceID: string;
191
+ /**
192
+ * The route from source of the message. The exact structure will depend on the implementation of the message exchange.
193
+ */
194
+ route: string;
195
+ };
196
+ export type Message = {
197
+ /**
198
+ * Unique identifier of the message chain if the message is part of one.
199
+ */
200
+ chainID: string;
201
+ /**
202
+ * The node level of this message in the message chain tree.
203
+ */
204
+ chainLevel: number;
205
+ /**
206
+ * The destination of the message.
207
+ */
208
+ destination: MessageDestination;
209
+ /**
210
+ * Security hash for the message if the mechanism is enabled.
211
+ */
212
+ hash?: string;
213
+ /**
214
+ * Unique message identifier.
215
+ */
216
+ messageID: string;
217
+ /**
218
+ * The message contents to be processed in destination. If a string, it is ID of the payload in the memory cache instead.
219
+ * Note that if this is not an Object or a string, there is no guarantee that it will be delivered in the same/proper format!
220
+ */
221
+ payload: Object | string | undefined;
222
+ /**
223
+ * The source of the message.
224
+ */
225
+ source: MessageSource;
226
+ };
227
+ /** @import { TiException } from "#exceptions" */
228
+ /** @import { TiLocalizationLanguage } from "#localization" */
229
+ /** @import { TiLogSeverity } from "#logger" */
230
+ /** @import { ServiceHandlerMethod } from "#service-executor" */
231
+ /**
232
+ * @typedef {string} EnvironmentVariable
233
+ */
234
+ /**
235
+ * @typedef {NodeJS.Process} Environment
236
+ * @property {ProcessEnv} env
237
+ * @property {EnvironmentVariable} env.TI_GCLOUD_API_KEY
238
+ * @property {EnvironmentVariable} env.TI_GCLOUD_ENABLED
239
+ * @property {EnvironmentVariable} env.TI_GCLOUD_PROJECT_ID
240
+ * @property {EnvironmentVariable} env.TI_INSTANCE_CLASS
241
+ * @property {EnvironmentVariable} env.TI_INSTANCE_CONFIG
242
+ * @property {EnvironmentVariable} env.TI_INSTANCE_ID
243
+ * @property {EnvironmentVariable} env.TI_INSTANCE_NAME
244
+ * @property {EnvironmentVariable} env.TI_AUDITING_LOG_CONSOLE_ENABLED
245
+ * @property {EnvironmentVariable} env.TI_AUDITING_LOG_DETAILS
246
+ * @property {EnvironmentVariable} env.TI_AUDITING_LOG_MIN_LEVEL
247
+ * @property {EnvironmentVariable} env.TI_AUDITING_LOG_USES_JSON
248
+ * @property {EnvironmentVariable} env.TI_LOCALIZATION_LABELS_PATH
249
+ * @property {EnvironmentVariable} env.TI_LOCALIZATION_LANGUAGE
250
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_AUTH_KEY
251
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_REDIS_DB
252
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_REDIS_HOST
253
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_REDIS_PORT
254
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_RETRY_MAX_ATTEMPTS
255
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_RETRY_MAX_INTERVAL
256
+ * @property {EnvironmentVariable} env.TI_MEMORY_CACHE_USER
257
+ * @property {EnvironmentVariable} env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_ENABLED
258
+ * @property {EnvironmentVariable} env.TI_MESSAGE_EXCHANGE_SECURITY_HASH_KEY
259
+ * @property {EnvironmentVariable} env.TI_MESSAGE_EXCHANGE_TRACE_LOG_ENABLED
260
+ */
261
+ /**
262
+ * @typedef {Object} SettingsMain
263
+ * @property {SettingsAuditing} auditing
264
+ * @property {SettingsGcloudIntegration} gcloudIntegration
265
+ * @property {SettingsLocalization} localization
266
+ * @property {SettingsMemoryCache} memoryCache
267
+ * @property {SettingsMessageExchange} messageExchange
268
+ * @property {SettingsServiceConfig} serviceConfig
269
+ * @property {string} operationMode
270
+ */
271
+ /**
272
+ * @typedef {Object} SettingsAuditing
273
+ * @property {boolean} logConsoleEnabled
274
+ * @property {boolean} logDetails
275
+ * @property {TiLogSeverity} logMinLevel
276
+ * @property {boolean} logUsesJSON
277
+ */
278
+ /**
279
+ * @typedef {Object} SettingsGcloudIntegration
280
+ * @property {string} apiKey
281
+ * @property {string} projectID
282
+ */
283
+ /**
284
+ * @typedef {Object} SettingsLocalization
285
+ * @property {Array<string>} labelsPath
286
+ * @property {TiLocalizationLanguage} language
287
+ */
288
+ /**
289
+ * @typedef {Object} SettingsMemoryCache
290
+ * @property {string} authKey
291
+ * @property {number} redisDB
292
+ * @property {string} redisHost
293
+ * @property {number} redisPort
294
+ * @property {number} retryMaxAttempts
295
+ * @property {number} retryMaxInterval
296
+ * @property {string} user
297
+ */
298
+ /**
299
+ * @typedef {Object} SettingsMessageExchange
300
+ * @property {string} messageQueuePrefix
301
+ * @property {string} messageStore
302
+ * @property {boolean} securityHashEnabled
303
+ * @property {string} securityHashKey
304
+ * @property {number} traceExpirationTime
305
+ * @property {boolean} traceLogEnabled
306
+ * @property {string} traceRepository
307
+ */
308
+ /**
309
+ * @typedef {Object} SettingsServiceConfig
310
+ * @property {number} executionTimeout
311
+ * @property {string} healthCheckAddress
312
+ * @property {CronString} healthCheckInterval
313
+ * @property {number} healthCheckTimeout
314
+ * @property {string} serviceRegistryAddress
315
+ */
316
+ /**
317
+ * @typedef {string} CronString
318
+ */
319
+ /**
320
+ * @typedef {Object} TiEnumValue
321
+ * @property {number|string} value
322
+ * @property {string} name
323
+ * @property {string} [description]
324
+ */
325
+ /**
326
+ * @typedef {Object} TiEnum
327
+ * @property {Object.<string,TiEnumValue>} properties
328
+ * @property {(enumValue: number|string, placeholder?: string) => string|undefined} name
329
+ * @property {(enumValue: number|string, placeholder?: string) => string|undefined} description
330
+ * @property {(enumValue: number|string) => boolean} contains
331
+ */
332
+ /**
333
+ * The shape `tools.enum()` produces for a given seed. Every key of the seed is carried over as an enum
334
+ * member, so a typo is a compile error rather than `undefined` at runtime, and the lookup helpers of
335
+ * {@link TiEnum} come along with it. Members are typed as the value they hold, not as the
336
+ * `[ value, name, description ]` tuple the seed declares them with.
337
+ *
338
+ * @template {Record<string,*>} T
339
+ * @typedef {{ [K in keyof T]: number|string } & TiEnum} TiEnumOf
340
+ */
341
+ /**
342
+ * @typedef {Object} TiLogEntry
343
+ * @property {string} _id Unique identifier that can be used to identify the document in a NoSQL database.
344
+ * @property {TiLogSeverity} severity The log severity level.
345
+ * @property {string} thread The categorization of the log message.
346
+ * @property {string} reporter
347
+ * @property {string} message The actual log message.
348
+ * @property {number} timestamp The timestamp of the log entry in UTC time.
349
+ * @property {Object} data Additional JSON data to go with the message.
350
+ */
351
+ /**
352
+ * @typedef {Object} TiTraceEntry
353
+ * @property {string} chainID
354
+ * @property {string} dispatchEvent
355
+ * @property {string} fromAddress
356
+ * @property {string} messageID
357
+ * @property {Object} messageSnapshot
358
+ * @property {string} messageState
359
+ * @property {string} messageType
360
+ * @property {string} toAddress
361
+ * @property {string} traceID
362
+ * @property {number} traceTimestamp
363
+ */
364
+ /**
365
+ * The key of this object is the language code, and the value is the textual representation of the label.
366
+ *
367
+ * @typedef {Record<TiLocalizationLanguage, string>} TiLocalizedLabel
368
+ */
369
+ /**
370
+ * A nested labels tree where intermediate nodes are objects and leaf nodes are language-to-text maps.
371
+ *
372
+ * @typedef {{ [label: string]: TiLocalizedLabel | TiLabelsTree }} TiLabelsTree
373
+ */
374
+ /**
375
+ * @typedef {Object} ServiceAddress
376
+ * @property {string} serviceAlias A valid service alias.
377
+ * @property {string} serviceDomainName A valid service domain name.
378
+ * @property {number|undefined} serviceVersion Optional service version. If not provided, the latest version will be assumed as a target.
379
+ */
380
+ /**
381
+ * @typedef {Object} ServiceExecContext
382
+ * @property {string|undefined} authToken A valid authentication token that initialized the service call (if applicable).
383
+ * @property {ServiceCallPredecessor|undefined} previousServiceCall The previous service call in the execution chain (if such exists).
384
+ */
385
+ /**
386
+ * @typedef {Message} ServiceCallPredecessor
387
+ * @property {string} predecessor The {@link Message.messageID} of the predecessor in the service call tree.
388
+ * @property {ServiceAddress} serviceAddress The address of the service that has to process the service call.
389
+ * @property {Object|undefined} serviceParams The named params to be provided to the API service.
390
+ */
391
+ /**
392
+ * @typedef {ServiceCallPredecessor} ServiceCall
393
+ * @property {string} authToken A valid authentication token that initialized the service call.
394
+ * @property {number} createdOn A unix timestamp taken at creation time of the service call.
395
+ * @property {number} executionTime The total execution time of this service call in milliseconds.
396
+ * @property {Object|undefined} exception If there was exception during the service call processing, it will be set here. Otherwise, it will be 'undefined'.
397
+ * @property {number|undefined} finishedOn A unix timestamp taken at finish time of the service call.
398
+ * @property {boolean} isCompleted Flag to indicate if this service call has been completed.
399
+ * @property {boolean|undefined} isSuccessful A flag indicating if this service call can be considered successful or not. Will be 'undefined' until the service call is processed.
400
+ * @property {string[]} successors The service call IDs of the successors in the service call tree.
401
+ */
402
+ /**
403
+ * @typedef {Object} ServiceCallResult
404
+ * @property {TiException|undefined} exception If there was exception during the service call processing, it will be set here. Otherwise, it will be 'undefined'.
405
+ * @property {boolean} isSuccessful A flag indicating if this service call can be considered successful or not.
406
+ * @property {Object|string|undefined} payload The payload containing the results from the service call processing. If a string, it is ID of the payload in the memory cache instead.
407
+ */
408
+ /**
409
+ * @typedef {Object} ServiceDefinition
410
+ * @property {string} serviceAlias Service alias.
411
+ * @property {string} serviceFile The JS file containing the service itself. This has to be exposed via package.json import structure!
412
+ * @property {number} [serviceVersion] Service version.
413
+ */
414
+ /**
415
+ * @typedef {Record<string, ServiceInterfaceVersion>} ServiceInterface
416
+ */
417
+ /**
418
+ * @typedef {Record<number, ServiceHandlerMethod>} ServiceInterfaceVersion
419
+ */
420
+ /**
421
+ * @typedef {Object} ServiceConfiguration
422
+ * @property {ServiceDefinition[]} [services] A list of service definitions to be registered with the {@link ServiceProvider}.
423
+ */
424
+ /**
425
+ * @typedef {Object} MessageDestination
426
+ * @property {string|undefined} [instanceID] The instance ID of the message exchange by which the message was received (available after acceptance).
427
+ * @property {string} route The route to destination for the message. The exact structure will depend on the implementation of the message exchange.
428
+ */
429
+ /**
430
+ * @typedef {Object} MessageSource
431
+ * @property {string} instanceID The instance ID of the message exchange from which the service call originated.
432
+ * @property {string} route The route from source of the message. The exact structure will depend on the implementation of the message exchange.
433
+ */
434
+ /**
435
+ * @typedef {Object} Message
436
+ * @property {string} chainID Unique identifier of the message chain if the message is part of one.
437
+ * @property {number} chainLevel The node level of this message in the message chain tree.
438
+ * @property {MessageDestination} destination The destination of the message.
439
+ * @property {string} [hash] Security hash for the message if the mechanism is enabled.
440
+ * @property {string} messageID Unique message identifier.
441
+ * @property {Object|string|undefined} payload The message contents to be processed in destination. If a string, it is ID of the payload in the memory cache instead.
442
+ * Note that if this is not an Object or a string, there is no guarantee that it will be delivered in the same/proper format!
443
+ * @property {MessageSource} source The source of the message.
444
+ */
@@ -0,0 +1,61 @@
1
+ export = DefaultMessageExchange;
2
+ import MessageExchange = require("#message-exchange");
3
+ import type { Message } from "#definitions";
4
+ /** @import { Message } from "#definitions" */
5
+ /**
6
+ * The default {@link MessageExchange} behavior for the Ti Engine using Redis for message exchange.
7
+ *
8
+ * @class DefaultMessageExchange
9
+ * @extends MessageExchange
10
+ * @public
11
+ */
12
+ declare class DefaultMessageExchange extends MessageExchange {
13
+ /**
14
+ * @constructor
15
+ * @param {string} instanceID The unique identifier of the microservice instance using the message exchange.
16
+ * @param {string} serviceDomainName The domain name of the microservice using the message exchange.
17
+ */
18
+ constructor(instanceID: string, serviceDomainName: string);
19
+ /**
20
+ * Used to initialize the message exchange.
21
+ * <br/>
22
+ * NOTE: This will create and prepare all necessary message handlers and then enable them simultaneously.
23
+ *
24
+ * @method
25
+ * @param {boolean} configureInbound If set to 'true' it tells the message exchange to set up inbound messaging.
26
+ * @param {boolean} configureOutbound If set to 'true' it tells the message exchange to set up outbound messaging.
27
+ * @returns {Promise}
28
+ * @override
29
+ * @public
30
+ */
31
+ enableMessaging(configureInbound: boolean, configureOutbound: boolean): Promise<any>;
32
+ /**
33
+ * Used to gracefully shut down the message exchange.
34
+ *
35
+ * @method
36
+ * @returns {Promise}
37
+ * @override
38
+ * @public
39
+ */
40
+ disableMessaging(): Promise<any>;
41
+ /**
42
+ * Used to send a message request vie the specified route.
43
+ *
44
+ * @method
45
+ * @param {Message} message The message request to send.
46
+ * @returns {Promise}
47
+ * @override
48
+ * @public
49
+ */
50
+ sendMessageRequest(message: Message): Promise<any>;
51
+ /**
52
+ * Used to send a message response via the specified route.
53
+ *
54
+ * @method
55
+ * @param {Message} message The message response to send.
56
+ * @returns {Promise}
57
+ * @override
58
+ * @public
59
+ */
60
+ sendMessageResponse(message: Message): Promise<any>;
61
+ }
@@ -0,0 +1,49 @@
1
+ export = DefaultMessageReceiver;
2
+ import MessageReceiver = require("#message-receiver");
3
+ import type { Message } from "#definitions";
4
+ /** @import { Message } from "#definitions" */
5
+ /**
6
+ * The default {@link MessageReceiver} behavior for the Ti Engine using Redis for message exchange.
7
+ *
8
+ * @class DefaultMessageReceiver
9
+ * @extends MessageReceiver
10
+ * @public
11
+ */
12
+ declare class DefaultMessageReceiver extends MessageReceiver {
13
+ #private;
14
+ /**
15
+ * @constructor
16
+ * @param {string} identifier An identifier for this message handler. Should be unique in the context of the message exchange.
17
+ * @param {string} receiveQueue The queue from which the messages will be received.
18
+ */
19
+ constructor(identifier: string, receiveQueue: string);
20
+ /**
21
+ * Used to initialize and enable the communication capabilities of the handler.
22
+ *
23
+ * @method
24
+ * @returns {Promise}
25
+ * @override
26
+ * @public
27
+ */
28
+ enable(): Promise<any>;
29
+ /**
30
+ * Used to shut down and disable the communication behavior of the handler.
31
+ *
32
+ * @method
33
+ * @returns {Promise}
34
+ * @override
35
+ * @public
36
+ */
37
+ disable(): Promise<any>;
38
+ /**
39
+ * Used to receive messages.
40
+ * <br/>
41
+ * NOTE: The default message exchange works with lightweight messages (i.e. will keep the payloads stored in Redis while exchanging).
42
+ *
43
+ * @method
44
+ * @returns {Promise<Message>}
45
+ * @override
46
+ * @public
47
+ */
48
+ onReceive(): Promise<Message>;
49
+ }
@@ -0,0 +1,50 @@
1
+ export = DefaultMessageSender;
2
+ import MessageSender = require("#message-sender");
3
+ import type { Message } from "#definitions";
4
+ /** @import { Message } from "#definitions" */
5
+ /**
6
+ * The default {@link MessageSender} behavior for the Ti Engine using Redis for message exchange.
7
+ *
8
+ * @class DefaultMessageSender
9
+ * @extends MessageSender
10
+ * @public
11
+ */
12
+ declare class DefaultMessageSender extends MessageSender {
13
+ #private;
14
+ /**
15
+ * @constructor
16
+ * @param {string} identifier An identifier for this message handler. Should be unique in the context of the message exchange.
17
+ */
18
+ constructor(identifier: string);
19
+ /**
20
+ * Used to perform the actual sending of a message.
21
+ * <br/>
22
+ * NOTE: The default message exchange works with lightweight messages (i.e., will keep the payloads stored in Redis while exchanging).
23
+ *
24
+ * @method
25
+ * @param {Message} message The message to send.
26
+ * @param {string} queue The route to destination (queue) for the message as recognized by the {@link MessageExchange} implementation.
27
+ * @returns {Promise}
28
+ * @override
29
+ * @public
30
+ */
31
+ onSend(message: Message, queue: string): Promise<any>;
32
+ /**
33
+ * Used to initialize and enable the communication capabilities of the handler.
34
+ *
35
+ * @method
36
+ * @returns {Promise}
37
+ * @override
38
+ * @public
39
+ */
40
+ enable(): Promise<any>;
41
+ /**
42
+ * Used to shut down and disable the communication behavior of the handler.
43
+ *
44
+ * @method
45
+ * @returns {Promise}
46
+ * @override
47
+ * @public
48
+ */
49
+ disable(): Promise<any>;
50
+ }
@@ -0,0 +1,77 @@
1
+ declare const _exported: Readonly<MessageDispatcher>;
2
+ export { _exported as instance };
3
+ import type { Message } from "#definitions";
4
+ import type MessageExchange from "#message-exchange";
5
+ import type MessageObserver from "#message-observer";
6
+ /** @import { Message } from "#definitions" */
7
+ /** @import MessageExchange from "#message-exchange" */
8
+ /** @import MessageObserver from "#message-observer" */
9
+ /**
10
+ * Used to create and/or return a Message Dispatcher singleton instance.
11
+ * This class handles the internal message dispatching between the microservices.
12
+ *
13
+ * @class MessageDispatcher
14
+ * @singleton
15
+ * @public
16
+ */
17
+ declare class MessageDispatcher {
18
+ #private;
19
+ /**
20
+ * @constructor
21
+ * @returns {MessageDispatcher}
22
+ */
23
+ constructor();
24
+ /**
25
+ * Used to initialize the message dispatcher and enable the message exchange.
26
+ *
27
+ * @method
28
+ * @param {MessageExchange} messageExchange The message exchange instance to be used by the dispatcher.
29
+ * @param {boolean} configureInbound If set to 'true' it tells the message exchange to set up inbound messaging.
30
+ * @param {boolean} configureOutbound If set to 'true' it tells the message exchange to set up outbound messaging.
31
+ * @returns {Promise}
32
+ * @public
33
+ */
34
+ initialize(messageExchange: MessageExchange, configureInbound: boolean, configureOutbound: boolean): Promise<any>;
35
+ /**
36
+ * Used to shut down the message dispatcher and disable the message exchange.
37
+ *
38
+ * @method
39
+ * @returns {Promise}
40
+ * @public
41
+ */
42
+ shutDown(): Promise<any>;
43
+ /**
44
+ * Used to send a message request via the message exchange system.
45
+ *
46
+ * @method
47
+ * @param {Message} message The message to send. This can also be a subclass of {@link Message}.
48
+ * @returns {Promise<string>}
49
+ * @public
50
+ */
51
+ sendRequest(message: Message): Promise<string>;
52
+ /**
53
+ * Used to send a message response via the message exchange system.
54
+ *
55
+ * @method
56
+ * @param {Message} message The message to send. This can also be a subclass of {@link Message}.
57
+ * @returns {Promise}
58
+ * @public
59
+ */
60
+ sendResponse(message: Message): Promise<any>;
61
+ /**
62
+ * Used to add an additional {@link MessageObserver} to the connection for the incoming message requests.
63
+ *
64
+ * @method
65
+ * @param {MessageObserver} messageObserver
66
+ * @public
67
+ */
68
+ addMessageObserverRequestsIn(messageObserver: MessageObserver): void;
69
+ /**
70
+ * Used to add an additional {@link MessageObserver} to the connection for the incoming message responses.
71
+ *
72
+ * @method
73
+ * @param {MessageObserver} messageObserver
74
+ * @public
75
+ */
76
+ addMessageObserverResponsesIn(messageObserver: MessageObserver): void;
77
+ }