@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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
This document contains the list of changes made to the framework. The format is based on the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
|
|
4
4
|
|
|
5
|
+
## Version 1.9.0
|
|
6
|
+
|
|
7
|
+
TypeScript declarations now ship with the package. The previous attempt was withdrawn in 1.8.1 because the generated
|
|
8
|
+
declarations did not type-check for a consumer using TypeScript's default settings; this one is verified under those
|
|
9
|
+
settings before it can be committed, by a check that runs in CI.
|
|
10
|
+
|
|
11
|
+
What made the first attempt look finished was the verification, not the output: it ran with `skipLibCheck: true`, which
|
|
12
|
+
suppresses errors *inside* `.d.ts` files — precisely the class of error declaration emit produces. The real number was
|
|
13
|
+
larger than the 45 that measurement eventually admitted to. A parse error anywhere in a program suppresses the whole
|
|
14
|
+
semantic pass, so the malformed declarations in one package were hiding every unresolved name in the other two: the
|
|
15
|
+
first honest measurement across all three was **251** errors, not 7.
|
|
16
|
+
|
|
17
|
+
* feat(types): generate and publish `.d.ts` declarations for every module, wired into `exports` and `imports` through
|
|
18
|
+
`types` conditions so both a consumer's import and the framework's own `#` specifiers resolve to them
|
|
19
|
+
* feat(exceptions): export the `TiException` class. It is named in the signature of everything that raises or inspects
|
|
20
|
+
an exception and was never exported, so no consumer could name the type it was being handed
|
|
21
|
+
* feat(tools): `tools.enum()` now returns a type carrying the seed's own members. Every enum was previously documented
|
|
22
|
+
as returning `Object`, on which TypeScript permits no property access at all — `exceptions.exceptionCode.E_SEC_UNAUTHORIZED_ACCESS`
|
|
23
|
+
did not type-check, and neither did any other enum member in the framework. A misspelled member is now a compile
|
|
24
|
+
error rather than `undefined` at runtime
|
|
25
|
+
* feat(definitions): expose the shared type definitions as `@ti-engine/core/definitions`. The types in it appear
|
|
26
|
+
throughout the public API and the module declaring them was not exported
|
|
27
|
+
* fix(types)!: rewrite every closure-style `{function(...)}` JSDoc annotation in arrow syntax. The declaration emitter
|
|
28
|
+
reduces that form to a nameless `: Function` and leaks the remainder of the annotation into the doc comment, which is
|
|
29
|
+
a syntax error in the emitted declaration — so the annotations documenting a callback were the ones destroying it
|
|
30
|
+
* fix(types): stop marking `#`-named members `@private`. The emitter combines the two into `private #name`, which
|
|
31
|
+
TypeScript rejects outright; the `#private` brand each class already emits carries the same meaning
|
|
32
|
+
* fix(exchange): `onConnectionDisrupted`, `onConnectionRecovered` and `onConnectionLost` are no longer marked
|
|
33
|
+
`@private` in `MessageHandler`. They override public methods of `ConnectionObserver` and their own documentation
|
|
34
|
+
tells you to override them, so the tag contradicted both the base class and the instruction directly above it
|
|
35
|
+
* fix(types): `Object.<K,V>` in a standalone `@typedef` emits as the non-generic `Object<K,V>`; the map typedefs are
|
|
36
|
+
now `Record<K,V>`, and `TiLabelsTree` an index signature, since a self-referential `Record` alias is circular
|
|
37
|
+
* refactor(exchange): the lazy `require` inside `addMessageObserver` binds under a distinct name. As `MessageObserver`
|
|
38
|
+
it shadowed the file-level type import, leaving the documented parameter type unresolvable
|
|
39
|
+
* build(deps): add `@types/node`. The published declarations name `NodeJS.Process`, so a consumer cannot read them
|
|
40
|
+
without it
|
|
41
|
+
|
|
5
42
|
## Version 1.8.1
|
|
6
43
|
|
|
7
44
|
Presentation and documentation only — no functional change. The npm page is the first thing a prospective user sees, and it was working against the package.
|
package/components/auditing.js
CHANGED
|
@@ -13,6 +13,8 @@ const logger = require( "#logger" );
|
|
|
13
13
|
const config = require( "#config" );
|
|
14
14
|
const ServiceInstance = require( "#service-instance" );
|
|
15
15
|
|
|
16
|
+
/** @import { TiLogSeverity } from "#logger" */
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* Used to create and/or return an Auditing System singleton instance.
|
|
18
20
|
*
|
|
@@ -77,7 +79,6 @@ class Auditing {
|
|
|
77
79
|
* @param {string} message
|
|
78
80
|
* @param {Object} data
|
|
79
81
|
* @returns {TiLogEntry}
|
|
80
|
-
* @private
|
|
81
82
|
*/
|
|
82
83
|
static #createLogEntry( severity, thread, message, data ) {
|
|
83
84
|
let currentDate = new Date();
|
|
@@ -104,7 +105,6 @@ class Auditing {
|
|
|
104
105
|
*
|
|
105
106
|
* @method
|
|
106
107
|
* @param {TiLogEntry} logEntry
|
|
107
|
-
* @private
|
|
108
108
|
*/
|
|
109
109
|
static #logToConsole( logEntry ) {
|
|
110
110
|
if ( config.getSetting( config.setting.AUDITING_LOG_USES_JSON ) === true ) {
|
|
@@ -127,7 +127,6 @@ class Auditing {
|
|
|
127
127
|
* @method
|
|
128
128
|
* @param {TiLogEntry} logEntry
|
|
129
129
|
* @returns {string}
|
|
130
|
-
* @private
|
|
131
130
|
*/
|
|
132
131
|
static #formatConsoleMessage( logEntry ) {
|
|
133
132
|
let logDate = new Date( logEntry.timestamp );
|
|
@@ -144,7 +143,6 @@ class Auditing {
|
|
|
144
143
|
* @param {number} [maxDepth=5]
|
|
145
144
|
* @param {Set} [visited=new Set()]
|
|
146
145
|
* @returns {string}
|
|
147
|
-
* @private
|
|
148
146
|
*/
|
|
149
147
|
static #formatConsoleData( data, prefix = "", currentDepth = 0, maxDepth = 5, visited = new Set() ) {
|
|
150
148
|
if ( data === null || data === undefined || !_.isObjectLike( data ) ) {
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/** @import { TiException } from "#exceptions" */
|
|
10
|
+
/** @import { TiLocalizationLanguage } from "#localization" */
|
|
11
|
+
/** @import { TiLogSeverity } from "#logger" */
|
|
12
|
+
/** @import { ServiceHandlerMethod } from "#service-executor" */
|
|
13
|
+
|
|
9
14
|
// Configuration Definitions:
|
|
10
15
|
|
|
11
16
|
/**
|
|
@@ -123,6 +128,16 @@
|
|
|
123
128
|
* @property {(enumValue: number|string) => boolean} contains
|
|
124
129
|
*/
|
|
125
130
|
|
|
131
|
+
/**
|
|
132
|
+
* The shape `tools.enum()` produces for a given seed. Every key of the seed is carried over as an enum
|
|
133
|
+
* member, so a typo is a compile error rather than `undefined` at runtime, and the lookup helpers of
|
|
134
|
+
* {@link TiEnum} come along with it. Members are typed as the value they hold, not as the
|
|
135
|
+
* `[ value, name, description ]` tuple the seed declares them with.
|
|
136
|
+
*
|
|
137
|
+
* @template {Record<string,*>} T
|
|
138
|
+
* @typedef {{ [K in keyof T]: number|string } & TiEnum} TiEnumOf
|
|
139
|
+
*/
|
|
140
|
+
|
|
126
141
|
/**
|
|
127
142
|
* @typedef {Object} TiLogEntry
|
|
128
143
|
* @property {string} _id Unique identifier that can be used to identify the document in a NoSQL database.
|
|
@@ -151,13 +166,13 @@
|
|
|
151
166
|
/**
|
|
152
167
|
* The key of this object is the language code, and the value is the textual representation of the label.
|
|
153
168
|
*
|
|
154
|
-
* @typedef {
|
|
169
|
+
* @typedef {Record<TiLocalizationLanguage, string>} TiLocalizedLabel
|
|
155
170
|
*/
|
|
156
171
|
|
|
157
172
|
/**
|
|
158
173
|
* A nested labels tree where intermediate nodes are objects and leaf nodes are language-to-text maps.
|
|
159
174
|
*
|
|
160
|
-
* @typedef {
|
|
175
|
+
* @typedef {{ [label: string]: TiLocalizedLabel | TiLabelsTree }} TiLabelsTree
|
|
161
176
|
*/
|
|
162
177
|
|
|
163
178
|
// Service Bus Definitions:
|
|
@@ -209,11 +224,11 @@
|
|
|
209
224
|
*/
|
|
210
225
|
|
|
211
226
|
/**
|
|
212
|
-
* @typedef {
|
|
227
|
+
* @typedef {Record<string, ServiceInterfaceVersion>} ServiceInterface
|
|
213
228
|
*/
|
|
214
229
|
|
|
215
230
|
/**
|
|
216
|
-
* @typedef {
|
|
231
|
+
* @typedef {Record<number, ServiceHandlerMethod>} ServiceInterfaceVersion
|
|
217
232
|
*/
|
|
218
233
|
|
|
219
234
|
/**
|
|
@@ -10,6 +10,8 @@ const MessageExchange = require( "#message-exchange" );
|
|
|
10
10
|
const config = require( "#config" );
|
|
11
11
|
const exceptions = require( "#exceptions" );
|
|
12
12
|
|
|
13
|
+
/** @import { Message } from "#definitions" */
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* The default {@link MessageExchange} behavior for the Ti Engine using Redis for message exchange.
|
|
15
17
|
*
|
|
@@ -11,6 +11,8 @@ const memoryCache = require( "#message-memory-cache" );
|
|
|
11
11
|
const config = require( "#config" );
|
|
12
12
|
const exceptions = require( "#exceptions" );
|
|
13
13
|
|
|
14
|
+
/** @import { Message } from "#definitions" */
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* The default {@link MessageReceiver} behavior for the Ti Engine using Redis for message exchange.
|
|
16
18
|
*
|
|
@@ -12,6 +12,8 @@ const config = require( "#config" );
|
|
|
12
12
|
const exceptions = require( "#exceptions" );
|
|
13
13
|
const memoryCache = require( "#message-memory-cache" );
|
|
14
14
|
|
|
15
|
+
/** @import { Message } from "#definitions" */
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* The default {@link MessageSender} behavior for the Ti Engine using Redis for message exchange.
|
|
17
19
|
*
|
|
@@ -11,6 +11,10 @@ const exceptions = require( "#exceptions" );
|
|
|
11
11
|
const logger = require( "#logger" );
|
|
12
12
|
const messageTracer = require( "#message-tracer" );
|
|
13
13
|
|
|
14
|
+
/** @import { Message } from "#definitions" */
|
|
15
|
+
/** @import MessageExchange from "#message-exchange" */
|
|
16
|
+
/** @import MessageObserver from "#message-observer" */
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* Used to create and/or return a Message Dispatcher singleton instance.
|
|
16
20
|
* This class handles the internal message dispatching between the microservices.
|
|
@@ -11,6 +11,10 @@ const _ = require( "lodash" );
|
|
|
11
11
|
const exceptions = require( "#exceptions" );
|
|
12
12
|
const messageTracer = require( "#message-tracer" );
|
|
13
13
|
|
|
14
|
+
/** @import { Message } from "#definitions" */
|
|
15
|
+
/** @import MessageReceiver from "#message-receiver" */
|
|
16
|
+
/** @import MessageSender from "#message-sender" */
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* An abstract class that defines a message exchange behavior.
|
|
16
20
|
* <br/>
|
|
@@ -14,6 +14,9 @@ const logger = require( "#logger" );
|
|
|
14
14
|
const tools = require( "#tools" );
|
|
15
15
|
const config = require( "#config" );
|
|
16
16
|
|
|
17
|
+
/** @import { Message } from "#definitions" */
|
|
18
|
+
/** @import MessageObserver from "#message-observer" */
|
|
19
|
+
|
|
17
20
|
const OLD_DEFAULT_HASH_KEY = "23e7bdc7-a793-41f9-856e-6760332f0c73";
|
|
18
21
|
let keyWarningEmitted = false;
|
|
19
22
|
|
|
@@ -145,8 +148,10 @@ class MessageHandler extends ConnectionObserver {
|
|
|
145
148
|
* @public
|
|
146
149
|
*/
|
|
147
150
|
addMessageObserver( messageObserver ) {
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
// Bound under a distinct name: `MessageObserver` at method scope would shadow the file-level type
|
|
152
|
+
// import, leaving the documented parameter type unresolvable in the generated declarations.
|
|
153
|
+
const MessageObserverClass = require( "#message-observer" );
|
|
154
|
+
if ( messageObserver instanceof MessageObserverClass ) {
|
|
150
155
|
this.#messageObservers.push( messageObserver );
|
|
151
156
|
this.#messageObservers = _.orderBy( this.#messageObservers, [ "priority" ], [ "desc" ] );
|
|
152
157
|
} else {
|
|
@@ -180,7 +185,6 @@ class MessageHandler extends ConnectionObserver {
|
|
|
180
185
|
* @method
|
|
181
186
|
* @param {string} identifier The identifier of the observed connection.
|
|
182
187
|
* @override
|
|
183
|
-
* @private
|
|
184
188
|
*/
|
|
185
189
|
onConnectionRecovered( identifier ) {
|
|
186
190
|
if ( this.#isAvailable === false && identifier === this.#connectionIdentifier ) {
|
|
@@ -200,7 +204,6 @@ class MessageHandler extends ConnectionObserver {
|
|
|
200
204
|
* @method
|
|
201
205
|
* @param {string} identifier The identifier of the observed connection.
|
|
202
206
|
* @override
|
|
203
|
-
* @private
|
|
204
207
|
*/
|
|
205
208
|
onConnectionDisrupted( identifier ) {
|
|
206
209
|
if ( this.#isAvailable === true && identifier === this.#connectionIdentifier ) {
|
|
@@ -220,7 +223,6 @@ class MessageHandler extends ConnectionObserver {
|
|
|
220
223
|
* @method
|
|
221
224
|
* @param {string} identifier The identifier of the observed connection.
|
|
222
225
|
* @override
|
|
223
|
-
* @private
|
|
224
226
|
*/
|
|
225
227
|
onConnectionLost( identifier ) {
|
|
226
228
|
if ( identifier === this.#connectionIdentifier ) {
|
|
@@ -11,6 +11,9 @@ const tools = require( "#tools" );
|
|
|
11
11
|
const exceptions = require( "#exceptions" );
|
|
12
12
|
const redis = require( "#redis-integration" );
|
|
13
13
|
|
|
14
|
+
/** @import ConnectionObserver from "#connection-observer" */
|
|
15
|
+
/** @import { Message } from "#definitions" */
|
|
16
|
+
|
|
14
17
|
/**
|
|
15
18
|
* Used to create a Redis Cache client wrapped in a specialized message memory cache interface.
|
|
16
19
|
*
|
|
@@ -10,6 +10,8 @@ const ConnectionObserver = require( "#connection-observer" );
|
|
|
10
10
|
const _ = require( "lodash" );
|
|
11
11
|
const exceptions = require( "#exceptions" );
|
|
12
12
|
|
|
13
|
+
/** @import { Message } from "#definitions" */
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* An abstract class that allows the child class to observe and take action on message events.
|
|
15
17
|
* <br/>
|
|
@@ -12,6 +12,8 @@ const exceptions = require( "#exceptions" );
|
|
|
12
12
|
const config = require( "#config" );
|
|
13
13
|
const tools = require( "#tools" );
|
|
14
14
|
|
|
15
|
+
/** @import { Message } from "#definitions" */
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* An abstract class that defines a basic message receiver behavior.
|
|
17
19
|
*
|
|
@@ -154,7 +156,6 @@ class MessageReceiver extends MessageHandler {
|
|
|
154
156
|
* @method
|
|
155
157
|
* @param {Message} message
|
|
156
158
|
* @returns {Promise<Message>}
|
|
157
|
-
* @private
|
|
158
159
|
*/
|
|
159
160
|
#postReceive( message ) {
|
|
160
161
|
return new Promise( ( resolve, reject ) => {
|
|
@@ -10,6 +10,8 @@ const MessageHandler = require( "#message-handler" );
|
|
|
10
10
|
const exceptions = require( "#exceptions" );
|
|
11
11
|
const config = require( "#config" );
|
|
12
12
|
|
|
13
|
+
/** @import { Message } from "#definitions" */
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* An abstract class that defines a basic message sender behavior.
|
|
15
17
|
*
|
|
@@ -113,7 +115,6 @@ class MessageSender extends MessageHandler {
|
|
|
113
115
|
* @method
|
|
114
116
|
* @param {Message} message
|
|
115
117
|
* @returns {Promise<Message>}
|
|
116
|
-
* @private
|
|
117
118
|
*/
|
|
118
119
|
#preSend( message ) {
|
|
119
120
|
if ( this.isAvailable === true ) {
|
|
@@ -132,7 +133,6 @@ class MessageSender extends MessageHandler {
|
|
|
132
133
|
*
|
|
133
134
|
* @method
|
|
134
135
|
* @returns {Promise}
|
|
135
|
-
* @private
|
|
136
136
|
*/
|
|
137
137
|
#postSend() {
|
|
138
138
|
return Promise.resolve();
|
|
@@ -13,6 +13,8 @@ const logger = require( "#logger" );
|
|
|
13
13
|
const exceptions = require( "#exceptions" );
|
|
14
14
|
const cache = require( "#cache" );
|
|
15
15
|
|
|
16
|
+
/** @import { Message } from "#definitions" */
|
|
17
|
+
|
|
16
18
|
const traceRoot = {
|
|
17
19
|
trace: []
|
|
18
20
|
};
|
|
@@ -174,7 +176,6 @@ class MessageTracer {
|
|
|
174
176
|
* @method
|
|
175
177
|
* @param {TiTraceEntry} traceEntry The trace entry to log.
|
|
176
178
|
* @param {TiLogSeverity} severity The log entry severity.
|
|
177
|
-
* @private
|
|
178
179
|
*/
|
|
179
180
|
static #createLogEntry( traceEntry, severity ) {
|
|
180
181
|
logger.log( MessageTracer.#formatLogEntry( traceEntry ), severity, traceEntry );
|
|
@@ -186,7 +187,6 @@ class MessageTracer {
|
|
|
186
187
|
* @method
|
|
187
188
|
* @param {TiTraceEntry} traceEntry
|
|
188
189
|
* @return {string} Prepared trace info.
|
|
189
|
-
* @private
|
|
190
190
|
*/
|
|
191
191
|
static #formatLogEntry( traceEntry ) {
|
|
192
192
|
return `Message(${ traceEntry.chainID || traceEntry.messageID }) Trace: '${ traceEntry.messageType } ${ traceEntry.dispatchEvent } ${ traceEntry.messageState }' From: '${ traceEntry.fromAddress }' To: '${ traceEntry.toAddress }'`;
|
|
@@ -198,7 +198,6 @@ class MessageTracer {
|
|
|
198
198
|
* @method
|
|
199
199
|
* @param {Message} message
|
|
200
200
|
* @returns {Message}
|
|
201
|
-
* @private
|
|
202
201
|
*/
|
|
203
202
|
static #obscureSensitiveData( message ) {
|
|
204
203
|
/** @type Message */
|
|
@@ -14,6 +14,8 @@ const config = require( "#config" );
|
|
|
14
14
|
const cache = require( "#cache" );
|
|
15
15
|
const messageDispatcher = require( "#message-dispatcher" );
|
|
16
16
|
|
|
17
|
+
/** @import { ServiceAddress, ServiceCall, ServiceCallResult, ServiceExecContext } from "#definitions" */
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* Used to assemble and prepare a new {@link ServiceCall} object.
|
|
19
21
|
*
|
|
@@ -182,7 +184,6 @@ class ServiceCallProcessor {
|
|
|
182
184
|
*
|
|
183
185
|
* @method
|
|
184
186
|
* @returns {Promise<ServiceCallResult>}
|
|
185
|
-
* @private
|
|
186
187
|
*/
|
|
187
188
|
#execute() {
|
|
188
189
|
return new Promise( ( resolve, reject ) => {
|
|
@@ -207,7 +208,6 @@ class ServiceCallProcessor {
|
|
|
207
208
|
*
|
|
208
209
|
* @method
|
|
209
210
|
* @returns {Promise<ServiceCallResult>}
|
|
210
|
-
* @private
|
|
211
211
|
*/
|
|
212
212
|
#timeout() {
|
|
213
213
|
return new Promise( ( resolve, reject ) => {
|
|
@@ -335,7 +335,6 @@ class ServiceCaller extends MessageObserver {
|
|
|
335
335
|
* @method
|
|
336
336
|
* @param {string} messageID
|
|
337
337
|
* @param {ServiceCallProcessor} processor
|
|
338
|
-
* @private
|
|
339
338
|
*/
|
|
340
339
|
#addProcessor( messageID, processor ) {
|
|
341
340
|
this.#serviceCallProcessors[ messageID ] = processor;
|
|
@@ -347,7 +346,6 @@ class ServiceCaller extends MessageObserver {
|
|
|
347
346
|
* @method
|
|
348
347
|
* @param {string} messageID
|
|
349
348
|
* @returns {ServiceCallProcessor}
|
|
350
|
-
* @private
|
|
351
349
|
*/
|
|
352
350
|
#getProcessor( messageID ) {
|
|
353
351
|
return this.#serviceCallProcessors[ messageID ];
|
|
@@ -358,7 +356,6 @@ class ServiceCaller extends MessageObserver {
|
|
|
358
356
|
*
|
|
359
357
|
* @method
|
|
360
358
|
* @param {string} messageID
|
|
361
|
-
* @private
|
|
362
359
|
*/
|
|
363
360
|
#removeProcessor( messageID ) {
|
|
364
361
|
if ( this.#serviceCallProcessors[ messageID ] ) {
|
|
@@ -10,6 +10,8 @@ const ServiceInstance = require( "#service-instance" );
|
|
|
10
10
|
const exceptions = require( "#exceptions" );
|
|
11
11
|
const messageDispatcher = require( "#message-dispatcher" );
|
|
12
12
|
|
|
13
|
+
/** @import { ServiceAddress, ServiceCallResult, ServiceConfiguration, ServiceExecContext } from "#definitions" */
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* Abstract class used to define a Service Consumer behavior.
|
|
15
17
|
* <br/>
|
|
@@ -15,11 +15,13 @@ const config = require( "#config" );
|
|
|
15
15
|
const cache = require( "#cache" );
|
|
16
16
|
const messageDispatcher = require( "#message-dispatcher" );
|
|
17
17
|
|
|
18
|
+
/** @import { ServiceAddress, ServiceCall, ServiceDefinition, ServiceExecContext, ServiceInterface } from "#definitions" */
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* @callback VerifyAccessMethod
|
|
20
22
|
* @param {string} authToken
|
|
21
23
|
* @param {ServiceAddress} serviceAddress
|
|
22
|
-
* @returns {Promise}
|
|
24
|
+
* @returns {Promise<*>}
|
|
23
25
|
*/
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -181,7 +183,6 @@ class ServiceExecutor extends MessageObserver {
|
|
|
181
183
|
* @method
|
|
182
184
|
* @param {ServiceCall} serviceCall
|
|
183
185
|
* @returns {ServiceExecContext}
|
|
184
|
-
* @private
|
|
185
186
|
*/
|
|
186
187
|
static #assembleServiceExecContext( serviceCall ) {
|
|
187
188
|
return {
|
|
@@ -206,7 +207,6 @@ class ServiceExecutor extends MessageObserver {
|
|
|
206
207
|
* @method
|
|
207
208
|
* @param {string} serviceAlias
|
|
208
209
|
* @returns {Promise}
|
|
209
|
-
* @private
|
|
210
210
|
*/
|
|
211
211
|
#registerServiceToCatalog( serviceAlias ) {
|
|
212
212
|
return new Promise( ( resolve, reject ) => {
|
|
@@ -226,7 +226,6 @@ class ServiceExecutor extends MessageObserver {
|
|
|
226
226
|
* @method
|
|
227
227
|
* @param {ServiceCall} serviceCall
|
|
228
228
|
* @returns {Promise<ServiceCall>}
|
|
229
|
-
* @private
|
|
230
229
|
*/
|
|
231
230
|
#processServiceCall( serviceCall ) {
|
|
232
231
|
return new Promise( ( resolve ) => {
|
|
@@ -252,7 +251,6 @@ class ServiceExecutor extends MessageObserver {
|
|
|
252
251
|
* @method
|
|
253
252
|
* @param {ServiceAddress} serviceAddress
|
|
254
253
|
* @returns {Promise<ServiceHandlerMethod>}
|
|
255
|
-
* @private
|
|
256
254
|
*/
|
|
257
255
|
#identifyService( serviceAddress ) {
|
|
258
256
|
return new Promise( ( resolve, reject ) => {
|
|
@@ -15,6 +15,8 @@ const exceptions = require( "#exceptions" );
|
|
|
15
15
|
const cache = require( "#cache" );
|
|
16
16
|
const messageDispatcher = require( "#message-dispatcher" );
|
|
17
17
|
|
|
18
|
+
/** @import { ServiceConfiguration } from "#definitions" */
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* Abstract class used to define a Service Instance behavior.
|
|
20
22
|
* <br/>
|
|
@@ -244,7 +246,6 @@ class ServiceInstance {
|
|
|
244
246
|
*
|
|
245
247
|
* @method
|
|
246
248
|
* @returns {Promise}
|
|
247
|
-
* @private
|
|
248
249
|
*/
|
|
249
250
|
#preStart() {
|
|
250
251
|
return new Promise( ( resolve ) => {
|
|
@@ -260,7 +261,6 @@ class ServiceInstance {
|
|
|
260
261
|
*
|
|
261
262
|
* @method
|
|
262
263
|
* @returns {Promise}
|
|
263
|
-
* @private
|
|
264
264
|
*/
|
|
265
265
|
#postStart() {
|
|
266
266
|
return new Promise( ( resolve ) => {
|
|
@@ -285,7 +285,6 @@ class ServiceInstance {
|
|
|
285
285
|
*
|
|
286
286
|
* @method
|
|
287
287
|
* @returns {Promise}
|
|
288
|
-
* @private
|
|
289
288
|
*/
|
|
290
289
|
#preStop() {
|
|
291
290
|
return new Promise( ( resolve ) => {
|
|
@@ -303,7 +302,6 @@ class ServiceInstance {
|
|
|
303
302
|
*
|
|
304
303
|
* @method
|
|
305
304
|
* @returns {Promise}
|
|
306
|
-
* @private
|
|
307
305
|
*/
|
|
308
306
|
#postStop() {
|
|
309
307
|
return new Promise( ( resolve ) => {
|
|
@@ -13,6 +13,9 @@ const exceptions = require( "#exceptions" );
|
|
|
13
13
|
const logger = require( "#logger" );
|
|
14
14
|
const messageDispatcher = require( "#message-dispatcher" );
|
|
15
15
|
|
|
16
|
+
/** @import { ServiceAddress, ServiceConfiguration, ServiceDefinition } from "#definitions" */
|
|
17
|
+
/** @import { ServiceHandlerMethod } from "#service-executor" */
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Abstract class used to define a Service Provider behavior.
|
|
18
21
|
* <br/>
|
|
@@ -282,7 +282,7 @@ class RedisClient {
|
|
|
282
282
|
*
|
|
283
283
|
* @method
|
|
284
284
|
* @param {string} channel Unique identifier of the channel to subscribe to.
|
|
285
|
-
* @param {
|
|
285
|
+
* @param {(message: Object) => void} messageHandler Will execute this handler every time a new message is received.
|
|
286
286
|
* @returns {Promise}
|
|
287
287
|
* @public
|
|
288
288
|
*/
|
|
@@ -428,7 +428,6 @@ class RedisClient {
|
|
|
428
428
|
* @param {number} [retryMaxIntervalMs=1000] Optional max backoff interval.
|
|
429
429
|
* @param {number|undefined} [retryMaxAttempts=undefined] Optional max (re)connection attempts before abort.
|
|
430
430
|
* @returns {Promise}
|
|
431
|
-
* @private
|
|
432
431
|
*/
|
|
433
432
|
#setupClient( host, port, authKey, user, defaultDB, retryMaxIntervalMs, retryMaxAttempts ) {
|
|
434
433
|
return new Promise( ( resolve, reject ) => {
|
|
@@ -510,7 +509,6 @@ class RedisClient {
|
|
|
510
509
|
* Used to notify all connection observers about the current connection state.
|
|
511
510
|
*
|
|
512
511
|
* @method
|
|
513
|
-
* @private
|
|
514
512
|
*/
|
|
515
513
|
#notifyConnectionObservers() {
|
|
516
514
|
// Notify all connection observers about the event:
|
|
@@ -530,7 +528,6 @@ class RedisClient {
|
|
|
530
528
|
*
|
|
531
529
|
* @method
|
|
532
530
|
* @returns {Promise}
|
|
533
|
-
* @private
|
|
534
531
|
*/
|
|
535
532
|
#fetchServerInfo() {
|
|
536
533
|
return new Promise( ( resolve, reject ) => {
|
|
@@ -570,7 +567,6 @@ class RedisClient {
|
|
|
570
567
|
*
|
|
571
568
|
* @method
|
|
572
569
|
* @returns {Promise<number>}
|
|
573
|
-
* @private
|
|
574
570
|
*/
|
|
575
571
|
#getClientID() {
|
|
576
572
|
let commandArguments = [ "client", "id" ];
|