@cloudnux/local-cloud-provider 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,22 @@
1
1
  import { FastifyPluginOptions, FastifyPluginAsync } from 'fastify';
2
- import { EventBatchItemResult } from '@cloudnux/core-cloud-provider';
2
+ import { LoggerService, LogEntry, EventBatchItemResult } from '@cloudnux/core-cloud-provider';
3
+
4
+ type LogContext = {
5
+ module?: string;
6
+ reqId?: string;
7
+ };
8
+ type LogListener = (entry: LogEntry) => void;
9
+ type RunWithLogContext = <T>(context: LogContext, fn: () => T) => T;
10
+ type SubscribeToLogs = (listener: LogListener) => () => void;
11
+ type LoggingContext = LoggerService & {
12
+ runWithLogContext: RunWithLogContext;
13
+ subscribeToLogs: SubscribeToLogs;
14
+ };
15
+ declare module "fastify" {
16
+ interface FastifyInstance {
17
+ logging: LoggingContext;
18
+ }
19
+ }
3
20
 
4
21
  interface QueueMessage {
5
22
  id: string;
@@ -19,7 +36,6 @@ interface QueueService {
19
36
  incoming: QueueMessage[];
20
37
  processing: QueueMessage[];
21
38
  dlq: QueueMessage[];
22
- timeoutId: NodeJS.Timeout | null;
23
39
  processingBatch: boolean;
24
40
  module?: string;
25
41
  }
@@ -30,12 +46,12 @@ interface QueueConfig {
30
46
  parallel: boolean;
31
47
  maxConcurrent: number;
32
48
  retryBackoff: boolean;
49
+ tickIntervalMs: number;
33
50
  persistence: {
34
51
  enabled?: boolean;
35
52
  directory: string;
36
53
  saveInterval?: number;
37
54
  saveOnShutdown?: boolean;
38
- loadOnStartup?: boolean;
39
55
  };
40
56
  }
41
57
  interface QueueSummary {
@@ -54,6 +70,17 @@ interface QueueRegistryItem {
54
70
  queueName: string;
55
71
  handler: EventHandler;
56
72
  }
73
+ interface QueueMessageHistoryEntry {
74
+ id: string;
75
+ queueName: string;
76
+ status: 'completed' | 'failed';
77
+ timestamp: Date;
78
+ completedAt: Date;
79
+ attempts: number;
80
+ payload: any;
81
+ attributes: Record<string, any>;
82
+ error?: string;
83
+ }
57
84
  interface QueuePluginOptions extends FastifyPluginOptions {
58
85
  prefix?: string;
59
86
  config?: Partial<QueueConfig>;
@@ -89,19 +116,15 @@ interface QueueManager {
89
116
  message: string;
90
117
  purged: number;
91
118
  } | null>;
119
+ getMessageHistory: (queueName: string, limit?: number) => QueueMessageHistoryEntry[];
92
120
  }
93
- type ScheduleProcessingFn = (queueName: string, queueService: QueueService, overrideDelay?: number | null) => void;
94
- interface SchedulerRef {
95
- current?: ScheduleProcessingFn;
96
- }
97
- interface QueueDecoratorOptions {
121
+ interface QueueRuntime {
98
122
  config: QueueConfig;
99
123
  queues: Record<string, QueueService>;
100
124
  dirtyQueues: Set<string>;
101
- saveQueueState?: (queueName: string, queueService: QueueService) => Promise<void>;
102
- loadQueueState?: (queueName: string) => Promise<void>;
103
- scheduleProcessing: ScheduleProcessingFn;
104
- processBatch: (queueName: string, queueService: QueueService) => Promise<void>;
125
+ lastSavedAt: number;
126
+ messageHistory: QueueMessageHistoryEntry[];
127
+ logging: LoggingContext;
105
128
  }
106
129
  declare module 'fastify' {
107
130
  interface FastifyInstance {
@@ -111,4 +134,4 @@ declare module 'fastify' {
111
134
 
112
135
  declare const queuesPlugin: FastifyPluginAsync<QueuePluginOptions>;
113
136
 
114
- export { type EventHandler, type QueueConfig, type QueueDecoratorOptions, type QueueManager, type QueueMessage, type QueuePluginOptions, type QueueRegistryItem, type QueueService, type QueueSummary, type ScheduleProcessingFn, type SchedulerRef, queuesPlugin };
137
+ export { type EventHandler, type QueueConfig, type QueueManager, type QueueMessage, type QueueMessageHistoryEntry, type QueuePluginOptions, type QueueRegistryItem, type QueueRuntime, type QueueService, type QueueSummary, queuesPlugin };