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