@cloudnux/local-cloud-provider 0.17.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,15 +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
- interface QueueDecoratorOptions {
121
+ interface QueueRuntime {
94
122
  config: QueueConfig;
95
123
  queues: Record<string, QueueService>;
96
124
  dirtyQueues: Set<string>;
97
- saveQueueState?: (queueName: string, queueService: QueueService) => Promise<void>;
98
- loadQueueState?: (queueName: string) => Promise<void>;
99
- scheduleProcessing: (queueName: string, queueService: QueueService) => void;
100
- processBatch: (queueName: string, queueService: QueueService) => Promise<void>;
125
+ lastSavedAt: number;
126
+ messageHistory: QueueMessageHistoryEntry[];
127
+ logging: LoggingContext;
101
128
  }
102
129
  declare module 'fastify' {
103
130
  interface FastifyInstance {
@@ -107,4 +134,4 @@ declare module 'fastify' {
107
134
 
108
135
  declare const queuesPlugin: FastifyPluginAsync<QueuePluginOptions>;
109
136
 
110
- export { type EventHandler, type QueueConfig, type QueueDecoratorOptions, type QueueManager, type QueueMessage, type QueuePluginOptions, type QueueRegistryItem, type QueueService, type QueueSummary, queuesPlugin };
137
+ export { type EventHandler, type QueueConfig, type QueueManager, type QueueMessage, type QueueMessageHistoryEntry, type QueuePluginOptions, type QueueRegistryItem, type QueueRuntime, type QueueService, type QueueSummary, queuesPlugin };