@imqueue/rpc 3.5.3 → 3.5.4
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/package.json +1 -1
- package/src/IMQRPCOptions.js +26 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/rpc",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.4",
|
|
4
4
|
"description": "Type-safe RPC framework for Node.js & TypeScript microservices over a Redis message queue — self-describing services generate their own strongly-typed clients (@imqueue framework)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redis",
|
package/src/IMQRPCOptions.js
CHANGED
|
@@ -26,6 +26,28 @@ import {} from './IMQRPCRequest.js';
|
|
|
26
26
|
import {} from './IMQRPCResponse.js';
|
|
27
27
|
import { IMQService } from './IMQService.js';
|
|
28
28
|
import { IMQClient } from './IMQClient.js';
|
|
29
|
+
/**
|
|
30
|
+
* Process-wide anchor for the mutable default-option singletons below.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* A module can be evaluated more than once inside one process: a loader that
|
|
34
|
+
* handles ESM and CJS through separate pipelines — `tsx`, for one — produces a
|
|
35
|
+
* distinct instance for `require('@imqueue/rpc')` and `import('@imqueue/rpc')`.
|
|
36
|
+
* Ordinary module-scope objects would then exist twice, and anything that
|
|
37
|
+
* *mutates* them to install behaviour would silently patch a copy the
|
|
38
|
+
* application never calls. `@imqueue/opentelemetry` does exactly that to attach
|
|
39
|
+
* its `beforeCall`/`afterCall`/`wrapCall` tracing hooks, and produced no spans
|
|
40
|
+
* at all under such a loader, with no error to explain it.
|
|
41
|
+
*
|
|
42
|
+
* Keying on `Symbol.for` makes these singletons per *process* rather than per
|
|
43
|
+
* module evaluation, so every instance hands out the same object and a mutation
|
|
44
|
+
* through any of them is visible to all.
|
|
45
|
+
*/
|
|
46
|
+
const shared = (key, create) => {
|
|
47
|
+
const anchor = globalThis;
|
|
48
|
+
const symbol = Symbol.for(`@imqueue/rpc:${key}`);
|
|
49
|
+
return (anchor[symbol] ??= create());
|
|
50
|
+
};
|
|
29
51
|
/**
|
|
30
52
|
* Default options applied to every IMQ service: the core queue defaults, plus
|
|
31
53
|
* cleanup enabled with a `'*:client'` filter, single-process mode, and one worker
|
|
@@ -41,13 +63,13 @@ import { IMQClient } from './IMQClient.js';
|
|
|
41
63
|
* {@link DEFAULT_IMQ_METRICS_SERVER_OPTIONS} and are merged in separately by the
|
|
42
64
|
* service constructor.
|
|
43
65
|
*/
|
|
44
|
-
export const DEFAULT_IMQ_SERVICE_OPTIONS = {
|
|
66
|
+
export const DEFAULT_IMQ_SERVICE_OPTIONS = shared('DEFAULT_IMQ_SERVICE_OPTIONS', () => ({
|
|
45
67
|
...DEFAULT_IMQ_OPTIONS,
|
|
46
68
|
cleanup: true,
|
|
47
69
|
cleanupFilter: '*:client',
|
|
48
70
|
multiProcess: false,
|
|
49
71
|
childrenPerCore: 1,
|
|
50
|
-
};
|
|
72
|
+
}));
|
|
51
73
|
/**
|
|
52
74
|
* Default metrics server options
|
|
53
75
|
*/
|
|
@@ -69,7 +91,7 @@ export const DEFAULT_IMQ_METRICS_SERVER_OPTIONS = {
|
|
|
69
91
|
* As with the service defaults, `cleanup: true` and `cleanupFilter: '*:client'`
|
|
70
92
|
* override the core defaults, and `timeout` applies to the generator only.
|
|
71
93
|
*/
|
|
72
|
-
export const DEFAULT_IMQ_CLIENT_OPTIONS = {
|
|
94
|
+
export const DEFAULT_IMQ_CLIENT_OPTIONS = shared('DEFAULT_IMQ_CLIENT_OPTIONS', () => ({
|
|
73
95
|
...DEFAULT_IMQ_OPTIONS,
|
|
74
96
|
cleanup: true,
|
|
75
97
|
cleanupFilter: '*:client',
|
|
@@ -77,5 +99,5 @@ export const DEFAULT_IMQ_CLIENT_OPTIONS = {
|
|
|
77
99
|
compile: true,
|
|
78
100
|
timeout: 30000,
|
|
79
101
|
write: true,
|
|
80
|
-
};
|
|
102
|
+
}));
|
|
81
103
|
//# sourceMappingURL=IMQRPCOptions.js.map
|