@zlink-systems/nestjs 0.29.1 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts.d.ts +3 -2
- package/dist/framework-integration-contracts.d.ts +1 -5
- package/dist/framework-loader.d.ts +12 -4
- package/dist/framework-loader.js +2 -1
- package/dist/handler-adapters.d.ts +8 -7
- package/dist/handler-adapters.js +29 -30
- package/dist/module.js +2 -2
- package/dist/options-builder.js +6 -5
- package/dist/providers.d.ts +7 -2
- package/dist/providers.js +194 -98
- package/dist/registration-composer.d.ts +3 -1
- package/dist/registration-composer.js +22 -13
- package/package.json +3 -3
package/dist/contracts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InjectionToken, ModuleMetadata } from '@nestjs/common';
|
|
2
|
-
import type { Type, ZLinkActor, ZLinkActorFactory, ZLinkCodecExtension, ZLinkDispatchOptions, ZLinkDispatchOptionsBuilder, ZLinkInboundDispatchOptions, ZLinkEntrySpot, ZLinkHandlerFilter, ZLinkLocationStore, ZLinkLocationOptions, ZLinkRelocationStore, ZLinkActorFactoryBuilder, ZLinkInstanceSpotFactoryBuilder, ZLinkUserSpotFactoryBuilder, ZLinkInstanceSpot, ZLinkMeshNodeSocketConfig, ZLinkMeshPeerConnections, ZLinkMetricsOptions, ZLinkNetworkOptions, ZLinkMessageContext, ZLinkPublishMessageContext, ZLinkRouteMessageContext, ZLinkSession, ZLinkSessionFactory, ZLinkSpot,
|
|
2
|
+
import type { Type, ZLinkActor, ZLinkActorFactory, ZLinkCodecExtension, ZLinkDispatchOptions, ZLinkDispatchOptionsBuilder, ZLinkInboundDispatchOptions, ZLinkEntrySpot, ZLinkHandlerFilter, ZLinkLocationStore, ZLinkLocationOptions, ZLinkRelocationStore, ZLinkActorFactoryBuilder, ZLinkInstanceSpotFactoryBuilder, ZLinkUserSpotFactoryBuilder, ZLinkInstanceSpot, ZLinkMeshNodeSocketConfig, ZLinkMeshPeerConnections, ZLinkMetricsOptions, ZLinkNetworkOptions, ZLinkMessageContext, ZLinkPublishMessageContext, ZLinkRouteMessageContext, ZLinkSession, ZLinkSessionFactory, ZLinkSpot, ZLinkStreamCompressionBuilder, ZLinkTimerOptions } from '@zlink-systems/framework';
|
|
3
3
|
import type { ZLinkChannelOptions, ZLinkChannelPublishHandlerRegistration, ZLinkClientCapabilityOptions, ZLinkCodecRegistryOptions, ZLinkFrameworkRegistrationOptions, ZLinkPublisherCapabilityOptions, ZLinkSpotNodeOptions, ZLinkSpotNodeRegistrationOptions, ZLinkStreamNodeOptions, ZLinkWorkerOptions } from './framework-integration-contracts';
|
|
4
4
|
export type MutableCodecRegistryOptions = {
|
|
5
5
|
serializers: NonNullable<ZLinkCodecRegistryOptions['serializers']>[number][];
|
|
@@ -23,6 +23,7 @@ export type Mutable<T> = {
|
|
|
23
23
|
-readonly [K in keyof T]: T[K];
|
|
24
24
|
};
|
|
25
25
|
export interface InternalZLinkNestFanoutChannelOptions extends ZLinkNestHandlerDiscoveryOptions {
|
|
26
|
+
readonly sendTimeoutMs?: number;
|
|
26
27
|
readonly routingId?: string;
|
|
27
28
|
readonly routingIdPrefix?: string;
|
|
28
29
|
readonly noDrop?: boolean;
|
|
@@ -157,6 +158,7 @@ export interface ZLinkNestFanoutChannelBuilder extends ZLinkNestFrameworkOptions
|
|
|
157
158
|
routingId(routingId: string | undefined): this;
|
|
158
159
|
setRoutingIdPrefix(prefix: string): this;
|
|
159
160
|
setNoDrop(noDrop?: boolean): this;
|
|
161
|
+
setSendTimeout(timeoutMs: number): this;
|
|
160
162
|
enableSubscriber(endpoint?: string | readonly string[]): this;
|
|
161
163
|
subscribe(topic: string): this;
|
|
162
164
|
addPublishHandler(packetName: string, handlerType: Type): this;
|
|
@@ -203,7 +205,6 @@ export interface ZLinkNestMeshNodeBuilder extends ZLinkNestFrameworkOptionsBuild
|
|
|
203
205
|
setActivationConcurrency(limit: number): this;
|
|
204
206
|
setInstanceSpotIdleTimeout(timeoutMs: number): this;
|
|
205
207
|
configureRouterSocket(): ZLinkMeshNodeSocketConfig;
|
|
206
|
-
configureSpotPublisher(): ZLinkSpotPublisherConfig;
|
|
207
208
|
peerConnections(): ZLinkMeshPeerConnections;
|
|
208
209
|
objects(): ZLinkNestMeshObjectRoleBuilder;
|
|
209
210
|
addSendHandler(packetName: string, handlerType: Type): this;
|
|
@@ -110,6 +110,7 @@ export interface ZLinkChannelOptions {
|
|
|
110
110
|
readonly routingId?: string;
|
|
111
111
|
readonly routingIdPrefix?: string;
|
|
112
112
|
readonly noDrop?: boolean;
|
|
113
|
+
readonly sendTimeoutMs?: number;
|
|
113
114
|
readonly requestTimeoutMs?: number;
|
|
114
115
|
readonly client?: ZLinkClientCapabilityOptions;
|
|
115
116
|
readonly publisher?: ZLinkPublisherCapabilityOptions;
|
|
@@ -203,11 +204,6 @@ export interface ZLinkSpotNodeOptions {
|
|
|
203
204
|
readonly routeSendHandlers?: readonly ZLinkRouteMeshSendHandlerRegistration[];
|
|
204
205
|
readonly routeRequestHandlers?: readonly ZLinkRouteMeshRequestHandlerRegistration[];
|
|
205
206
|
readonly requestTimeoutMs?: number;
|
|
206
|
-
readonly publisherConfig?: {
|
|
207
|
-
readonly sendHighWaterMark?: number;
|
|
208
|
-
readonly sendTimeoutMs?: number;
|
|
209
|
-
readonly lingerMs?: number;
|
|
210
|
-
};
|
|
211
207
|
readonly entrySpotTimerHandlers?: readonly ZLinkEntrySpotTimerHandlerRegistration[];
|
|
212
208
|
readonly entrySpotPacketHandlers?: readonly ZLinkEntrySpotPacketHandlerRegistration[];
|
|
213
209
|
readonly entrySpotSubscriptionHandlers?: readonly ZLinkEntrySpotSubscriptionHandlerRegistration[];
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import type { Type, ZLinkActorClient, ZLinkActorManager, ZLinkChannelClient, ZLinkCodecRegistrar, ZLinkCodecRegistryBuilder, ZLinkDispatchOptions, ZLinkDispatchOptionsBuilder, ZLinkInboundDispatchOptions, ZLinkLocationOptionValues, ZLinkLocationOptions, ZLinkEntrySpot, ZLinkFanoutClient, ZLinkHandlerFilterContext, ZLinkRouteClient, ZLinkSpot, ZLinkSpotManager, ZLinkSpotOutbound, ZLinkSpotPublisherClient, ZLinkStreamCompressionBuilder, ZLinkStreamCompressionCodec } from '@zlink-systems/framework';
|
|
1
|
+
import type { Type, ZLinkActorClient, ZLinkActorManager, ZLinkChannelClient, ZLinkCodecRegistrar, ZLinkCodecRegistryBuilder, ZLinkDispatchOptions, ZLinkDispatchOptionsBuilder, ZLinkInboundDispatchOptions, ZLinkLocationOptionValues, ZLinkLocationOptions, ZLinkMessageContext, ZLinkEntrySpot, ZLinkFanoutClient, ZLinkHandlerFilterContext, ZLinkRouteClient, ZLinkSpot, ZLinkSpotManager, ZLinkSpotOutbound, ZLinkSpotPublisherClient, ZLinkStreamCompressionBuilder, ZLinkStreamCompressionCodec } from '@zlink-systems/framework';
|
|
2
2
|
import type { ZLinkHttpExecutionScheduler } from '@zlink-systems/http-client';
|
|
3
3
|
import type { ZLinkCodecSerializerRegistration, ZLinkFrameworkRegistration, ZLinkFrameworkRegistrationOptions, ZLinkNestIntegrationRuntimeHost, ZLinkProviderResolver, ZLinkStreamCodecRegistration } from './framework-integration-contracts';
|
|
4
4
|
export type FrameworkRuntimeHost = ZLinkNestIntegrationRuntimeHost;
|
|
5
|
+
interface HandlerResolver {
|
|
6
|
+
resolve<T>(type: Type<T>): Promise<T>;
|
|
7
|
+
}
|
|
5
8
|
interface FrameworkIntegrationModule {
|
|
6
9
|
ZLinkSpotActorSend(packetName?: string): MethodDecorator;
|
|
7
10
|
ZLinkSpotActorRequest(packetName?: string): MethodDecorator;
|
|
8
11
|
disposeIntegrationHandler(instance: unknown): Promise<void>;
|
|
9
12
|
disposeIntegrationHandlers(instances: readonly unknown[]): Promise<void>;
|
|
13
|
+
registerIntegrationHandlerInstanceScopeFactory(resolver: ZLinkProviderResolver, factory: {
|
|
14
|
+
prepare?(type: Type): void;
|
|
15
|
+
create(context?: ZLinkMessageContext): HandlerResolver & {
|
|
16
|
+
dispose(): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
}): void;
|
|
10
19
|
readonly MAX_LISTENER_PORT: number;
|
|
11
20
|
readonly ZLINK_MAX_PUBLIC_WEIGHT: number;
|
|
12
21
|
readonly ZLINK_MAX_CAPACITY: number;
|
|
@@ -39,6 +48,7 @@ interface FrameworkIntegrationModule {
|
|
|
39
48
|
createIntegrationSpotOutbound(runtime: ZLinkNestIntegrationRuntimeHost): ZLinkSpotOutbound;
|
|
40
49
|
createIntegrationHttpExecutionScheduler(runtime: ZLinkNestIntegrationRuntimeHost): ZLinkHttpExecutionScheduler;
|
|
41
50
|
validateActorTransferTimeout(timeoutMs: number): number;
|
|
51
|
+
requireValidSendTimeoutMs(label: string, value: number | undefined): void;
|
|
42
52
|
validateMessageFollowDuration(timeoutMs: number): number;
|
|
43
53
|
validateSessionReplacementCallbackTimeout(timeoutMs: number): number;
|
|
44
54
|
validateRoutingIdPrefix(prefix: string): string;
|
|
@@ -59,9 +69,7 @@ interface FrameworkIntegrationModule {
|
|
|
59
69
|
registerRelocationStore(options: {
|
|
60
70
|
relocationStoreInstance?: import('@zlink-systems/framework').ZLinkRelocationStore;
|
|
61
71
|
}, store: import('@zlink-systems/framework').ZLinkRelocationStore): void;
|
|
62
|
-
registerIntegrationHandlerFilterScope(resolver: ZLinkProviderResolver, runner: (context: ZLinkHandlerFilterContext, callback: (scope:
|
|
63
|
-
resolve<T>(type: Type<T>): Promise<T>;
|
|
64
|
-
}) => Promise<unknown>) => Promise<unknown>): void;
|
|
72
|
+
registerIntegrationHandlerFilterScope(resolver: ZLinkProviderResolver, runner: (context: ZLinkHandlerFilterContext, callback: (scope: HandlerResolver) => Promise<unknown>) => Promise<unknown>): void;
|
|
65
73
|
}
|
|
66
74
|
export declare const framework: FrameworkIntegrationModule;
|
|
67
75
|
export {};
|
package/dist/framework-loader.js
CHANGED
|
@@ -20,7 +20,8 @@ function loadFramework() {
|
|
|
20
20
|
isValidPositiveCapacity: internal.isValidPositiveCapacity,
|
|
21
21
|
isValidListenerPort: internal.isValidListenerPort,
|
|
22
22
|
isValidCapacity: internal.isValidCapacity,
|
|
23
|
-
requirePublicWeight: internal.requirePublicWeight
|
|
23
|
+
requirePublicWeight: internal.requirePublicWeight,
|
|
24
|
+
requireValidSendTimeoutMs: internal.requireValidSendTimeoutMs
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
// The Nest package is a workspace adapter. It loads the framework's private
|
|
@@ -2,10 +2,11 @@ import { ModuleRef } from '@nestjs/core';
|
|
|
2
2
|
import type { ZLinkChannelOptions } from './framework-integration-contracts';
|
|
3
3
|
import type { ZLinkNestManualHandlerOptions } from './contracts';
|
|
4
4
|
import type { DiscoveredNestProvider } from './provider-discovery';
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
5
|
+
import { type NestHandlerFactories } from './providers';
|
|
6
|
+
export declare function createDiscoveredRequestHandlers(providerRefs: readonly DiscoveredNestProvider[], handlerGroups: readonly string[] | undefined, moduleRef: ModuleRef, factories?: NestHandlerFactories): NonNullable<ZLinkChannelOptions['requestHandlers']>;
|
|
7
|
+
export declare function createDiscoveredSendHandlers(providerRefs: readonly DiscoveredNestProvider[], handlerGroups: readonly string[] | undefined, moduleRef: ModuleRef, factories?: NestHandlerFactories): NonNullable<NonNullable<ZLinkChannelOptions['routeMesh']>['sendHandlers']>;
|
|
8
|
+
export declare function createDiscoveredChannelSendHandlers(providerRefs: readonly DiscoveredNestProvider[], handlerGroups: readonly string[] | undefined, moduleRef: ModuleRef, factories?: NestHandlerFactories): NonNullable<ZLinkChannelOptions['sendHandlers']>;
|
|
9
|
+
export declare function createDiscoveredPublishHandlers(providerRefs: readonly DiscoveredNestProvider[], handlerGroups: readonly string[] | undefined, moduleRef: ModuleRef, factories?: NestHandlerFactories): NonNullable<ZLinkChannelOptions['publishHandlers']>;
|
|
10
|
+
export declare function createManualRequestHandlers(handlerTypes: readonly ZLinkNestManualHandlerOptions[] | undefined, moduleRef: ModuleRef, factories?: NestHandlerFactories): NonNullable<ZLinkChannelOptions['requestHandlers']>;
|
|
11
|
+
export declare function createManualPublishHandlers(handlerTypes: readonly ZLinkNestManualHandlerOptions[] | undefined, moduleRef: ModuleRef, factories?: NestHandlerFactories): NonNullable<ZLinkChannelOptions['publishHandlers']>;
|
|
12
|
+
export declare function createManualSendHandlers(handlerTypes: readonly ZLinkNestManualHandlerOptions[] | undefined, moduleRef: ModuleRef, factories?: NestHandlerFactories): NonNullable<ZLinkChannelOptions['sendHandlers']>;
|
package/dist/handler-adapters.js
CHANGED
|
@@ -11,66 +11,65 @@ const core_1 = require("@nestjs/core");
|
|
|
11
11
|
const framework_loader_1 = require("./framework-loader");
|
|
12
12
|
const dispatch_scope_1 = require("./dispatch-scope");
|
|
13
13
|
const providers_1 = require("./providers");
|
|
14
|
-
function createDiscoveredRequestHandlers(providerRefs, handlerGroups, moduleRef) {
|
|
15
|
-
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'request', moduleRef, (ref, metadata) => ({
|
|
14
|
+
function createDiscoveredRequestHandlers(providerRefs, handlerGroups, moduleRef, factories = new Map()) {
|
|
15
|
+
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'request', moduleRef, factories, (ref, metadata, factory) => ({
|
|
16
16
|
async handle(payload, context) {
|
|
17
|
-
const result = await invokeDiscoveredHandler(moduleRef, ref, metadata, payload, context);
|
|
17
|
+
const result = await invokeDiscoveredHandler(moduleRef, ref, metadata, factory, payload, context);
|
|
18
18
|
return metadata.encodeResult === undefined
|
|
19
19
|
? result
|
|
20
20
|
: metadata.encodeResult(result, context);
|
|
21
21
|
}
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
|
-
function createDiscoveredSendHandlers(providerRefs, handlerGroups, moduleRef) {
|
|
25
|
-
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'send', moduleRef, (ref, metadata) => ({
|
|
24
|
+
function createDiscoveredSendHandlers(providerRefs, handlerGroups, moduleRef, factories = new Map()) {
|
|
25
|
+
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'send', moduleRef, factories, (ref, metadata, factory) => ({
|
|
26
26
|
async handle(payload, context) {
|
|
27
|
-
await invokeDiscoveredHandler(moduleRef, ref, metadata, payload, context);
|
|
27
|
+
await invokeDiscoveredHandler(moduleRef, ref, metadata, factory, payload, context);
|
|
28
28
|
}
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
|
-
function createDiscoveredChannelSendHandlers(providerRefs, handlerGroups, moduleRef) {
|
|
32
|
-
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'send', moduleRef, (ref, metadata) => ({
|
|
31
|
+
function createDiscoveredChannelSendHandlers(providerRefs, handlerGroups, moduleRef, factories = new Map()) {
|
|
32
|
+
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'send', moduleRef, factories, (ref, metadata, factory) => ({
|
|
33
33
|
async handle(payload, context) {
|
|
34
|
-
await invokeDiscoveredHandler(moduleRef, ref, metadata, payload, context);
|
|
34
|
+
await invokeDiscoveredHandler(moduleRef, ref, metadata, factory, payload, context);
|
|
35
35
|
}
|
|
36
36
|
}));
|
|
37
37
|
}
|
|
38
|
-
function createDiscoveredPublishHandlers(providerRefs, handlerGroups, moduleRef) {
|
|
39
|
-
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'publish', moduleRef, (ref, metadata) => ({
|
|
38
|
+
function createDiscoveredPublishHandlers(providerRefs, handlerGroups, moduleRef, factories = new Map()) {
|
|
39
|
+
return createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, 'publish', moduleRef, factories, (ref, metadata, factory) => ({
|
|
40
40
|
async handle(payload, context) {
|
|
41
|
-
await invokeDiscoveredHandler(moduleRef, ref, metadata, payload, context);
|
|
41
|
+
await invokeDiscoveredHandler(moduleRef, ref, metadata, factory, payload, context);
|
|
42
42
|
}
|
|
43
43
|
}));
|
|
44
44
|
}
|
|
45
|
-
function createManualRequestHandlers(handlerTypes, moduleRef) {
|
|
46
|
-
return createManualHandlerRegistrations(handlerTypes, moduleRef, (result) => result);
|
|
45
|
+
function createManualRequestHandlers(handlerTypes, moduleRef, factories = new Map()) {
|
|
46
|
+
return createManualHandlerRegistrations(handlerTypes, moduleRef, factories, (result) => result);
|
|
47
47
|
}
|
|
48
|
-
function createManualPublishHandlers(handlerTypes, moduleRef) {
|
|
49
|
-
return createManualHandlerRegistrations(handlerTypes, moduleRef, () => undefined);
|
|
48
|
+
function createManualPublishHandlers(handlerTypes, moduleRef, factories = new Map()) {
|
|
49
|
+
return createManualHandlerRegistrations(handlerTypes, moduleRef, factories, () => undefined);
|
|
50
50
|
}
|
|
51
|
-
function createManualSendHandlers(handlerTypes, moduleRef) {
|
|
52
|
-
return createManualHandlerRegistrations(handlerTypes, moduleRef, () => undefined);
|
|
51
|
+
function createManualSendHandlers(handlerTypes, moduleRef, factories = new Map()) {
|
|
52
|
+
return createManualHandlerRegistrations(handlerTypes, moduleRef, factories, () => undefined);
|
|
53
53
|
}
|
|
54
|
-
function createManualHandlerRegistrations(handlerTypes, moduleRef, result) {
|
|
54
|
+
function createManualHandlerRegistrations(handlerTypes, moduleRef, factories, result) {
|
|
55
55
|
return (handlerTypes ?? []).map((registration) => {
|
|
56
|
-
(0, providers_1.
|
|
56
|
+
const factory = (0, providers_1.registeredNestHandlerFactory)(factories, registration.handlerType, moduleRef);
|
|
57
57
|
return {
|
|
58
58
|
packetName: registration.packetName,
|
|
59
59
|
handler: {
|
|
60
60
|
async handle(payload, context) {
|
|
61
|
-
return result(await invokeManualHandler(moduleRef, registration.handlerType, payload, context));
|
|
61
|
+
return result(await invokeManualHandler(moduleRef, registration.handlerType, factory, payload, context));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
function createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, kind, moduleRef, createHandler) {
|
|
67
|
+
function createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, kind, moduleRef, factories, createHandler) {
|
|
68
68
|
const descriptors = createDiscoveredHandlerDescriptors(providerRefs, handlerGroups, kind);
|
|
69
69
|
return descriptors.map(({ ref, metadata }) => {
|
|
70
|
-
(0, providers_1.validateNestConstructorDependencies)(moduleRef, ref.handlerKey);
|
|
71
70
|
return {
|
|
72
71
|
packetName: metadata.packetName,
|
|
73
|
-
handler: createHandler(ref, metadata)
|
|
72
|
+
handler: createHandler(ref, metadata, (0, providers_1.registeredNestHandlerFactory)(factories, ref.handlerKey, moduleRef))
|
|
74
73
|
};
|
|
75
74
|
});
|
|
76
75
|
}
|
|
@@ -99,8 +98,8 @@ function createDiscoveredHandlerDescriptors(providerRefs, handlerGroups, kind) {
|
|
|
99
98
|
}
|
|
100
99
|
return selected;
|
|
101
100
|
}
|
|
102
|
-
async function invokeDiscoveredHandler(moduleRef, ref, metadata, payload, context) {
|
|
103
|
-
const instance = await resolveHandlerInstance(moduleRef,
|
|
101
|
+
async function invokeDiscoveredHandler(moduleRef, ref, metadata, factory, payload, context) {
|
|
102
|
+
const instance = await resolveHandlerInstance(moduleRef, factory, context);
|
|
104
103
|
try {
|
|
105
104
|
const method = instance[metadata.methodName];
|
|
106
105
|
if (typeof method !== 'function') {
|
|
@@ -112,8 +111,8 @@ async function invokeDiscoveredHandler(moduleRef, ref, metadata, payload, contex
|
|
|
112
111
|
await framework_loader_1.framework.disposeIntegrationHandler(instance);
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
|
-
async function invokeManualHandler(moduleRef, handlerType, payload, context) {
|
|
116
|
-
const instance = await resolveHandlerInstance(moduleRef,
|
|
114
|
+
async function invokeManualHandler(moduleRef, handlerType, factory, payload, context) {
|
|
115
|
+
const instance = await resolveHandlerInstance(moduleRef, factory, context);
|
|
117
116
|
try {
|
|
118
117
|
const method = instance.handle;
|
|
119
118
|
if (typeof method !== 'function') {
|
|
@@ -125,13 +124,13 @@ async function invokeManualHandler(moduleRef, handlerType, payload, context) {
|
|
|
125
124
|
await framework_loader_1.framework.disposeIntegrationHandler(instance);
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
|
-
async function resolveHandlerInstance(moduleRef,
|
|
127
|
+
async function resolveHandlerInstance(moduleRef, factory, context) {
|
|
129
128
|
const currentContextId = (0, dispatch_scope_1.currentNestDispatchContext)();
|
|
130
129
|
const contextId = currentContextId ?? core_1.ContextIdFactory.create();
|
|
131
130
|
if (currentContextId === undefined) {
|
|
132
131
|
moduleRef.registerRequestByContextId({ zlinkContext: context }, contextId);
|
|
133
132
|
}
|
|
134
|
-
return (await (
|
|
133
|
+
return (await factory(moduleRef, contextId, new Map()));
|
|
135
134
|
}
|
|
136
135
|
function decodePayload(metadata, payload, context) {
|
|
137
136
|
if (Buffer.isBuffer(payload) || payload instanceof Uint8Array) {
|
package/dist/module.js
CHANGED
|
@@ -107,7 +107,7 @@ let ZLinkModule = ZLinkModule_1 = class ZLinkModule {
|
|
|
107
107
|
const moduleRef = args[args.length - 1];
|
|
108
108
|
const factoryArgs = args.slice(0, -2);
|
|
109
109
|
const resolvedOptions = (0, registration_composer_1.assertBuiltModuleOptions)(await options.useFactory(...factoryArgs));
|
|
110
|
-
return
|
|
110
|
+
return (0, registration_composer_1.createDiscoveredRegistration)(resolvedOptions, discovery, moduleRef);
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
return {
|
|
@@ -158,7 +158,7 @@ function createDiscoveringZLinkDynamicModule(options) {
|
|
|
158
158
|
const registrationProvider = {
|
|
159
159
|
provide: tokens_1.ZLINK_FRAMEWORK_REGISTRATION,
|
|
160
160
|
inject: [core_1.DiscoveryService, core_1.ModuleRef],
|
|
161
|
-
useFactory: (discovery, moduleRef) =>
|
|
161
|
+
useFactory: (discovery, moduleRef) => (0, registration_composer_1.createDiscoveredRegistration)(options, discovery, moduleRef)
|
|
162
162
|
};
|
|
163
163
|
return {
|
|
164
164
|
module: ZLinkModule,
|
package/dist/options-builder.js
CHANGED
|
@@ -268,10 +268,15 @@ class DefaultZLinkNestFanoutChannelBuilder extends ZLinkNestOptionsBuilder {
|
|
|
268
268
|
this.channelOptions.routingIdPrefix = framework_loader_1.framework.validateRoutingIdPrefix(prefix);
|
|
269
269
|
return this;
|
|
270
270
|
}
|
|
271
|
-
setNoDrop(noDrop) {
|
|
271
|
+
setNoDrop(noDrop = true) {
|
|
272
272
|
this.channelOptions.noDrop = noDrop;
|
|
273
273
|
return this;
|
|
274
274
|
}
|
|
275
|
+
setSendTimeout(timeoutMs) {
|
|
276
|
+
framework_loader_1.framework.requireValidSendTimeoutMs(`Fanout channel '${this.name}' send timeout`, timeoutMs);
|
|
277
|
+
this.channelOptions.sendTimeoutMs = timeoutMs;
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
275
280
|
enableSubscriber(endpoint) {
|
|
276
281
|
const mode = endpoint === undefined ? 'automatic' : 'manual';
|
|
277
282
|
if (this.subscriberMode !== undefined && this.subscriberMode !== mode) {
|
|
@@ -584,10 +589,6 @@ class DefaultZLinkNestMeshNodeBuilder extends ZLinkNestOptionsBuilder {
|
|
|
584
589
|
this.spotOptions.router ??= {};
|
|
585
590
|
return this.spotOptions.router;
|
|
586
591
|
}
|
|
587
|
-
configureSpotPublisher() {
|
|
588
|
-
this.spotOptions.publisherConfig ??= {};
|
|
589
|
-
return this.spotOptions.publisherConfig;
|
|
590
|
-
}
|
|
591
592
|
peerConnections() {
|
|
592
593
|
this.spotOptions.router ??= {};
|
|
593
594
|
return new DefaultZLinkNestMeshPeerConnections(this.spotOptions.router);
|
package/dist/providers.d.ts
CHANGED
|
@@ -10,7 +10,12 @@ export declare function conditionalClientProviders(registration: ZLinkFrameworkR
|
|
|
10
10
|
export declare function conditionalClientProvidersForFactory(registration?: ZLinkFrameworkRegistration): Provider[];
|
|
11
11
|
export declare function conditionalClientTokens(): InjectionToken[];
|
|
12
12
|
export declare function createRuntimeHost(registration: ZLinkFrameworkRegistration, moduleRef: ModuleRef, discovery: DiscoveryService): RuntimeHostWithNestLifecycle;
|
|
13
|
-
export
|
|
14
|
-
export declare function
|
|
13
|
+
export type NestHandlerFactories = Map<Type, NestHandlerFactory>;
|
|
14
|
+
export declare function nestHandlerFactories(registration: ZLinkFrameworkRegistration, prepared?: NestHandlerFactories): NestHandlerFactories;
|
|
15
|
+
export declare function registeredNestHandlerFactory<T>(factories: NestHandlerFactories, type: Type<T>, moduleRef: ModuleRef): NestHandlerFactory<T>;
|
|
16
|
+
export type NestHandlerFactory<T = unknown> = ((moduleRef: ModuleRef, contextId: import('@nestjs/core').ContextId, dependencies: Map<unknown, unknown>) => T | Promise<T>) & {
|
|
17
|
+
readonly scopeFree?: () => T;
|
|
18
|
+
};
|
|
19
|
+
export declare function prepareNestHandlerFactory<T>(type: Type<T>, moduleRef?: ModuleRef): NestHandlerFactory<T>;
|
|
15
20
|
export declare function providerToken(provider: Provider): InjectionToken;
|
|
16
21
|
export {};
|