@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.
- package/CHANGELOG.md +37 -0
- package/components/auditing.js +2 -4
- package/components/definitions.types.js +19 -4
- package/components/exchange/default/default-message-exchange.js +2 -0
- package/components/exchange/default/default-message-receiver.js +2 -0
- package/components/exchange/default/default-message-sender.js +2 -0
- package/components/exchange/message-dispatcher.js +4 -0
- package/components/exchange/message-exchange.js +4 -0
- package/components/exchange/message-handler.js +7 -5
- package/components/exchange/message-memory-cache.js +3 -0
- package/components/exchange/message-observer.js +2 -0
- package/components/exchange/message-receiver.js +2 -1
- package/components/exchange/message-sender.js +2 -2
- package/components/exchange/message-tracer.js +2 -3
- package/components/service-caller.js +2 -5
- package/components/service-consumer.js +2 -0
- package/components/service-executor.js +3 -5
- package/components/service-instance.js +2 -4
- package/components/service-provider.js +3 -0
- package/integrations/redis-integration.js +1 -5
- package/package.json +152 -36
- package/types/bin/start-instance.d.ts +1 -0
- package/types/components/auditing.d.ts +30 -0
- package/types/components/connection-observer.d.ts +49 -0
- package/types/components/definitions.types.d.ts +443 -0
- package/types/components/exchange/default/default-message-exchange.d.ts +61 -0
- package/types/components/exchange/default/default-message-receiver.d.ts +49 -0
- package/types/components/exchange/default/default-message-sender.d.ts +50 -0
- package/types/components/exchange/message-dispatcher.d.ts +77 -0
- package/types/components/exchange/message-exchange.d.ts +306 -0
- package/types/components/exchange/message-handler.d.ts +132 -0
- package/types/components/exchange/message-memory-cache.d.ts +84 -0
- package/types/components/exchange/message-observer.d.ts +87 -0
- package/types/components/exchange/message-receiver.d.ts +91 -0
- package/types/components/exchange/message-sender.d.ts +68 -0
- package/types/components/exchange/message-tracer.d.ts +84 -0
- package/types/components/service-caller.d.ts +68 -0
- package/types/components/service-consumer.d.ts +81 -0
- package/types/components/service-executor.d.ts +101 -0
- package/types/components/service-instance.d.ts +111 -0
- package/types/components/service-provider.d.ts +120 -0
- package/types/integrations/redis-integration.d.ts +223 -0
- package/types/utils/cache.d.ts +320 -0
- package/types/utils/config.d.ts +40 -0
- package/types/utils/exceptions.d.ts +224 -0
- package/types/utils/localization.d.ts +194 -0
- package/types/utils/logger.d.ts +24 -0
- package/types/utils/tools.d.ts +70 -0
- package/utils/cache.js +0 -1
- package/utils/exceptions.js +2 -0
- package/utils/localization.js +2 -0
- package/utils/logger.js +2 -0
- package/utils/tools.js +10 -8
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
export = MessageExchange;
|
|
2
|
+
import MessageObserver = require("#message-observer");
|
|
3
|
+
import type { Message } from "#definitions";
|
|
4
|
+
import type MessageReceiver from "#message-receiver";
|
|
5
|
+
import type MessageSender from "#message-sender";
|
|
6
|
+
/** @import { Message } from "#definitions" */
|
|
7
|
+
/** @import MessageReceiver from "#message-receiver" */
|
|
8
|
+
/** @import MessageSender from "#message-sender" */
|
|
9
|
+
/**
|
|
10
|
+
* An abstract class that defines a message exchange behavior.
|
|
11
|
+
* <br/>
|
|
12
|
+
* NOTE: While this sets the basis frame for the message-based communication between microservices, it has to be inherited and
|
|
13
|
+
* extended with additional logic that is NOT implemented here. For a working example please see {@link DefaultMessageExchange} class.
|
|
14
|
+
* <br/>
|
|
15
|
+
* NOTE: This class and its children are designed to be used internally by the {@link MessageDispatcher} and its related classes.
|
|
16
|
+
*
|
|
17
|
+
* @class MessageExchange
|
|
18
|
+
* @extends MessageObserver
|
|
19
|
+
* @abstract
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
declare class MessageExchange extends MessageObserver {
|
|
23
|
+
#private;
|
|
24
|
+
/**
|
|
25
|
+
* @constructor
|
|
26
|
+
* @param {string} instanceID The unique identifier of the microservice instance using the message exchange.
|
|
27
|
+
* @param {string} serviceDomainName The domain name of the microservice using the message exchange.
|
|
28
|
+
* @throws {TiException.E_GEN_ABSTRACT_CLASS_INIT} If this class is instantiated directly.
|
|
29
|
+
*/
|
|
30
|
+
constructor(instanceID: string, serviceDomainName: string);
|
|
31
|
+
/**
|
|
32
|
+
* Property returning the configured connection name for the outgoing message requests.
|
|
33
|
+
*
|
|
34
|
+
* @property
|
|
35
|
+
* @returns {string}
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
static get connectionNameRequestsOut(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Used to set the connection name for the outgoing message requests.
|
|
41
|
+
*
|
|
42
|
+
* @property
|
|
43
|
+
* @param {string} value
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
static set connectionNameRequestsOut(value: string);
|
|
47
|
+
/**
|
|
48
|
+
* Property returning the configured connection name for the incoming message requests.
|
|
49
|
+
*
|
|
50
|
+
* @property
|
|
51
|
+
* @returns {string}
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
static get connectionNameRequestsIn(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Used to set the connection name for the incoming message requests.
|
|
57
|
+
*
|
|
58
|
+
* @property
|
|
59
|
+
* @param {string} value
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
static set connectionNameRequestsIn(value: string);
|
|
63
|
+
/**
|
|
64
|
+
* Property returning the configured connection name for the outgoing message responses.
|
|
65
|
+
*
|
|
66
|
+
* @property
|
|
67
|
+
* @returns {string}
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
static get connectionNameResponsesOut(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Used to set the connection name for the outgoing message responses.
|
|
73
|
+
*
|
|
74
|
+
* @property
|
|
75
|
+
* @param {string} value
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
static set connectionNameResponsesOut(value: string);
|
|
79
|
+
/**
|
|
80
|
+
* Property returning the configured connection name for the incoming message responses.
|
|
81
|
+
*
|
|
82
|
+
* @property
|
|
83
|
+
* @returns {string}
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
static get connectionNameResponsesIn(): string;
|
|
87
|
+
/**
|
|
88
|
+
* Used to set the connection name for the incoming message responses.
|
|
89
|
+
*
|
|
90
|
+
* @property
|
|
91
|
+
* @param {string} value
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
static set connectionNameResponsesIn(value: string);
|
|
95
|
+
/**
|
|
96
|
+
* Property returning the identifier of the pending messages queue.
|
|
97
|
+
*
|
|
98
|
+
* @property
|
|
99
|
+
* @returns {string}
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
static get pendingQueue(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Property returning the identifier of the processed messages queue.
|
|
105
|
+
*
|
|
106
|
+
* @property
|
|
107
|
+
* @returns {string}
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
static get processedQueue(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Property returning the configured service instance ID.
|
|
113
|
+
*
|
|
114
|
+
* @property
|
|
115
|
+
* @returns {string}
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
get instanceID(): string;
|
|
119
|
+
/**
|
|
120
|
+
* Property returning the configured service domain name.
|
|
121
|
+
*
|
|
122
|
+
* @property
|
|
123
|
+
* @returns {string}
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
get serviceDomainName(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Returns the currently configured {@link MessageSender} for outbound message requests.
|
|
129
|
+
*
|
|
130
|
+
* @property
|
|
131
|
+
* @returns {MessageSender}
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
get messageRequestsOut(): MessageSender;
|
|
135
|
+
/**
|
|
136
|
+
* Returns the currently configured {@link MessageSender} for outbound message responses.
|
|
137
|
+
*
|
|
138
|
+
* @property
|
|
139
|
+
* @returns {MessageSender}
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
get messageResponsesOut(): MessageSender;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the currently configured {@link MessageReceiver} for inbound message requests.
|
|
145
|
+
*
|
|
146
|
+
* @property
|
|
147
|
+
* @returns {MessageReceiver}
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
get messageRequestsIn(): MessageReceiver;
|
|
151
|
+
/**
|
|
152
|
+
* Returns the currently configured {@link MessageReceiver} for inbound message responses.
|
|
153
|
+
*
|
|
154
|
+
* @property
|
|
155
|
+
* @returns {MessageReceiver}
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
get messageResponsesIn(): MessageReceiver;
|
|
159
|
+
/**
|
|
160
|
+
* Returns a flag indicating if the message exchange is configured for outbound communication.
|
|
161
|
+
*
|
|
162
|
+
* @property
|
|
163
|
+
* @returns {boolean}
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
get configuredOutbound(): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Returns a flag indicating if the message exchange is configured for inbound communication.
|
|
169
|
+
*
|
|
170
|
+
* @property
|
|
171
|
+
* @returns {boolean}
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
get configuredInbound(): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Should be used to enable all communication channels for messaging.
|
|
177
|
+
* <br/>
|
|
178
|
+
* NOTE: Override this to implement messaging initialization.
|
|
179
|
+
*
|
|
180
|
+
* @method
|
|
181
|
+
* @param {boolean} configureInbound If set to 'true' it tells the message exchange to set up inbound messaging.
|
|
182
|
+
* @param {boolean} configureOutbound If set to 'true' it tells the message exchange to set up outbound messaging.
|
|
183
|
+
* @returns {Promise}
|
|
184
|
+
* @abstract
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
enableMessaging(configureInbound: boolean, configureOutbound: boolean): Promise<any>;
|
|
188
|
+
/**
|
|
189
|
+
* Should be used to gracefully disable all communication channels for messaging.
|
|
190
|
+
* <br/>
|
|
191
|
+
* NOTE: Override this to implement graceful messaging shut down.
|
|
192
|
+
*
|
|
193
|
+
* @method
|
|
194
|
+
* @returns {Promise}
|
|
195
|
+
* @abstract
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
disableMessaging(): Promise<any>;
|
|
199
|
+
/**
|
|
200
|
+
* Used to configure the message exchange for receiving inbound messages and returning responses to them.
|
|
201
|
+
* Should typically be called from an implemented {@link enableMessaging} method.
|
|
202
|
+
*
|
|
203
|
+
* @method
|
|
204
|
+
* @param {MessageReceiver} messageReceiverRequestsIn A message receiver that will handle the inbound messages.
|
|
205
|
+
* @param {MessageSender} messageSenderResponsesOut A message sender that will handle the sending of responses for the inbound messages.
|
|
206
|
+
* @public
|
|
207
|
+
*/
|
|
208
|
+
configureInboundMessaging(messageReceiverRequestsIn: MessageReceiver, messageSenderResponsesOut: MessageSender): void;
|
|
209
|
+
/**
|
|
210
|
+
* Used to configure message exchange for sending messages and receiving responses to them.
|
|
211
|
+
* Should typically be called from an implemented {@link enableMessaging} method.
|
|
212
|
+
*
|
|
213
|
+
* @method
|
|
214
|
+
* @param {MessageSender} messageSenderRequestsOut A message sender that will handle the outbound messages.
|
|
215
|
+
* @param {MessageReceiver} messageReceiverResponsesIn A message receiver that will handle the returned responses for the outbound messages.
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
configureOutboundMessaging(messageSenderRequestsOut: MessageSender, messageReceiverResponsesIn: MessageReceiver): void;
|
|
219
|
+
/**
|
|
220
|
+
* Used to add an additional {@link MessageObserver} to the connection for the incoming message requests.
|
|
221
|
+
*
|
|
222
|
+
* @method
|
|
223
|
+
* @param {MessageObserver} messageObserver
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
addMessageObserverRequestsIn(messageObserver: MessageObserver): void;
|
|
227
|
+
/**
|
|
228
|
+
* Used to add an additional {@link MessageObserver} to the connection for the incoming message responses.
|
|
229
|
+
*
|
|
230
|
+
* @method
|
|
231
|
+
* @param {MessageObserver} messageObserver
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
234
|
+
addMessageObserverResponsesIn(messageObserver: MessageObserver): void;
|
|
235
|
+
/**
|
|
236
|
+
* Used to mark the connection with the provided identifier as disrupted.
|
|
237
|
+
*
|
|
238
|
+
* @method
|
|
239
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
240
|
+
* @override
|
|
241
|
+
* @public
|
|
242
|
+
*/
|
|
243
|
+
onConnectionDisrupted(identifier: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* Used to mark the connection with the provided identifier as recovered.
|
|
246
|
+
* <br/>
|
|
247
|
+
* NOTE: This will also result in enabling the message exchange if no connections are currently disrupted.
|
|
248
|
+
*
|
|
249
|
+
* @method
|
|
250
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
251
|
+
* @override
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
onConnectionRecovered(identifier: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* Used to mark the connection with the provided identifier as disrupted.
|
|
257
|
+
*
|
|
258
|
+
* @method
|
|
259
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
260
|
+
* @override
|
|
261
|
+
* @public
|
|
262
|
+
*/
|
|
263
|
+
onConnectionLost(identifier: string): void;
|
|
264
|
+
/**
|
|
265
|
+
* Used only for the message tracer.
|
|
266
|
+
*
|
|
267
|
+
* @method
|
|
268
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
269
|
+
* @param {Message} message The message for processing.
|
|
270
|
+
* @returns {Message} The message that was received.
|
|
271
|
+
* @override
|
|
272
|
+
* @public
|
|
273
|
+
*/
|
|
274
|
+
onMessage(identifier: string, message: Message): Message;
|
|
275
|
+
/**
|
|
276
|
+
* Used to check whether the connection with the provided identifier is currently in recovery mode.
|
|
277
|
+
*
|
|
278
|
+
* @method
|
|
279
|
+
* @param {string} identifier The identifier of the connection.
|
|
280
|
+
* @returns {boolean} Will return 'true' if the connection is currently disrupted and not yet recovered.
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
isConnectionInRecovery(identifier: string): boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Used to send a message request. Override of this method assumes that the message itself contains enough
|
|
286
|
+
* information to determine the sending destination.
|
|
287
|
+
*
|
|
288
|
+
* @method
|
|
289
|
+
* @param {Message} message The message request to send.
|
|
290
|
+
* @returns {Promise}
|
|
291
|
+
* @abstract
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
sendMessageRequest(message: Message): Promise<any>;
|
|
295
|
+
/**
|
|
296
|
+
* Used to send a message response. Override of this method assumes that the message itself contains enough
|
|
297
|
+
* information to determine the sending destination.
|
|
298
|
+
*
|
|
299
|
+
* @method
|
|
300
|
+
* @param {Message} message The message response to send.
|
|
301
|
+
* @returns {Promise}
|
|
302
|
+
* @abstract
|
|
303
|
+
* @public
|
|
304
|
+
*/
|
|
305
|
+
sendMessageResponse(message: Message): Promise<any>;
|
|
306
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export = MessageHandler;
|
|
2
|
+
import ConnectionObserver = require("#connection-observer");
|
|
3
|
+
import type { Message } from "#definitions";
|
|
4
|
+
import type MessageObserver from "#message-observer";
|
|
5
|
+
/**
|
|
6
|
+
* An abstract class that defines a basic message handler behavior.
|
|
7
|
+
* <br/>
|
|
8
|
+
* NOTE: This class and its children are designed to be used internally by classes extending the {@link MessageObserver} class.
|
|
9
|
+
*
|
|
10
|
+
* @class MessageHandler
|
|
11
|
+
* @extends ConnectionObserver
|
|
12
|
+
* @abstract
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
declare class MessageHandler extends ConnectionObserver {
|
|
16
|
+
#private;
|
|
17
|
+
/**
|
|
18
|
+
* @constructor
|
|
19
|
+
* @param {string} identifier An identifier for this message handler. Should be unique in the context of the message exchange.
|
|
20
|
+
* @throws {TiException.E_GEN_ABSTRACT_CLASS_INIT} If this class is instantiated directly.
|
|
21
|
+
*/
|
|
22
|
+
constructor(identifier: string);
|
|
23
|
+
/**
|
|
24
|
+
* Indicates whether the message handler is currently available.
|
|
25
|
+
*
|
|
26
|
+
* @property
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
get isAvailable(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Used to set the isAvailable flag.
|
|
33
|
+
* <br/>
|
|
34
|
+
* NOTE: For use by implementing classes only!
|
|
35
|
+
*
|
|
36
|
+
* @property
|
|
37
|
+
* @param {boolean} value
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
set isAvailable(value: boolean);
|
|
41
|
+
/**
|
|
42
|
+
* Returns the connection identifier.
|
|
43
|
+
*
|
|
44
|
+
* @property
|
|
45
|
+
* @returns {string}
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
get connectionIdentifier(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Used to initialize and enable the communication capabilities of the handler.
|
|
51
|
+
* <br/>
|
|
52
|
+
* NOTE: Override this to add functionality.
|
|
53
|
+
*
|
|
54
|
+
* @method
|
|
55
|
+
* @returns {Promise}
|
|
56
|
+
* @abstract
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
enable(): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Used to shut down and disable the communication behavior of the handler.
|
|
62
|
+
* <br/>
|
|
63
|
+
* NOTE: Override this to add functionality.
|
|
64
|
+
*
|
|
65
|
+
* @method
|
|
66
|
+
* @returns {Promise}
|
|
67
|
+
* @abstract
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
disable(): Promise<any>;
|
|
71
|
+
/**
|
|
72
|
+
* Used to create a security hash from the message.
|
|
73
|
+
*
|
|
74
|
+
* @method
|
|
75
|
+
* @param {Message} message
|
|
76
|
+
* @returns {string}
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
createMessageHash(message: Message): string;
|
|
80
|
+
/**
|
|
81
|
+
* Used to register a new {@link MessageObserver} for events related to the messages passing through this handler.
|
|
82
|
+
*
|
|
83
|
+
* @method
|
|
84
|
+
* @param {MessageObserver} messageObserver The {@link MessageObserver} that will be notified of any changes.
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
addMessageObserver(messageObserver: MessageObserver): void;
|
|
88
|
+
/**
|
|
89
|
+
* An event-triggered method that will notify any observers about a new message for handling.
|
|
90
|
+
* <br/>
|
|
91
|
+
* NOTE: Each observer will be notified in the order of their priority via their {@link MessageObserver.onMessage} method. Additionally, the message will be
|
|
92
|
+
* passed through each observer in the order of their priority. If the observer returns a modified message, it will be used instead of the original message!
|
|
93
|
+
*
|
|
94
|
+
* @method
|
|
95
|
+
* @param {Message} message
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
notifyMessageObservers(message: Message): void;
|
|
99
|
+
/**
|
|
100
|
+
* An event-triggered method that will notify any observers about the primary connection recovered state.
|
|
101
|
+
* <br/>
|
|
102
|
+
* NOTE: You can override this to add custom functionality but make sure to also call the base method
|
|
103
|
+
* using: super.onConnectionRecovered( identifier )
|
|
104
|
+
*
|
|
105
|
+
* @method
|
|
106
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
107
|
+
* @override
|
|
108
|
+
*/
|
|
109
|
+
onConnectionRecovered(identifier: string): void;
|
|
110
|
+
/**
|
|
111
|
+
* An event-triggered method that will notify any observers about the primary connection disrupted state.
|
|
112
|
+
* <br/>
|
|
113
|
+
* NOTE: You can override this to add custom functionality but make sure to also call the base method
|
|
114
|
+
* using: super.onConnectionDisrupted( identifier )
|
|
115
|
+
*
|
|
116
|
+
* @method
|
|
117
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
118
|
+
* @override
|
|
119
|
+
*/
|
|
120
|
+
onConnectionDisrupted(identifier: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* An event-triggered method that will notify any observers about the primary connection having been lost.
|
|
123
|
+
* <br/>
|
|
124
|
+
* NOTE: You can override this to add custom functionality but make sure to also call the base method
|
|
125
|
+
* using: super.onConnectionLost( identifier )
|
|
126
|
+
*
|
|
127
|
+
* @method
|
|
128
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
129
|
+
* @override
|
|
130
|
+
*/
|
|
131
|
+
onConnectionLost(identifier: string): void;
|
|
132
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export declare var create: (identifier: string) => MessageMemoryCache;
|
|
2
|
+
import type ConnectionObserver from "#connection-observer";
|
|
3
|
+
import type { Message } from "#definitions";
|
|
4
|
+
/** @import ConnectionObserver from "#connection-observer" */
|
|
5
|
+
/** @import { Message } from "#definitions" */
|
|
6
|
+
/**
|
|
7
|
+
* Used to create a Redis Cache client wrapped in a specialized message memory cache interface.
|
|
8
|
+
*
|
|
9
|
+
* @class MessageMemoryCache
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
declare class MessageMemoryCache {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {string} identifier The connection identifier for the Redis connection.
|
|
17
|
+
* @returns {MessageMemoryCache}
|
|
18
|
+
*/
|
|
19
|
+
constructor(identifier: string);
|
|
20
|
+
/**
|
|
21
|
+
* Used to initialize the cache service.
|
|
22
|
+
*
|
|
23
|
+
* @method
|
|
24
|
+
* @returns {Promise}
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
initialize(): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Used to gracefully shut down the cache service.
|
|
30
|
+
*
|
|
31
|
+
* @method
|
|
32
|
+
* @param {number} [timeoutMs]
|
|
33
|
+
* @returns {Promise}
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
shutDown(timeoutMs?: number): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* Used to register a new {@link ConnectionObserver} for events related to the Redis connection state.
|
|
39
|
+
*
|
|
40
|
+
* @method
|
|
41
|
+
* @param {ConnectionObserver} connectionObserver The {@link ConnectionObserver} that will be notified of any changes.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
addConnectionObserver(connectionObserver: ConnectionObserver): void;
|
|
45
|
+
/**
|
|
46
|
+
* Used to send a message to the specified route.
|
|
47
|
+
*
|
|
48
|
+
* @method
|
|
49
|
+
* @param {Message} message The message to send.
|
|
50
|
+
* @param {string} queue The destination queue for the message as recognized by the {@link MessageExchange} implementation.
|
|
51
|
+
* @returns {Promise<number>} Will return the destination queue length after adding the current message to it.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
sendMessage(message: Message, queue: string): Promise<number>;
|
|
55
|
+
/**
|
|
56
|
+
* Used to store a message payload.
|
|
57
|
+
*
|
|
58
|
+
* @method
|
|
59
|
+
* @param {Object} payload
|
|
60
|
+
* @param {string} storeLocation
|
|
61
|
+
* @returns {Promise<string>} Will return a unique ID of the storage location for the payload.
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
storeMessagePayload(payload: Object, storeLocation: string): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Used to receive a message from the specified queue.
|
|
67
|
+
*
|
|
68
|
+
* @method
|
|
69
|
+
* @param {string} queue
|
|
70
|
+
* @returns {Promise<Message>}
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
receiveMessage(queue: string): Promise<Message>;
|
|
74
|
+
/**
|
|
75
|
+
* Used to retrieve a message payload by its store ID.
|
|
76
|
+
*
|
|
77
|
+
* @method
|
|
78
|
+
* @param {Message} message
|
|
79
|
+
* @param {string} storeLocation
|
|
80
|
+
* @returns {Promise<Message>} Will return the message with its payload populated if such is found.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
retrieveMessagePayload(message: Message, storeLocation: string): Promise<Message>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export = MessageObserver;
|
|
2
|
+
import ConnectionObserver = require("#connection-observer");
|
|
3
|
+
import type { Message } from "#definitions";
|
|
4
|
+
/** @import { Message } from "#definitions" */
|
|
5
|
+
/**
|
|
6
|
+
* An abstract class that allows the child class to observe and take action on message events.
|
|
7
|
+
* <br/>
|
|
8
|
+
* NOTE: This class inherits {@link ConnectionObserver} so it can also act in that capacity.
|
|
9
|
+
*
|
|
10
|
+
* @class MessageObserver
|
|
11
|
+
* @extends ConnectionObserver
|
|
12
|
+
* @abstract
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
declare class MessageObserver extends ConnectionObserver {
|
|
16
|
+
#private;
|
|
17
|
+
/**
|
|
18
|
+
* @constructor
|
|
19
|
+
* @param {number} [priority=0] The priority of this observer. Higher values indicate higher priority.
|
|
20
|
+
* @throws {TiException.E_GEN_ABSTRACT_CLASS_INIT} If this class is instantiated directly.
|
|
21
|
+
*/
|
|
22
|
+
constructor(priority?: number);
|
|
23
|
+
/**
|
|
24
|
+
* Returns the priority of this observer.
|
|
25
|
+
* <br/>
|
|
26
|
+
* NOTE: Higher values indicate higher priority.
|
|
27
|
+
*
|
|
28
|
+
* @property
|
|
29
|
+
* @returns {number}
|
|
30
|
+
*/
|
|
31
|
+
get priority(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Used to set the priority of this observer.
|
|
34
|
+
* <br/>
|
|
35
|
+
* NOTE: Higher values indicate higher priority.
|
|
36
|
+
*
|
|
37
|
+
* @property
|
|
38
|
+
* @param {number} value
|
|
39
|
+
*/
|
|
40
|
+
set priority(value: number);
|
|
41
|
+
/**
|
|
42
|
+
* Needs to be invoked by the message handler once a message enters its logic for processing.
|
|
43
|
+
* <br/>
|
|
44
|
+
* NOTE: Override this to add custom functionality.
|
|
45
|
+
*
|
|
46
|
+
* @method
|
|
47
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
48
|
+
* @param {Message} message The message for processing.
|
|
49
|
+
* @returns {Message} The message that was received.
|
|
50
|
+
* @virtual
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
onMessage(identifier: string, message: Message): Message;
|
|
54
|
+
/**
|
|
55
|
+
* Needs to be invoked by the connection handler when the connection is disrupted.
|
|
56
|
+
* <br/>
|
|
57
|
+
* NOTE: Override this to add custom functionality.
|
|
58
|
+
*
|
|
59
|
+
* @method
|
|
60
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
61
|
+
* @virtual
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
onConnectionDisrupted(identifier: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Needs to be invoked by the connection handler when the connection is recovered.
|
|
67
|
+
* <br/>
|
|
68
|
+
* NOTE: Override this to add custom functionality.
|
|
69
|
+
*
|
|
70
|
+
* @method
|
|
71
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
72
|
+
* @virtual
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
onConnectionRecovered(identifier: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Needs to be invoked by the connection handler when the connection is irrevocably lost.
|
|
78
|
+
* <br/>
|
|
79
|
+
* NOTE: Override this to add custom functionality.
|
|
80
|
+
*
|
|
81
|
+
* @method
|
|
82
|
+
* @param {string} identifier The identifier of the observed connection.
|
|
83
|
+
* @virtual
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
onConnectionLost(identifier: string): void;
|
|
87
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export = MessageReceiver;
|
|
2
|
+
import MessageHandler = require("#message-handler");
|
|
3
|
+
import type { Message } from "#definitions";
|
|
4
|
+
/** @import { Message } from "#definitions" */
|
|
5
|
+
/**
|
|
6
|
+
* An abstract class that defines a basic message receiver behavior.
|
|
7
|
+
*
|
|
8
|
+
* @class MessageReceiver
|
|
9
|
+
* @extends MessageHandler
|
|
10
|
+
* @abstract
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
declare class MessageReceiver extends MessageHandler {
|
|
14
|
+
#private;
|
|
15
|
+
/**
|
|
16
|
+
* @constructor
|
|
17
|
+
* @param {string} identifier An identifier for this message handler. Should be unique in the context of the message exchange.
|
|
18
|
+
* @param {string} receiveQueue The queue from which the messages will be received.
|
|
19
|
+
* @throws {TiException.E_GEN_ABSTRACT_CLASS_INIT} If this class is instantiated directly.
|
|
20
|
+
*/
|
|
21
|
+
constructor(identifier: string, receiveQueue: string);
|
|
22
|
+
/**
|
|
23
|
+
* Property returning the configured receiving queue.
|
|
24
|
+
*
|
|
25
|
+
* @property
|
|
26
|
+
* @returns {string}
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
get receiveQueue(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Indicates whether the receiver is currently receiving messages.
|
|
32
|
+
*
|
|
33
|
+
* @property
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
get isReceiving(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Used to set the value of the {@link MessageReceiver#isReceiving} property.
|
|
40
|
+
*
|
|
41
|
+
* @property
|
|
42
|
+
* @param {boolean} value
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
set isReceiving(value: boolean);
|
|
46
|
+
/**
|
|
47
|
+
* Used to initialize and enable the communication capabilities of the handler.
|
|
48
|
+
* <br/>
|
|
49
|
+
* NOTE: Override this to add functionality.
|
|
50
|
+
*
|
|
51
|
+
* @method
|
|
52
|
+
* @returns {Promise}
|
|
53
|
+
* @abstract
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
enable(): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Used to shut down and disable the communication behavior of the handler.
|
|
59
|
+
* <br/>
|
|
60
|
+
* NOTE: Override this to add functionality.
|
|
61
|
+
*
|
|
62
|
+
* @method
|
|
63
|
+
* @returns {Promise}
|
|
64
|
+
* @abstract
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
disable(): Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
* Used to receive messages.
|
|
70
|
+
* <br/>
|
|
71
|
+
* NOTE: This method will start a recursion of subsequent receive calls that will continue even if an individual message fetch fails.
|
|
72
|
+
*
|
|
73
|
+
* @method
|
|
74
|
+
* @recursion
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
receive(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Used to receive messages.
|
|
80
|
+
* <br/>
|
|
81
|
+
* NOTE: This method will be called automatically even if overridden.
|
|
82
|
+
* <br/>
|
|
83
|
+
* NOTE: Override this to add functionality.
|
|
84
|
+
*
|
|
85
|
+
* @method
|
|
86
|
+
* @returns {Promise<Message>}
|
|
87
|
+
* @abstract
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
onReceive(): Promise<Message>;
|
|
91
|
+
}
|