@crossdelta/cloudevents 0.7.17 → 0.7.19
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/bin/cli.js +2 -4
- package/dist/index.cjs +17 -12
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +17 -12
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -661,14 +661,12 @@ var init_errors = __esm({
|
|
|
661
661
|
});
|
|
662
662
|
|
|
663
663
|
// src/infrastructure/logging.ts
|
|
664
|
-
var
|
|
664
|
+
var createLogger, logger;
|
|
665
665
|
var init_logging = __esm({
|
|
666
666
|
"src/infrastructure/logging.ts"() {
|
|
667
|
-
LOG_PREFIX = "cloudevents";
|
|
668
667
|
createLogger = (enabled) => {
|
|
669
668
|
const logWithArgs = (consoleFn, message, args) => {
|
|
670
|
-
|
|
671
|
-
args !== void 0 ? consoleFn(formattedMessage, args) : consoleFn(formattedMessage);
|
|
669
|
+
args !== void 0 ? consoleFn(message, args) : consoleFn(message);
|
|
672
670
|
};
|
|
673
671
|
return {
|
|
674
672
|
log: (message, args) => enabled && logWithArgs(console.log, message, args),
|
package/dist/index.cjs
CHANGED
|
@@ -84,14 +84,12 @@ var init_errors = __esm({
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
// src/infrastructure/logging.ts
|
|
87
|
-
var
|
|
87
|
+
var createLogger, logger;
|
|
88
88
|
var init_logging = __esm({
|
|
89
89
|
"src/infrastructure/logging.ts"() {
|
|
90
|
-
LOG_PREFIX = "cloudevents";
|
|
91
90
|
createLogger = (enabled) => {
|
|
92
91
|
const logWithArgs = (consoleFn, message, args) => {
|
|
93
|
-
|
|
94
|
-
args !== void 0 ? consoleFn(formattedMessage, args) : consoleFn(formattedMessage);
|
|
92
|
+
args !== void 0 ? consoleFn(message, args) : consoleFn(message);
|
|
95
93
|
};
|
|
96
94
|
return {
|
|
97
95
|
log: (message, args) => enabled && logWithArgs(console.log, message, args),
|
|
@@ -2188,7 +2186,7 @@ function cloudEvents(options = {}) {
|
|
|
2188
2186
|
// package.json
|
|
2189
2187
|
var package_default = {
|
|
2190
2188
|
name: "@crossdelta/cloudevents",
|
|
2191
|
-
version: "0.7.
|
|
2189
|
+
version: "0.7.19",
|
|
2192
2190
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2193
2191
|
|
|
2194
2192
|
// src/plugin.ts
|
|
@@ -2433,6 +2431,7 @@ var SHORT_LIVED_DEFAULTS = {
|
|
|
2433
2431
|
};
|
|
2434
2432
|
var INITIAL_RETRY_DELAY_MS = 1e3;
|
|
2435
2433
|
var MAX_RETRY_DELAY_MS = 3e4;
|
|
2434
|
+
var ESCALATE_AFTER_MS = 5 * 60 * 1e3;
|
|
2436
2435
|
var CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
2437
2436
|
var global = globalThis;
|
|
2438
2437
|
var buildConnectOptions = (config, mode) => {
|
|
@@ -2450,11 +2449,14 @@ var getConnectionRegistry = () => {
|
|
|
2450
2449
|
};
|
|
2451
2450
|
var connectWithRetry = async (options, label) => {
|
|
2452
2451
|
let delay = INITIAL_RETRY_DELAY_MS;
|
|
2452
|
+
const startedAt = Date.now();
|
|
2453
2453
|
while (true) {
|
|
2454
2454
|
try {
|
|
2455
2455
|
return await nats.connect(options);
|
|
2456
2456
|
} catch (error) {
|
|
2457
|
-
|
|
2457
|
+
const elapsed = Date.now() - startedAt;
|
|
2458
|
+
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "warn";
|
|
2459
|
+
logger[logLevel](`[${label}] NATS connect failed, retrying in ${delay}ms...`, error);
|
|
2458
2460
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2459
2461
|
delay = Math.min(delay * 2, MAX_RETRY_DELAY_MS);
|
|
2460
2462
|
}
|
|
@@ -2614,7 +2616,7 @@ async function ensureConsumer(jsm, streamName, consumerName, options) {
|
|
|
2614
2616
|
// Filter subjects at consumer level (optional)
|
|
2615
2617
|
filter_subjects: options.filterSubjects
|
|
2616
2618
|
});
|
|
2617
|
-
logger.
|
|
2619
|
+
logger.debug(`[jetstream] created durable consumer ${consumerName} on stream ${streamName}`);
|
|
2618
2620
|
}
|
|
2619
2621
|
}
|
|
2620
2622
|
async function consumeJetStreamEvents(options) {
|
|
@@ -2625,7 +2627,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2625
2627
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2626
2628
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2627
2629
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2628
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2630
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2629
2631
|
const nc = await connectWithRetry(
|
|
2630
2632
|
{
|
|
2631
2633
|
servers,
|
|
@@ -2643,7 +2645,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2643
2645
|
const messages = await consumer.consume({
|
|
2644
2646
|
max_messages: options.maxMessages ?? 100
|
|
2645
2647
|
});
|
|
2646
|
-
logger.info(`[${name}] consuming from stream ${options.stream}`);
|
|
2648
|
+
logger.info(`[${name}] consuming from stream: ${options.stream}`);
|
|
2647
2649
|
const dlqEnabled = Boolean(options.quarantineTopic || options.errorTopic);
|
|
2648
2650
|
const idempotencyStore = options.idempotencyStore === false ? null : options.idempotencyStore ?? getDefaultIdempotencyStore();
|
|
2649
2651
|
const idempotencyTtl = options.idempotencyTtl;
|
|
@@ -2698,7 +2700,7 @@ async function consumeJetStreamStreams(options) {
|
|
|
2698
2700
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2699
2701
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2700
2702
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2701
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2703
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2702
2704
|
const nc = await connectWithRetry(
|
|
2703
2705
|
{
|
|
2704
2706
|
servers,
|
|
@@ -2755,7 +2757,6 @@ async function consumeJetStreamStreams(options) {
|
|
|
2755
2757
|
const messages = await consumer.consume({
|
|
2756
2758
|
max_messages: options.maxMessages ?? 100
|
|
2757
2759
|
});
|
|
2758
|
-
logger.info(`[${name}] consuming from stream ${stream}`);
|
|
2759
2760
|
(async () => {
|
|
2760
2761
|
try {
|
|
2761
2762
|
for await (const msg of messages) {
|
|
@@ -2767,6 +2768,9 @@ async function consumeJetStreamStreams(options) {
|
|
|
2767
2768
|
})();
|
|
2768
2769
|
allMessages.push(messages);
|
|
2769
2770
|
}
|
|
2771
|
+
const streamList = options.streams.join(", ");
|
|
2772
|
+
const streamLabel = options.streams.length === 1 ? "stream" : "streams";
|
|
2773
|
+
logger.info(`[${name}] consuming from ${streamLabel}: ${streamList}`);
|
|
2770
2774
|
return allMessages;
|
|
2771
2775
|
}
|
|
2772
2776
|
var ensureJetStreams = ensureJetStreamStreams;
|
|
@@ -2847,7 +2851,8 @@ async function consumeNatsEvents(options) {
|
|
|
2847
2851
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2848
2852
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2849
2853
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2850
|
-
|
|
2854
|
+
const handlerLabel = processedHandlers.length === 1 ? "handler" : "handlers";
|
|
2855
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} ${handlerLabel}: ${handlerNames}`);
|
|
2851
2856
|
const nc = await connectWithRetry(
|
|
2852
2857
|
{
|
|
2853
2858
|
servers,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
2
|
import { CloudEventV1 } from 'cloudevents';
|
|
3
|
-
import {
|
|
3
|
+
import { ZodType, z } from 'zod';
|
|
4
4
|
import { ChangeResult, FlowContext, FsContextMixin, GenerationContextMixin, FlowStep } from '@crossdelta/flowcore';
|
|
5
5
|
import { ConsumerMessages, Subscription } from 'nats';
|
|
6
6
|
|
|
@@ -413,7 +413,7 @@ interface EventHandler<T = unknown> {
|
|
|
413
413
|
*/
|
|
414
414
|
type HandlerConstructor<T = unknown> = (new (...args: unknown[]) => EventHandler<T>) & {
|
|
415
415
|
__eventarcMetadata?: {
|
|
416
|
-
schema:
|
|
416
|
+
schema: ZodType;
|
|
417
417
|
declaredType?: string;
|
|
418
418
|
match?: (event: EnrichedEvent<T>) => boolean;
|
|
419
419
|
safeParse?: boolean;
|
|
@@ -455,7 +455,7 @@ interface ChannelConfig {
|
|
|
455
455
|
* Note: In Zod v4, we use a more relaxed schema constraint to allow
|
|
456
456
|
* contracts defined in external packages to work correctly.
|
|
457
457
|
*/
|
|
458
|
-
interface HandleEventOptions<S =
|
|
458
|
+
interface HandleEventOptions<S = ZodType> {
|
|
459
459
|
schema: S;
|
|
460
460
|
type?: string;
|
|
461
461
|
match?: MatchFn<unknown>;
|
|
@@ -491,7 +491,7 @@ interface IdempotencyStore {
|
|
|
491
491
|
* Type helper to extract data type from a Zod schema
|
|
492
492
|
* Handles both data-only schemas and full CloudEvent schemas with a 'data' field
|
|
493
493
|
*/
|
|
494
|
-
type InferEventData<S extends
|
|
494
|
+
type InferEventData<S extends ZodType> = S['_output'] extends {
|
|
495
495
|
data: infer D;
|
|
496
496
|
} ? D : S['_output'];
|
|
497
497
|
|
|
@@ -542,7 +542,7 @@ type InferEventData<S extends ZodTypeAny> = S['_output'] extends {
|
|
|
542
542
|
* })
|
|
543
543
|
* ```
|
|
544
544
|
*/
|
|
545
|
-
declare function createContract<TSchema extends
|
|
545
|
+
declare function createContract<TSchema extends ZodType>(options: {
|
|
546
546
|
type: string;
|
|
547
547
|
schema: TSchema;
|
|
548
548
|
match?: HandleEventOptions['match'];
|
|
@@ -594,15 +594,15 @@ declare function createContract<TSchema extends ZodTypeAny>(options: {
|
|
|
594
594
|
* })
|
|
595
595
|
* ```
|
|
596
596
|
*/
|
|
597
|
-
declare function handleEvent<TSchema extends
|
|
597
|
+
declare function handleEvent<TSchema extends ZodType>(schemaOrOptions: TSchema | HandleEventOptions<TSchema> | HandleEventOptions, handler: (payload: TSchema['_output'], context?: EventContext) => Promise<unknown> | unknown, eventType?: string): HandlerConstructor;
|
|
598
598
|
/**
|
|
599
599
|
* Creates an event schema with type inference
|
|
600
600
|
* Automatically enforces the presence of a 'type' field
|
|
601
601
|
*/
|
|
602
|
-
declare function eventSchema<T extends Record<string,
|
|
603
|
-
type:
|
|
602
|
+
declare function eventSchema<T extends Record<string, ZodType>>(schema: T & {
|
|
603
|
+
type: ZodType;
|
|
604
604
|
}): z.ZodObject<T & {
|
|
605
|
-
type:
|
|
605
|
+
type: ZodType;
|
|
606
606
|
} extends infer T_1 ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strip>;
|
|
607
607
|
|
|
608
608
|
/**
|
|
@@ -797,7 +797,7 @@ declare const normalizeSubject: (eventType: string) => string;
|
|
|
797
797
|
* @param schema - Zod schema to extract type from
|
|
798
798
|
* @returns Event type string or undefined if not found
|
|
799
799
|
*/
|
|
800
|
-
declare const extractTypeFromSchema: (schema:
|
|
800
|
+
declare const extractTypeFromSchema: (schema: ZodType) => string | undefined;
|
|
801
801
|
|
|
802
802
|
/**
|
|
803
803
|
* Create Event Flow
|
|
@@ -1354,7 +1354,7 @@ declare const __resetNatsPublisher: () => Promise<void>;
|
|
|
1354
1354
|
declare const deriveSubjectFromType: (eventType: string, config?: RoutingConfig) => string;
|
|
1355
1355
|
declare const deriveStreamFromType: (eventType: string, config?: RoutingConfig) => string | undefined;
|
|
1356
1356
|
declare const publishNatsRawEvent: (subjectName: string, eventType: string, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1357
|
-
declare const publishNatsEvent: <T extends
|
|
1357
|
+
declare const publishNatsEvent: <T extends ZodType>(subjectName: string, schema: T, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1358
1358
|
declare const publish: (eventTypeOrContract: string | {
|
|
1359
1359
|
type: string;
|
|
1360
1360
|
channel?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
2
|
import { CloudEventV1 } from 'cloudevents';
|
|
3
|
-
import {
|
|
3
|
+
import { ZodType, z } from 'zod';
|
|
4
4
|
import { ChangeResult, FlowContext, FsContextMixin, GenerationContextMixin, FlowStep } from '@crossdelta/flowcore';
|
|
5
5
|
import { ConsumerMessages, Subscription } from 'nats';
|
|
6
6
|
|
|
@@ -413,7 +413,7 @@ interface EventHandler<T = unknown> {
|
|
|
413
413
|
*/
|
|
414
414
|
type HandlerConstructor<T = unknown> = (new (...args: unknown[]) => EventHandler<T>) & {
|
|
415
415
|
__eventarcMetadata?: {
|
|
416
|
-
schema:
|
|
416
|
+
schema: ZodType;
|
|
417
417
|
declaredType?: string;
|
|
418
418
|
match?: (event: EnrichedEvent<T>) => boolean;
|
|
419
419
|
safeParse?: boolean;
|
|
@@ -455,7 +455,7 @@ interface ChannelConfig {
|
|
|
455
455
|
* Note: In Zod v4, we use a more relaxed schema constraint to allow
|
|
456
456
|
* contracts defined in external packages to work correctly.
|
|
457
457
|
*/
|
|
458
|
-
interface HandleEventOptions<S =
|
|
458
|
+
interface HandleEventOptions<S = ZodType> {
|
|
459
459
|
schema: S;
|
|
460
460
|
type?: string;
|
|
461
461
|
match?: MatchFn<unknown>;
|
|
@@ -491,7 +491,7 @@ interface IdempotencyStore {
|
|
|
491
491
|
* Type helper to extract data type from a Zod schema
|
|
492
492
|
* Handles both data-only schemas and full CloudEvent schemas with a 'data' field
|
|
493
493
|
*/
|
|
494
|
-
type InferEventData<S extends
|
|
494
|
+
type InferEventData<S extends ZodType> = S['_output'] extends {
|
|
495
495
|
data: infer D;
|
|
496
496
|
} ? D : S['_output'];
|
|
497
497
|
|
|
@@ -542,7 +542,7 @@ type InferEventData<S extends ZodTypeAny> = S['_output'] extends {
|
|
|
542
542
|
* })
|
|
543
543
|
* ```
|
|
544
544
|
*/
|
|
545
|
-
declare function createContract<TSchema extends
|
|
545
|
+
declare function createContract<TSchema extends ZodType>(options: {
|
|
546
546
|
type: string;
|
|
547
547
|
schema: TSchema;
|
|
548
548
|
match?: HandleEventOptions['match'];
|
|
@@ -594,15 +594,15 @@ declare function createContract<TSchema extends ZodTypeAny>(options: {
|
|
|
594
594
|
* })
|
|
595
595
|
* ```
|
|
596
596
|
*/
|
|
597
|
-
declare function handleEvent<TSchema extends
|
|
597
|
+
declare function handleEvent<TSchema extends ZodType>(schemaOrOptions: TSchema | HandleEventOptions<TSchema> | HandleEventOptions, handler: (payload: TSchema['_output'], context?: EventContext) => Promise<unknown> | unknown, eventType?: string): HandlerConstructor;
|
|
598
598
|
/**
|
|
599
599
|
* Creates an event schema with type inference
|
|
600
600
|
* Automatically enforces the presence of a 'type' field
|
|
601
601
|
*/
|
|
602
|
-
declare function eventSchema<T extends Record<string,
|
|
603
|
-
type:
|
|
602
|
+
declare function eventSchema<T extends Record<string, ZodType>>(schema: T & {
|
|
603
|
+
type: ZodType;
|
|
604
604
|
}): z.ZodObject<T & {
|
|
605
|
-
type:
|
|
605
|
+
type: ZodType;
|
|
606
606
|
} extends infer T_1 ? { -readonly [P in keyof T_1]: T_1[P]; } : never, z.core.$strip>;
|
|
607
607
|
|
|
608
608
|
/**
|
|
@@ -797,7 +797,7 @@ declare const normalizeSubject: (eventType: string) => string;
|
|
|
797
797
|
* @param schema - Zod schema to extract type from
|
|
798
798
|
* @returns Event type string or undefined if not found
|
|
799
799
|
*/
|
|
800
|
-
declare const extractTypeFromSchema: (schema:
|
|
800
|
+
declare const extractTypeFromSchema: (schema: ZodType) => string | undefined;
|
|
801
801
|
|
|
802
802
|
/**
|
|
803
803
|
* Create Event Flow
|
|
@@ -1354,7 +1354,7 @@ declare const __resetNatsPublisher: () => Promise<void>;
|
|
|
1354
1354
|
declare const deriveSubjectFromType: (eventType: string, config?: RoutingConfig) => string;
|
|
1355
1355
|
declare const deriveStreamFromType: (eventType: string, config?: RoutingConfig) => string | undefined;
|
|
1356
1356
|
declare const publishNatsRawEvent: (subjectName: string, eventType: string, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1357
|
-
declare const publishNatsEvent: <T extends
|
|
1357
|
+
declare const publishNatsEvent: <T extends ZodType>(subjectName: string, schema: T, eventData: unknown, options?: PublishNatsEventOptions) => Promise<string>;
|
|
1358
1358
|
declare const publish: (eventTypeOrContract: string | {
|
|
1359
1359
|
type: string;
|
|
1360
1360
|
channel?: {
|
package/dist/index.js
CHANGED
|
@@ -59,14 +59,12 @@ var init_errors = __esm({
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// src/infrastructure/logging.ts
|
|
62
|
-
var
|
|
62
|
+
var createLogger, logger;
|
|
63
63
|
var init_logging = __esm({
|
|
64
64
|
"src/infrastructure/logging.ts"() {
|
|
65
|
-
LOG_PREFIX = "cloudevents";
|
|
66
65
|
createLogger = (enabled) => {
|
|
67
66
|
const logWithArgs = (consoleFn, message, args) => {
|
|
68
|
-
|
|
69
|
-
args !== void 0 ? consoleFn(formattedMessage, args) : consoleFn(formattedMessage);
|
|
67
|
+
args !== void 0 ? consoleFn(message, args) : consoleFn(message);
|
|
70
68
|
};
|
|
71
69
|
return {
|
|
72
70
|
log: (message, args) => enabled && logWithArgs(console.log, message, args),
|
|
@@ -2163,7 +2161,7 @@ function cloudEvents(options = {}) {
|
|
|
2163
2161
|
// package.json
|
|
2164
2162
|
var package_default = {
|
|
2165
2163
|
name: "@crossdelta/cloudevents",
|
|
2166
|
-
version: "0.7.
|
|
2164
|
+
version: "0.7.19",
|
|
2167
2165
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2168
2166
|
|
|
2169
2167
|
// src/plugin.ts
|
|
@@ -2408,6 +2406,7 @@ var SHORT_LIVED_DEFAULTS = {
|
|
|
2408
2406
|
};
|
|
2409
2407
|
var INITIAL_RETRY_DELAY_MS = 1e3;
|
|
2410
2408
|
var MAX_RETRY_DELAY_MS = 3e4;
|
|
2409
|
+
var ESCALATE_AFTER_MS = 5 * 60 * 1e3;
|
|
2411
2410
|
var CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
2412
2411
|
var global = globalThis;
|
|
2413
2412
|
var buildConnectOptions = (config, mode) => {
|
|
@@ -2425,11 +2424,14 @@ var getConnectionRegistry = () => {
|
|
|
2425
2424
|
};
|
|
2426
2425
|
var connectWithRetry = async (options, label) => {
|
|
2427
2426
|
let delay = INITIAL_RETRY_DELAY_MS;
|
|
2427
|
+
const startedAt = Date.now();
|
|
2428
2428
|
while (true) {
|
|
2429
2429
|
try {
|
|
2430
2430
|
return await connect(options);
|
|
2431
2431
|
} catch (error) {
|
|
2432
|
-
|
|
2432
|
+
const elapsed = Date.now() - startedAt;
|
|
2433
|
+
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "warn";
|
|
2434
|
+
logger[logLevel](`[${label}] NATS connect failed, retrying in ${delay}ms...`, error);
|
|
2433
2435
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2434
2436
|
delay = Math.min(delay * 2, MAX_RETRY_DELAY_MS);
|
|
2435
2437
|
}
|
|
@@ -2589,7 +2591,7 @@ async function ensureConsumer(jsm, streamName, consumerName, options) {
|
|
|
2589
2591
|
// Filter subjects at consumer level (optional)
|
|
2590
2592
|
filter_subjects: options.filterSubjects
|
|
2591
2593
|
});
|
|
2592
|
-
logger.
|
|
2594
|
+
logger.debug(`[jetstream] created durable consumer ${consumerName} on stream ${streamName}`);
|
|
2593
2595
|
}
|
|
2594
2596
|
}
|
|
2595
2597
|
async function consumeJetStreamEvents(options) {
|
|
@@ -2600,7 +2602,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2600
2602
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2601
2603
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2602
2604
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2603
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2605
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2604
2606
|
const nc = await connectWithRetry(
|
|
2605
2607
|
{
|
|
2606
2608
|
servers,
|
|
@@ -2618,7 +2620,7 @@ async function consumeJetStreamEvents(options) {
|
|
|
2618
2620
|
const messages = await consumer.consume({
|
|
2619
2621
|
max_messages: options.maxMessages ?? 100
|
|
2620
2622
|
});
|
|
2621
|
-
logger.info(`[${name}] consuming from stream ${options.stream}`);
|
|
2623
|
+
logger.info(`[${name}] consuming from stream: ${options.stream}`);
|
|
2622
2624
|
const dlqEnabled = Boolean(options.quarantineTopic || options.errorTopic);
|
|
2623
2625
|
const idempotencyStore = options.idempotencyStore === false ? null : options.idempotencyStore ?? getDefaultIdempotencyStore();
|
|
2624
2626
|
const idempotencyTtl = options.idempotencyTtl;
|
|
@@ -2673,7 +2675,7 @@ async function consumeJetStreamStreams(options) {
|
|
|
2673
2675
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2674
2676
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2675
2677
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2676
|
-
logger.info(`[${name}] discovered ${processedHandlers.length} handler
|
|
2678
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} handler${processedHandlers.length === 1 ? "" : "s"}: ${handlerNames}`);
|
|
2677
2679
|
const nc = await connectWithRetry(
|
|
2678
2680
|
{
|
|
2679
2681
|
servers,
|
|
@@ -2730,7 +2732,6 @@ async function consumeJetStreamStreams(options) {
|
|
|
2730
2732
|
const messages = await consumer.consume({
|
|
2731
2733
|
max_messages: options.maxMessages ?? 100
|
|
2732
2734
|
});
|
|
2733
|
-
logger.info(`[${name}] consuming from stream ${stream}`);
|
|
2734
2735
|
(async () => {
|
|
2735
2736
|
try {
|
|
2736
2737
|
for await (const msg of messages) {
|
|
@@ -2742,6 +2743,9 @@ async function consumeJetStreamStreams(options) {
|
|
|
2742
2743
|
})();
|
|
2743
2744
|
allMessages.push(messages);
|
|
2744
2745
|
}
|
|
2746
|
+
const streamList = options.streams.join(", ");
|
|
2747
|
+
const streamLabel = options.streams.length === 1 ? "stream" : "streams";
|
|
2748
|
+
logger.info(`[${name}] consuming from ${streamLabel}: ${streamList}`);
|
|
2745
2749
|
return allMessages;
|
|
2746
2750
|
}
|
|
2747
2751
|
var ensureJetStreams = ensureJetStreamStreams;
|
|
@@ -2822,7 +2826,8 @@ async function consumeNatsEvents(options) {
|
|
|
2822
2826
|
const handlerConstructors = await discoverHandlers(options.discover);
|
|
2823
2827
|
const processedHandlers = handlerConstructors.map(processHandler).filter((h) => h !== null);
|
|
2824
2828
|
const handlerNames = processedHandlers.map((h) => h.name).join(", ");
|
|
2825
|
-
|
|
2829
|
+
const handlerLabel = processedHandlers.length === 1 ? "handler" : "handlers";
|
|
2830
|
+
logger.info(`[${name}] discovered ${processedHandlers.length} ${handlerLabel}: ${handlerNames}`);
|
|
2826
2831
|
const nc = await connectWithRetry(
|
|
2827
2832
|
{
|
|
2828
2833
|
servers,
|
package/package.json
CHANGED