nmtjs 0.16.1 → 0.17.0-beta.2
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.md +1 -1
- package/README.md +41 -1
- package/dist/index.d.ts +22 -161
- package/dist/index.js +24 -53
- package/dist/index.js.map +1 -1
- package/package.json +11 -63
- package/src/index.ts +71 -91
- package/bin/cli.js +0 -2
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -137
- package/dist/cli.js.map +0 -1
- package/dist/codegen.d.ts +0 -5
- package/dist/codegen.js +0 -18
- package/dist/codegen.js.map +0 -1
- package/dist/config.d.ts +0 -47
- package/dist/config.js +0 -16
- package/dist/config.js.map +0 -1
- package/dist/entrypoints/cli.d.ts +0 -1
- package/dist/entrypoints/cli.js +0 -12
- package/dist/entrypoints/cli.js.map +0 -1
- package/dist/entrypoints/main.d.ts +0 -5
- package/dist/entrypoints/main.js +0 -248
- package/dist/entrypoints/main.js.map +0 -1
- package/dist/entrypoints/thread.d.ts +0 -16
- package/dist/entrypoints/thread.js +0 -182
- package/dist/entrypoints/thread.js.map +0 -1
- package/dist/entrypoints/worker.d.ts +0 -9
- package/dist/entrypoints/worker.js +0 -143
- package/dist/entrypoints/worker.js.map +0 -1
- package/dist/resolver.d.ts +0 -2
- package/dist/resolver.js +0 -7
- package/dist/resolver.js.map +0 -1
- package/dist/runtime/application/index.d.ts +0 -1
- package/dist/runtime/application/index.js +0 -2
- package/dist/runtime/application/index.js.map +0 -1
- package/dist/runtime/constants.d.ts +0 -8
- package/dist/runtime/constants.js +0 -5
- package/dist/runtime/constants.js.map +0 -1
- package/dist/runtime/enums.d.ts +0 -10
- package/dist/runtime/enums.js +0 -13
- package/dist/runtime/enums.js.map +0 -1
- package/dist/runtime/hooks.d.ts +0 -1
- package/dist/runtime/hooks.js +0 -2
- package/dist/runtime/hooks.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -28
- package/dist/runtime/index.js +0 -29
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/injectables.d.ts +0 -69
- package/dist/runtime/injectables.js +0 -40
- package/dist/runtime/injectables.js.map +0 -1
- package/dist/runtime/jobs/job.d.ts +0 -146
- package/dist/runtime/jobs/job.js +0 -89
- package/dist/runtime/jobs/job.js.map +0 -1
- package/dist/runtime/jobs/manager.d.ts +0 -131
- package/dist/runtime/jobs/manager.js +0 -309
- package/dist/runtime/jobs/manager.js.map +0 -1
- package/dist/runtime/jobs/router.d.ts +0 -296
- package/dist/runtime/jobs/router.js +0 -458
- package/dist/runtime/jobs/router.js.map +0 -1
- package/dist/runtime/jobs/runner.d.ts +0 -103
- package/dist/runtime/jobs/runner.js +0 -425
- package/dist/runtime/jobs/runner.js.map +0 -1
- package/dist/runtime/jobs/step.d.ts +0 -26
- package/dist/runtime/jobs/step.js +0 -18
- package/dist/runtime/jobs/step.js.map +0 -1
- package/dist/runtime/jobs/types.d.ts +0 -86
- package/dist/runtime/jobs/types.js +0 -5
- package/dist/runtime/jobs/types.js.map +0 -1
- package/dist/runtime/metrics/metric.d.ts +0 -8
- package/dist/runtime/metrics/metric.js +0 -11
- package/dist/runtime/metrics/metric.js.map +0 -1
- package/dist/runtime/metrics/registry.d.ts +0 -3
- package/dist/runtime/metrics/registry.js +0 -5
- package/dist/runtime/metrics/registry.js.map +0 -1
- package/dist/runtime/metrics/server.d.ts +0 -7
- package/dist/runtime/metrics/server.js +0 -53
- package/dist/runtime/metrics/server.js.map +0 -1
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -2
- package/dist/runtime/plugin.js.map +0 -1
- package/dist/runtime/runtime.d.ts +0 -27
- package/dist/runtime/runtime.js +0 -77
- package/dist/runtime/runtime.js.map +0 -1
- package/dist/runtime/scheduler/index.d.ts +0 -22
- package/dist/runtime/scheduler/index.js +0 -20
- package/dist/runtime/scheduler/index.js.map +0 -1
- package/dist/runtime/server/applications.d.ts +0 -91
- package/dist/runtime/server/applications.js +0 -171
- package/dist/runtime/server/applications.js.map +0 -1
- package/dist/runtime/server/config.d.ts +0 -148
- package/dist/runtime/server/config.js +0 -33
- package/dist/runtime/server/config.js.map +0 -1
- package/dist/runtime/server/environment.d.ts +0 -43
- package/dist/runtime/server/environment.js +0 -33
- package/dist/runtime/server/environment.js.map +0 -1
- package/dist/runtime/server/error-policy.d.ts +0 -62
- package/dist/runtime/server/error-policy.js +0 -73
- package/dist/runtime/server/error-policy.js.map +0 -1
- package/dist/runtime/server/hmr-coordinator.d.ts +0 -37
- package/dist/runtime/server/hmr-coordinator.js +0 -94
- package/dist/runtime/server/hmr-coordinator.js.map +0 -1
- package/dist/runtime/server/jobs.d.ts +0 -54
- package/dist/runtime/server/jobs.js +0 -176
- package/dist/runtime/server/jobs.js.map +0 -1
- package/dist/runtime/server/lifecycle.d.ts +0 -85
- package/dist/runtime/server/lifecycle.js +0 -177
- package/dist/runtime/server/lifecycle.js.map +0 -1
- package/dist/runtime/server/managed-worker.d.ts +0 -158
- package/dist/runtime/server/managed-worker.js +0 -420
- package/dist/runtime/server/managed-worker.js.map +0 -1
- package/dist/runtime/server/pool-manager.d.ts +0 -85
- package/dist/runtime/server/pool-manager.js +0 -129
- package/dist/runtime/server/pool-manager.js.map +0 -1
- package/dist/runtime/server/proxy.d.ts +0 -21
- package/dist/runtime/server/proxy.js +0 -76
- package/dist/runtime/server/proxy.js.map +0 -1
- package/dist/runtime/server/server.d.ts +0 -60
- package/dist/runtime/server/server.js +0 -163
- package/dist/runtime/server/server.js.map +0 -1
- package/dist/runtime/server/types.d.ts +0 -31
- package/dist/runtime/server/types.js +0 -2
- package/dist/runtime/server/types.js.map +0 -1
- package/dist/runtime/server/worker-pool.d.ts +0 -121
- package/dist/runtime/server/worker-pool.js +0 -171
- package/dist/runtime/server/worker-pool.js.map +0 -1
- package/dist/runtime/store/index.d.ts +0 -3
- package/dist/runtime/store/index.js +0 -23
- package/dist/runtime/store/index.js.map +0 -1
- package/dist/runtime/subscription/manager.d.ts +0 -49
- package/dist/runtime/subscription/manager.js +0 -170
- package/dist/runtime/subscription/manager.js.map +0 -1
- package/dist/runtime/subscription/redis.d.ts +0 -18
- package/dist/runtime/subscription/redis.js +0 -119
- package/dist/runtime/subscription/redis.js.map +0 -1
- package/dist/runtime/types.d.ts +0 -95
- package/dist/runtime/types.js +0 -2
- package/dist/runtime/types.js.map +0 -1
- package/dist/runtime/workers/application.d.ts +0 -29
- package/dist/runtime/workers/application.js +0 -77
- package/dist/runtime/workers/application.js.map +0 -1
- package/dist/runtime/workers/base.d.ts +0 -14
- package/dist/runtime/workers/base.js +0 -41
- package/dist/runtime/workers/base.js.map +0 -1
- package/dist/runtime/workers/cli.d.ts +0 -1
- package/dist/runtime/workers/cli.js +0 -2
- package/dist/runtime/workers/cli.js.map +0 -1
- package/dist/runtime/workers/job.d.ts +0 -20
- package/dist/runtime/workers/job.js +0 -170
- package/dist/runtime/workers/job.js.map +0 -1
- package/dist/vite/builder.d.ts +0 -5
- package/dist/vite/builder.js +0 -79
- package/dist/vite/builder.js.map +0 -1
- package/dist/vite/config.d.ts +0 -28
- package/dist/vite/config.js +0 -22
- package/dist/vite/config.js.map +0 -1
- package/dist/vite/plugins.d.ts +0 -2
- package/dist/vite/plugins.js +0 -43
- package/dist/vite/plugins.js.map +0 -1
- package/dist/vite/runners/worker.d.ts +0 -3
- package/dist/vite/runners/worker.js +0 -34
- package/dist/vite/runners/worker.js.map +0 -1
- package/dist/vite/server.d.ts +0 -3
- package/dist/vite/server.js +0 -36
- package/dist/vite/server.js.map +0 -1
- package/dist/vite/servers/main.d.ts +0 -8
- package/dist/vite/servers/main.js +0 -24
- package/dist/vite/servers/main.js.map +0 -1
- package/dist/vite/servers/worker.d.ts +0 -13
- package/dist/vite/servers/worker.js +0 -124
- package/dist/vite/servers/worker.js.map +0 -1
- package/src/cli.ts +0 -162
- package/src/codegen.ts +0 -30
- package/src/config.ts +0 -69
- package/src/entrypoints/cli.ts +0 -13
- package/src/entrypoints/main.ts +0 -317
- package/src/entrypoints/thread.ts +0 -223
- package/src/entrypoints/worker.ts +0 -174
- package/src/resolver.ts +0 -7
- package/src/runtime/application/index.ts +0 -1
- package/src/runtime/constants.ts +0 -13
- package/src/runtime/enums.ts +0 -12
- package/src/runtime/hooks.ts +0 -1
- package/src/runtime/index.ts +0 -29
- package/src/runtime/injectables.ts +0 -101
- package/src/runtime/jobs/job.ts +0 -467
- package/src/runtime/jobs/manager.ts +0 -454
- package/src/runtime/jobs/router.ts +0 -967
- package/src/runtime/jobs/runner.ts +0 -583
- package/src/runtime/jobs/step.ts +0 -66
- package/src/runtime/jobs/types.ts +0 -116
- package/src/runtime/metrics/metric.ts +0 -18
- package/src/runtime/metrics/registry.ts +0 -11
- package/src/runtime/metrics/server.ts +0 -69
- package/src/runtime/plugin.ts +0 -2
- package/src/runtime/runtime.ts +0 -103
- package/src/runtime/scheduler/index.ts +0 -39
- package/src/runtime/server/applications.ts +0 -264
- package/src/runtime/server/config.ts +0 -199
- package/src/runtime/server/environment.ts +0 -71
- package/src/runtime/server/error-policy.ts +0 -132
- package/src/runtime/server/hmr-coordinator.ts +0 -116
- package/src/runtime/server/jobs.ts +0 -266
- package/src/runtime/server/lifecycle.ts +0 -234
- package/src/runtime/server/managed-worker.ts +0 -546
- package/src/runtime/server/pool-manager.ts +0 -187
- package/src/runtime/server/proxy.ts +0 -119
- package/src/runtime/server/server.ts +0 -218
- package/src/runtime/server/types.ts +0 -32
- package/src/runtime/server/worker-pool.ts +0 -275
- package/src/runtime/store/index.ts +0 -30
- package/src/runtime/subscription/manager.ts +0 -307
- package/src/runtime/subscription/redis.ts +0 -159
- package/src/runtime/types.ts +0 -84
- package/src/runtime/workers/application.ts +0 -133
- package/src/runtime/workers/base.ts +0 -65
- package/src/runtime/workers/cli.ts +0 -0
- package/src/runtime/workers/job.ts +0 -142
- package/src/vite/builder.ts +0 -94
- package/src/vite/config.ts +0 -45
- package/src/vite/plugins.ts +0 -53
- package/src/vite/runners/worker.ts +0 -55
- package/src/vite/server.ts +0 -55
- package/src/vite/servers/main.ts +0 -41
- package/src/vite/servers/worker.ts +0 -177
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { StoreType } from '../enums.js';
|
|
2
|
-
export async function createStoreClient(config) {
|
|
3
|
-
if (config.type === StoreType.Redis) {
|
|
4
|
-
const { Redis } = await import('ioredis').catch(() => {
|
|
5
|
-
throw new Error('ioredis package is not installed. Please install it to use Redis store.');
|
|
6
|
-
});
|
|
7
|
-
return new Redis({
|
|
8
|
-
...config.options,
|
|
9
|
-
lazyConnect: true,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
else if (config.type === StoreType.Valkey) {
|
|
13
|
-
const { Redis } = await import('iovalkey').catch(() => {
|
|
14
|
-
throw new Error('iovalkey package is not installed. Please install it to use Valkey store.');
|
|
15
|
-
});
|
|
16
|
-
return new Redis({
|
|
17
|
-
...config.options,
|
|
18
|
-
lazyConnect: true,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
throw new Error('Unsupported store');
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/store/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAS;IAET,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACnD,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAA;QACH,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,KAAK,CAAC;YACf,GAAG,MAAM,CAAC,OAAO;YACjB,WAAW,EAAE,IAAI;SAClB,CAA0B,CAAA;IAC7B,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;QAC5C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACpD,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAA;QACH,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,KAAK,CAAC;YACf,GAAG,MAAM,CAAC,OAAO;YACjB,WAAW,EAAE,IAAI;SAClB,CAA0B,CAAA;IAC7B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Readable } from 'node:stream';
|
|
2
|
-
import type { TAnyEventContract, TAnySubscriptionContract } from '@nmtjs/contract';
|
|
3
|
-
import type { Logger } from '@nmtjs/core';
|
|
4
|
-
import type { t } from '@nmtjs/type';
|
|
5
|
-
export type SubscriptionAdapterEvent = {
|
|
6
|
-
channel: string;
|
|
7
|
-
payload: any;
|
|
8
|
-
};
|
|
9
|
-
export interface SubscriptionAdapterType {
|
|
10
|
-
publish(channel: string, payload: any): Promise<boolean>;
|
|
11
|
-
subscribe(channel: string, signal?: AbortSignal): AsyncGenerator<SubscriptionAdapterEvent>;
|
|
12
|
-
initialize(): Promise<void>;
|
|
13
|
-
dispose(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export type SubscriptionChannel = {
|
|
16
|
-
stream: Readable;
|
|
17
|
-
subscription: TAnySubscriptionContract;
|
|
18
|
-
event: TAnyEventContract;
|
|
19
|
-
};
|
|
20
|
-
export type SubscribeFn = <Contract extends TAnySubscriptionContract, Events extends {
|
|
21
|
-
[K in keyof Contract['events']]?: true;
|
|
22
|
-
}>(subscription: Contract, events: Events, options: Contract['options'], signal?: AbortSignal) => Promise<Omit<Readable, typeof Symbol.asyncIterator> & {
|
|
23
|
-
[Symbol.asyncIterator]: () => AsyncIterator<{} extends Events ? {
|
|
24
|
-
[K in keyof Contract['events']]: {
|
|
25
|
-
event: K;
|
|
26
|
-
data: t.infer.decode.output<Contract['events'][K]['payload']>;
|
|
27
|
-
};
|
|
28
|
-
}[keyof Contract['events']] : {
|
|
29
|
-
[K in keyof Events]: K extends keyof Contract['events'] ? {
|
|
30
|
-
event: K;
|
|
31
|
-
data: t.infer.decode.output<Contract['events'][K]['payload']>;
|
|
32
|
-
} : never;
|
|
33
|
-
}[keyof Events]>;
|
|
34
|
-
}>;
|
|
35
|
-
export type PublishFn = <S extends TAnySubscriptionContract, E extends S['events'][keyof S['events']]>(event: E, options: S['options'], data: t.infer.decode.input<E['payload']>) => Promise<boolean>;
|
|
36
|
-
export type SubscriptionManagerOptions = {
|
|
37
|
-
logger: Logger;
|
|
38
|
-
adapter: SubscriptionAdapterType;
|
|
39
|
-
};
|
|
40
|
-
export declare class SubscriptionManager {
|
|
41
|
-
protected readonly options: SubscriptionManagerOptions;
|
|
42
|
-
readonly subscriptions: Map<string, SubscriptionChannel>;
|
|
43
|
-
protected readonly logger: Logger;
|
|
44
|
-
constructor(options: SubscriptionManagerOptions);
|
|
45
|
-
subscribe: SubscribeFn;
|
|
46
|
-
publish: PublishFn;
|
|
47
|
-
dispose(): Promise<void>;
|
|
48
|
-
private createEventStream;
|
|
49
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { PassThrough, Readable } from 'node:stream';
|
|
4
|
-
import { isAbortError } from '@nmtjs/common';
|
|
5
|
-
export class SubscriptionManager {
|
|
6
|
-
options;
|
|
7
|
-
subscriptions = new Map();
|
|
8
|
-
logger;
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.options = options;
|
|
11
|
-
this.logger = options.logger.child({ component: SubscriptionManager.name });
|
|
12
|
-
}
|
|
13
|
-
subscribe = async (subscription, events, options, signal) => {
|
|
14
|
-
const eventKeys = Object.keys(events).length === 0
|
|
15
|
-
? Object.keys(subscription.events)
|
|
16
|
-
: Object.keys(events);
|
|
17
|
-
this.logger.debug({ subscription: subscription.name, eventCount: eventKeys.length }, 'Opening subscription');
|
|
18
|
-
const streams = Array(eventKeys.length);
|
|
19
|
-
for (const index in eventKeys) {
|
|
20
|
-
const event = subscription.events[eventKeys[index]];
|
|
21
|
-
const channel = getChannelName(event, options);
|
|
22
|
-
if (this.subscriptions.has(channel)) {
|
|
23
|
-
streams[index] = this.subscriptions.get(channel).stream;
|
|
24
|
-
this.logger.trace({
|
|
25
|
-
channel,
|
|
26
|
-
event: event.name,
|
|
27
|
-
activeChannels: this.subscriptions.size,
|
|
28
|
-
}, 'Reusing pubsub channel stream');
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const iterable = this.options.adapter.subscribe(channel, signal);
|
|
32
|
-
const stream = this.createEventStream(iterable);
|
|
33
|
-
stream.on('close', () => {
|
|
34
|
-
this.subscriptions.delete(channel);
|
|
35
|
-
this.logger.debug({
|
|
36
|
-
channel,
|
|
37
|
-
event: event.name,
|
|
38
|
-
activeChannels: this.subscriptions.size,
|
|
39
|
-
}, 'Pubsub channel stream closed');
|
|
40
|
-
});
|
|
41
|
-
stream.on('error', (error) => {
|
|
42
|
-
this.logger.warn({ channel, event: event.name, error }, 'Pubsub channel stream failed');
|
|
43
|
-
});
|
|
44
|
-
streams[index] = stream;
|
|
45
|
-
this.subscriptions.set(channel, { subscription, event, stream });
|
|
46
|
-
this.logger.debug({
|
|
47
|
-
channel,
|
|
48
|
-
event: event.name,
|
|
49
|
-
activeChannels: this.subscriptions.size,
|
|
50
|
-
}, 'Creating channel stream');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const mergedStream = mergeEventStreams(streams, signal);
|
|
54
|
-
mergedStream.once('close', () => {
|
|
55
|
-
this.logger.debug({ subscription: subscription.name, eventCount: eventKeys.length }, 'Pubsub subscription stream closed');
|
|
56
|
-
});
|
|
57
|
-
mergedStream.once('error', (error) => {
|
|
58
|
-
this.logger.warn({
|
|
59
|
-
subscription: subscription.name,
|
|
60
|
-
eventCount: eventKeys.length,
|
|
61
|
-
error,
|
|
62
|
-
}, 'Pubsub subscription stream failed');
|
|
63
|
-
});
|
|
64
|
-
return mergedStream;
|
|
65
|
-
};
|
|
66
|
-
publish = async (event, options, data) => {
|
|
67
|
-
const channel = getChannelName(event, options);
|
|
68
|
-
this.logger.trace({ channel, event: event.name }, 'Publishing pubsub event');
|
|
69
|
-
try {
|
|
70
|
-
const payload = event.payload.encode(data);
|
|
71
|
-
const published = await this.options.adapter.publish(channel, payload);
|
|
72
|
-
if (published) {
|
|
73
|
-
this.logger.trace({ channel, event: event.name }, 'Published pubsub event');
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
this.logger.warn({ channel, event: event.name }, 'Pubsub adapter reported publish failure');
|
|
77
|
-
}
|
|
78
|
-
return published;
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
this.logger.error({ channel, event: event.name, error }, 'Failed to publish pubsub event');
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
async dispose() {
|
|
86
|
-
for (const { stream } of this.subscriptions.values()) {
|
|
87
|
-
stream.destroy();
|
|
88
|
-
}
|
|
89
|
-
this.subscriptions.clear();
|
|
90
|
-
}
|
|
91
|
-
createEventStream(iterable) {
|
|
92
|
-
const { subscriptions } = this;
|
|
93
|
-
const logger = this.logger;
|
|
94
|
-
return new Readable({
|
|
95
|
-
objectMode: true,
|
|
96
|
-
read() {
|
|
97
|
-
iterable.next().then(({ value, done }) => {
|
|
98
|
-
if (done) {
|
|
99
|
-
logger.trace('Pubsub adapter stream ended');
|
|
100
|
-
this.push(null);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
const subscription = subscriptions.get(value.channel);
|
|
104
|
-
if (subscription) {
|
|
105
|
-
const { event } = subscription;
|
|
106
|
-
try {
|
|
107
|
-
const data = event.payload.decode(value.payload);
|
|
108
|
-
logger.trace({ channel: value.channel, event: event.name }, 'Received event');
|
|
109
|
-
this.push({ event: event.name, data });
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
logger.warn({ channel: value.channel, event: event.name, error }, 'Failed to decode pubsub event payload');
|
|
113
|
-
this.destroy(error);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
logger.trace({ channel: value.channel }, 'Dropped pubsub event for inactive channel');
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}, (error) => {
|
|
121
|
-
if (isAbortError(error)) {
|
|
122
|
-
logger.trace('Pubsub adapter stream aborted');
|
|
123
|
-
this.push(null);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
logger.warn({ error }, 'Pubsub adapter stream failed');
|
|
127
|
-
this.destroy(error);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function concat(...args) {
|
|
135
|
-
return args.filter(Boolean).join('/');
|
|
136
|
-
}
|
|
137
|
-
function getChannelName(contract, options) {
|
|
138
|
-
const key = options ? serializerOptions(options) : '';
|
|
139
|
-
assert(contract.name, 'Event contract must have a name');
|
|
140
|
-
return concat(contract.name, key);
|
|
141
|
-
}
|
|
142
|
-
function serializerOptions(options) {
|
|
143
|
-
const hash = createHash('sha1');
|
|
144
|
-
const serialized = Object.entries(options)
|
|
145
|
-
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
146
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
147
|
-
.join(';');
|
|
148
|
-
hash.update(serialized);
|
|
149
|
-
return hash.digest('base64url');
|
|
150
|
-
}
|
|
151
|
-
function mergeEventStreams(streams, signal) {
|
|
152
|
-
const destination = new PassThrough({
|
|
153
|
-
signal,
|
|
154
|
-
objectMode: true,
|
|
155
|
-
readableObjectMode: true,
|
|
156
|
-
writableObjectMode: true,
|
|
157
|
-
});
|
|
158
|
-
let ended = 0;
|
|
159
|
-
for (const source of streams) {
|
|
160
|
-
source.pipe(destination, { end: false });
|
|
161
|
-
source.once('end', () => {
|
|
162
|
-
ended++;
|
|
163
|
-
if (ended === streams.length) {
|
|
164
|
-
destination.end();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
return destination;
|
|
169
|
-
}
|
|
170
|
-
//# sourceMappingURL=manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/runtime/subscription/manager.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AASnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAkE5C,MAAM,OAAO,mBAAmB;IAIC,OAAO;IAH7B,aAAa,GAAG,IAAI,GAAG,EAA+B,CAAA;IAC5C,MAAM,CAAQ;IAEjC,YAA+B,OAAmC;uBAAnC,OAAO;QACpC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAA;IAC7E,CAAC;IAED,SAAS,GAAgB,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QACvE,MAAM,SAAS,GACb,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YAC9B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YAClC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEzB,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,EAAE,YAAY,EAAE,YAAY,CA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,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;SACxC,IAAI,CAAC,GAAG,CAAC,CAAA;IACZ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACvB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,iBAAiB,CACxB,OAAmB,EACnB,MAAoB;IAEpB,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC;QAClC,MAAM;QACN,UAAU,EAAE,IAAI;QAChB,kBAAkB,EAAE,IAAI;QACxB,kBAAkB,EAAE,IAAI;KACzB,CAAC,CAAA;IAEF,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;QACxC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;YACtB,KAAK,EAAE,CAAA;YACP,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;gBAC7B,WAAW,CAAC,GAAG,EAAE,CAAA;YACnB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
|
-
import type { RuntimePlugin } from '@nmtjs/application';
|
|
3
|
-
import type { Logger } from '@nmtjs/core';
|
|
4
|
-
import type { Store } from '../types.ts';
|
|
5
|
-
import type { SubscriptionAdapterEvent, SubscriptionAdapterType } from './manager.ts';
|
|
6
|
-
export declare class RedisSubscriptionAdapter implements SubscriptionAdapterType {
|
|
7
|
-
protected readonly client: Store;
|
|
8
|
-
protected readonly events: EventEmitter<[never]>;
|
|
9
|
-
protected readonly listeners: Map<string, number>;
|
|
10
|
-
protected readonly logger?: Logger;
|
|
11
|
-
protected subscriberClient?: Store;
|
|
12
|
-
constructor(client: Store, logger?: Logger);
|
|
13
|
-
initialize(): Promise<void>;
|
|
14
|
-
dispose(): Promise<void>;
|
|
15
|
-
publish(channel: string, payload: any): Promise<boolean>;
|
|
16
|
-
subscribe(channel: string, signal?: AbortSignal): AsyncGenerator<SubscriptionAdapterEvent>;
|
|
17
|
-
}
|
|
18
|
-
export declare const RedisSubscriptionAdapterPlugin: () => RuntimePlugin;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import EventEmitter, { on } from 'node:events';
|
|
2
|
-
import { isAbortError } from '@nmtjs/common';
|
|
3
|
-
import { CoreInjectables, createFactoryInjectable, provision, } from '@nmtjs/core';
|
|
4
|
-
import { storeConfig, subscriptionAdapter } from '../injectables.js';
|
|
5
|
-
import { createStoreClient } from '../store/index.js';
|
|
6
|
-
export class RedisSubscriptionAdapter {
|
|
7
|
-
client;
|
|
8
|
-
events = new EventEmitter();
|
|
9
|
-
listeners = new Map();
|
|
10
|
-
logger;
|
|
11
|
-
subscriberClient;
|
|
12
|
-
constructor(client, logger) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
this.logger = logger?.child({ component: RedisSubscriptionAdapter.name });
|
|
15
|
-
}
|
|
16
|
-
async initialize() {
|
|
17
|
-
this.logger?.debug('Initializing Redis adapter');
|
|
18
|
-
// Create a dedicated subscriber client (Redis requires separate clients for pub/sub)
|
|
19
|
-
this.subscriberClient = this.client.duplicate();
|
|
20
|
-
// Set up message handler
|
|
21
|
-
this.subscriberClient.on('message', (channel, message) => {
|
|
22
|
-
try {
|
|
23
|
-
const parsed = JSON.parse(message);
|
|
24
|
-
this.logger?.trace({ channel }, 'Received Redis message');
|
|
25
|
-
this.events.emit(channel, parsed);
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
this.logger?.warn({ channel, error }, 'Failed to parse Redis message');
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
this.logger?.debug('Redis adapter initialized');
|
|
32
|
-
}
|
|
33
|
-
async dispose() {
|
|
34
|
-
this.logger?.debug('Disposing Redis adapter');
|
|
35
|
-
if (this.subscriberClient) {
|
|
36
|
-
await this.subscriberClient.quit();
|
|
37
|
-
this.subscriberClient = undefined;
|
|
38
|
-
}
|
|
39
|
-
this.logger?.debug('Redis adapter disposed');
|
|
40
|
-
}
|
|
41
|
-
async publish(channel, payload) {
|
|
42
|
-
this.logger?.trace({ channel }, 'Publishing Redis message');
|
|
43
|
-
try {
|
|
44
|
-
await this.client.publish(channel, JSON.stringify(payload));
|
|
45
|
-
this.logger?.trace({ channel }, 'Published Redis message');
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
this.logger?.warn({ channel, error }, 'Failed to publish Redis message');
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async *subscribe(channel, signal) {
|
|
54
|
-
if (!this.subscriberClient) {
|
|
55
|
-
throw new Error('RedisSubscriptionAdapter not initialized');
|
|
56
|
-
}
|
|
57
|
-
this.logger?.debug({ channel }, 'Opening Redis channel listener');
|
|
58
|
-
if (!this.listeners.has(channel)) {
|
|
59
|
-
await this.subscriberClient.subscribe(channel);
|
|
60
|
-
this.listeners.set(channel, 1);
|
|
61
|
-
this.logger?.debug({ channel, listeners: 1 }, 'Subscribed Redis channel');
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
const listeners = this.listeners.get(channel) + 1;
|
|
65
|
-
this.listeners.set(channel, listeners);
|
|
66
|
-
this.logger?.trace({ channel, listeners }, 'Reusing Redis channel listener');
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
signal?.throwIfAborted();
|
|
70
|
-
for await (const [payload] of on(this.events, channel, { signal })) {
|
|
71
|
-
this.logger?.trace({ channel }, 'Delivering Redis message');
|
|
72
|
-
yield { channel, payload };
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
if (isAbortError(error)) {
|
|
77
|
-
this.logger?.trace({ channel }, 'Redis channel listener aborted');
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
this.logger?.warn({ channel, error }, 'Redis channel listener failed');
|
|
81
|
-
}
|
|
82
|
-
finally {
|
|
83
|
-
const count = this.listeners.get(channel);
|
|
84
|
-
if (count !== undefined) {
|
|
85
|
-
if (count > 1) {
|
|
86
|
-
const listeners = count - 1;
|
|
87
|
-
this.listeners.set(channel, listeners);
|
|
88
|
-
this.logger?.trace({ channel, listeners }, 'Detached Redis channel listener');
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
await this.subscriberClient?.unsubscribe(channel);
|
|
92
|
-
this.listeners.delete(channel);
|
|
93
|
-
this.logger?.debug({ channel, listeners: 0 }, 'Unsubscribed Redis channel');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
export const RedisSubscriptionAdapterPlugin = () => {
|
|
100
|
-
const adapterFactory = createFactoryInjectable({
|
|
101
|
-
dependencies: { config: storeConfig, logger: CoreInjectables.logger },
|
|
102
|
-
factory: async ({ config, logger }) => {
|
|
103
|
-
const connection = await createStoreClient(config);
|
|
104
|
-
const adapter = new RedisSubscriptionAdapter(connection, logger);
|
|
105
|
-
await adapter.initialize();
|
|
106
|
-
return { adapter, connection };
|
|
107
|
-
},
|
|
108
|
-
pick: ({ adapter }) => adapter,
|
|
109
|
-
dispose: async ({ adapter, connection }) => {
|
|
110
|
-
await adapter.dispose();
|
|
111
|
-
await connection.quit();
|
|
112
|
-
},
|
|
113
|
-
}, 'RedisSubscriptionAdapter');
|
|
114
|
-
return {
|
|
115
|
-
name: 'redis-subscription-adapter',
|
|
116
|
-
injections: [provision(subscriptionAdapter, adapterFactory)],
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=redis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sourceRoot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IAAI,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YAChE,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;YAC1B,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA;QAChC,CAAC;QACD,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO;QAC9B,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;YACzC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;YACvB,MAAM,UAAU,CAAC,IAAI,EAAE,CAAA;QACzB,CAAC;KACF,EACD,0BAA0B,CAC3B,CAAA;IAED,OAAO;QACL,IAAI,EAAE,4BAA4B;QAClC,UAAU,EAAE,CAAC,SAAS,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;KAC7D,CAAA;AACH,CAAC,CAAA"}
|
package/dist/runtime/types.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { ApplicationHostDefinition } from '@nmtjs/application';
|
|
2
|
-
import type { ProxyableTransportType } from '@nmtjs/gateway';
|
|
3
|
-
import type { Redis, RedisOptions } from 'ioredis';
|
|
4
|
-
import type { Redis as Valkey, RedisOptions as ValkeyOptions } from 'iovalkey';
|
|
5
|
-
import type { StoreType } from './enums.ts';
|
|
6
|
-
export type WorkerThreadErrorOrigin = 'bootstrap' | 'start' | 'runtime';
|
|
7
|
-
export type ThreadErrorMessage = {
|
|
8
|
-
message: string;
|
|
9
|
-
name?: string;
|
|
10
|
-
stack?: string;
|
|
11
|
-
origin: WorkerThreadErrorOrigin;
|
|
12
|
-
fatal: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type WorkerThreadError = Error & {
|
|
15
|
-
origin?: WorkerThreadErrorOrigin;
|
|
16
|
-
fatal?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export type ServerPortMessageTypes = {
|
|
19
|
-
stop: undefined;
|
|
20
|
-
task: {
|
|
21
|
-
id: string;
|
|
22
|
-
task: WorkerJobTask;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export type ThreadPortMessageTypes = {
|
|
26
|
-
ready: {
|
|
27
|
-
hosts?: {
|
|
28
|
-
type: ProxyableTransportType;
|
|
29
|
-
url: string;
|
|
30
|
-
}[];
|
|
31
|
-
};
|
|
32
|
-
error: ThreadErrorMessage;
|
|
33
|
-
task: {
|
|
34
|
-
id: string;
|
|
35
|
-
task: JobTaskResult;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export type ServerPortMessage = {
|
|
39
|
-
[K in keyof ServerPortMessageTypes]: {
|
|
40
|
-
type: K;
|
|
41
|
-
data: ServerPortMessageTypes[K];
|
|
42
|
-
};
|
|
43
|
-
}[keyof ServerPortMessageTypes];
|
|
44
|
-
export type ThreadPortMessage = {
|
|
45
|
-
[K in keyof ThreadPortMessageTypes]: {
|
|
46
|
-
type: K;
|
|
47
|
-
data: ThreadPortMessageTypes[K];
|
|
48
|
-
};
|
|
49
|
-
}[keyof ThreadPortMessageTypes];
|
|
50
|
-
export interface WorkerTask {
|
|
51
|
-
type?: string;
|
|
52
|
-
payload?: any;
|
|
53
|
-
}
|
|
54
|
-
export type WorkerJobTask = {
|
|
55
|
-
jobId: string;
|
|
56
|
-
jobName: string;
|
|
57
|
-
data: any;
|
|
58
|
-
};
|
|
59
|
-
export type JobTaskResult = {
|
|
60
|
-
[K in keyof JobTaskResultTypes]: {
|
|
61
|
-
type: K;
|
|
62
|
-
} & JobTaskResultTypes[K];
|
|
63
|
-
}[keyof JobTaskResultTypes];
|
|
64
|
-
export type JobTaskResultTypes = {
|
|
65
|
-
success: {
|
|
66
|
-
result?: unknown;
|
|
67
|
-
};
|
|
68
|
-
error: {
|
|
69
|
-
error: any;
|
|
70
|
-
};
|
|
71
|
-
unrecoverable_error: {
|
|
72
|
-
error: any;
|
|
73
|
-
};
|
|
74
|
-
job_not_found: {};
|
|
75
|
-
queue_job_not_found: {};
|
|
76
|
-
};
|
|
77
|
-
export type ApplicationDefinitionType = {
|
|
78
|
-
type: 'neemata';
|
|
79
|
-
definition: ApplicationHostDefinition;
|
|
80
|
-
} | {
|
|
81
|
-
type: 'custom';
|
|
82
|
-
definition: any;
|
|
83
|
-
};
|
|
84
|
-
export interface Applications extends Record<string, ApplicationDefinitionType> {
|
|
85
|
-
}
|
|
86
|
-
export type StoreTypes = {
|
|
87
|
-
[StoreType.Redis]: Redis;
|
|
88
|
-
[StoreType.Valkey]: Valkey;
|
|
89
|
-
};
|
|
90
|
-
export type StoreTypeOptions = {
|
|
91
|
-
[StoreType.Redis]: RedisOptions;
|
|
92
|
-
[StoreType.Valkey]: ValkeyOptions;
|
|
93
|
-
};
|
|
94
|
-
export type Store = StoreTypes[StoreType];
|
|
95
|
-
export type StoreOptions = StoreTypeOptions[StoreType];
|
package/dist/runtime/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { ApplicationHost, ApplicationHostDefinition, ApplicationHostOptions, ApplicationResolvedProcedure, NeemataApplication } from '@nmtjs/application';
|
|
2
|
-
import type { Gateway, GatewayOptions } from '@nmtjs/gateway';
|
|
3
|
-
import type { ServerApplicationConfig, ServerConfig } from '../server/config.ts';
|
|
4
|
-
import { BaseWorkerRuntime } from './base.ts';
|
|
5
|
-
export interface ApplicationWorkerRuntimeOptions {
|
|
6
|
-
name: string;
|
|
7
|
-
path: string;
|
|
8
|
-
transports: ServerApplicationConfig['threads'][number];
|
|
9
|
-
}
|
|
10
|
-
export declare class ApplicationWorkerRuntime extends BaseWorkerRuntime {
|
|
11
|
-
readonly config: ServerConfig;
|
|
12
|
-
readonly runtimeOptions: ApplicationWorkerRuntimeOptions;
|
|
13
|
-
protected hostDefinition: ApplicationHostDefinition;
|
|
14
|
-
host: ApplicationHost;
|
|
15
|
-
constructor(config: ServerConfig, runtimeOptions: ApplicationWorkerRuntimeOptions, hostDefinition: ApplicationHostDefinition);
|
|
16
|
-
get application(): NeemataApplication;
|
|
17
|
-
get api(): import("@nmtjs/gateway").GatewayApi<ApplicationResolvedProcedure>;
|
|
18
|
-
get applicationHooks(): import("@nmtjs/application").ApplicationHooks;
|
|
19
|
-
get gateway(): Gateway<ApplicationResolvedProcedure>;
|
|
20
|
-
get transports(): GatewayOptions<ApplicationResolvedProcedure>['transports'];
|
|
21
|
-
start(): Promise<{
|
|
22
|
-
url: string;
|
|
23
|
-
type: import("@nmtjs/gateway").ProxyableTransportType;
|
|
24
|
-
}[]>;
|
|
25
|
-
stop(): Promise<void>;
|
|
26
|
-
reload(hostDefinition: ApplicationHostDefinition): Promise<void>;
|
|
27
|
-
protected _dependents(): Generator<never, void, unknown>;
|
|
28
|
-
protected resolveHostOptions(): Pick<ApplicationHostOptions, 'transports' | 'gateway' | 'identity'>;
|
|
29
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createApplicationHost, LifecycleHook } from '@nmtjs/application';
|
|
2
|
-
import { JsonFormat } from '@nmtjs/json-format/server';
|
|
3
|
-
import { MsgpackFormat } from '@nmtjs/msgpack-format/server';
|
|
4
|
-
import { ProtocolFormats } from '@nmtjs/protocol/server';
|
|
5
|
-
import { WorkerType } from '../enums.js';
|
|
6
|
-
import { BaseWorkerRuntime } from './base.js';
|
|
7
|
-
export class ApplicationWorkerRuntime extends BaseWorkerRuntime {
|
|
8
|
-
config;
|
|
9
|
-
runtimeOptions;
|
|
10
|
-
hostDefinition;
|
|
11
|
-
host;
|
|
12
|
-
constructor(config, runtimeOptions, hostDefinition) {
|
|
13
|
-
super(config, {
|
|
14
|
-
logger: config.logger,
|
|
15
|
-
name: `Worker ${runtimeOptions.name}`,
|
|
16
|
-
plugins: [],
|
|
17
|
-
}, WorkerType.Application);
|
|
18
|
-
this.config = config;
|
|
19
|
-
this.runtimeOptions = runtimeOptions;
|
|
20
|
-
this.hostDefinition = hostDefinition;
|
|
21
|
-
}
|
|
22
|
-
get application() {
|
|
23
|
-
return this.host.application;
|
|
24
|
-
}
|
|
25
|
-
get api() {
|
|
26
|
-
return this.application.api;
|
|
27
|
-
}
|
|
28
|
-
get applicationHooks() {
|
|
29
|
-
return this.application.applicationHooks;
|
|
30
|
-
}
|
|
31
|
-
get gateway() {
|
|
32
|
-
return this.host.gateway;
|
|
33
|
-
}
|
|
34
|
-
get transports() {
|
|
35
|
-
return this.host.transports;
|
|
36
|
-
}
|
|
37
|
-
async start() {
|
|
38
|
-
await this.initialize();
|
|
39
|
-
this.host = createApplicationHost(this.hostDefinition.application, {
|
|
40
|
-
name: this.runtimeOptions.name,
|
|
41
|
-
logger: this.logger,
|
|
42
|
-
container: this.container,
|
|
43
|
-
formats: new ProtocolFormats([new JsonFormat(), new MsgpackFormat()]),
|
|
44
|
-
...this.resolveHostOptions(),
|
|
45
|
-
});
|
|
46
|
-
return this.host.start();
|
|
47
|
-
}
|
|
48
|
-
async stop() {
|
|
49
|
-
await this.host.stop();
|
|
50
|
-
await this.dispose();
|
|
51
|
-
await this.lifecycleHooks.callHook(LifecycleHook.Stop);
|
|
52
|
-
}
|
|
53
|
-
async reload(hostDefinition) {
|
|
54
|
-
this.hostDefinition = hostDefinition;
|
|
55
|
-
await this.host.reloadApplication(hostDefinition.application);
|
|
56
|
-
}
|
|
57
|
-
*_dependents() { }
|
|
58
|
-
resolveHostOptions() {
|
|
59
|
-
const config = this.config.applications[this.runtimeOptions.name];
|
|
60
|
-
if (!config) {
|
|
61
|
-
throw new Error(`Missing server application config: ${this.runtimeOptions.name}`);
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
transports: createHostTransportConfig(this.hostDefinition.transports, this.runtimeOptions.transports),
|
|
65
|
-
gateway: this.hostDefinition.gateway,
|
|
66
|
-
identity: this.hostDefinition.identity,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function createHostTransportConfig(transports, options) {
|
|
71
|
-
const config = {};
|
|
72
|
-
for (const key in transports) {
|
|
73
|
-
config[key] = { transport: transports[key], options: options[key] };
|
|
74
|
-
}
|
|
75
|
-
return config;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=application.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/runtime/workers/application.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAQ7C,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAIlD,MAAM;IACN,cAAc;IACb,cAAc;IAL1B,IAAI,CAAkB;IAEtB,YACW,MAAoB,EACpB,cAA+C,EAC9C,cAAyC;QAEnD,KAAK,CACH,MAAM,EACN;YACE,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,IAAI,EAAE,UAAU,cAAc,CAAC,IAAI,EAAE;YACrC,OAAO,EAAE,EAAE;SACZ,EACD,UAAU,CAAC,WAAW,CACvB,CAAA;sBAZQ,MAAM;8BACN,cAAc;8BACb,cAAc;IAW1B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAA;IAC9B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;IAC7B,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAA;IAC1C,CAAC;IAED,IAAI,OAAO;QACT,OA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cAAc,CAAC,IAAI,EAAE,CACjE,CAAA;QACH,CAAC;QAED,OAAO;YACL,UAAU,EAAE,yBAAyB,CACnC,IAAI,CAAC,cAAc,CAAC,UAAU,EAC9B,IAAI,CAAC,cAAc,CAAC,UAAU,CAC/B;YACD,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO;YACpC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ;SACvC,CAAA;IACH,CAAC;CACF;AAED,SAAS,yBAAyB,CAGhC,UAAsB,EACtB,OAAuE;IAEvE,MAAM,MAAM,GAAG,EAKd,CAAA;IAED,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAA;IACrE,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { WorkerType } from '../enums.ts';
|
|
2
|
-
import type { BaseRuntimeOptions } from '../runtime.ts';
|
|
3
|
-
import type { ServerConfig } from '../server/config.ts';
|
|
4
|
-
import { JobManager } from '../jobs/manager.ts';
|
|
5
|
-
import { BaseRuntime } from '../runtime.ts';
|
|
6
|
-
export declare abstract class BaseWorkerRuntime extends BaseRuntime {
|
|
7
|
-
readonly config: ServerConfig;
|
|
8
|
-
readonly workerType: WorkerType;
|
|
9
|
-
jobManager?: JobManager;
|
|
10
|
-
constructor(config: ServerConfig, options: BaseRuntimeOptions, workerType: WorkerType);
|
|
11
|
-
initialize(): Promise<void>;
|
|
12
|
-
protected _initialize(): Promise<void>;
|
|
13
|
-
protected _dispose(): Promise<void>;
|
|
14
|
-
}
|