@gravito/ripple 4.0.0 → 4.0.3
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/README.md +26 -10
- package/dist/{ripple/src/OrbitRipple.d.ts → OrbitRipple.d.ts} +1 -0
- package/dist/{ripple/src/RippleServer.d.ts → RippleServer.d.ts} +32 -2
- package/dist/core/src/Application.d.ts +41 -0
- package/dist/core/src/ConfigManager.d.ts +39 -0
- package/dist/core/src/Container/RequestScopeManager.d.ts +62 -0
- package/dist/core/src/Container/RequestScopeMetrics.d.ts +144 -0
- package/dist/core/src/Container.d.ts +45 -0
- package/dist/core/src/ErrorHandler.d.ts +3 -0
- package/dist/core/src/HookManager.d.ts +104 -165
- package/dist/core/src/PlanetCore.d.ts +114 -1
- package/dist/core/src/RequestContext.d.ts +97 -0
- package/dist/core/src/Router.d.ts +32 -46
- package/dist/core/src/ServiceProvider.d.ts +22 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +10 -1
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +35 -0
- package/dist/core/src/adapters/bun/BunWebSocketHandler.d.ts +48 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +1 -0
- package/dist/core/src/adapters/bun/index.d.ts +7 -0
- package/dist/core/src/binary/BinaryUtils.d.ts +105 -0
- package/dist/core/src/binary/index.d.ts +5 -0
- package/dist/core/src/cli/queue-commands.d.ts +6 -0
- package/dist/core/src/compat/async-local-storage.d.ts +7 -0
- package/dist/core/src/compat/crypto.d.ts +6 -0
- package/dist/core/src/engine/AOTRouter.d.ts +16 -1
- package/dist/core/src/engine/FastContext.d.ts +42 -1
- package/dist/core/src/engine/Gravito.d.ts +13 -19
- package/dist/core/src/engine/MinimalContext.d.ts +23 -0
- package/dist/core/src/engine/analyzer.d.ts +92 -6
- package/dist/core/src/engine/types.d.ts +6 -0
- package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +126 -0
- package/dist/core/src/events/BackpressureManager.d.ts +215 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +75 -1
- package/dist/core/src/events/EventBackend.d.ts +2 -1
- package/dist/core/src/events/EventOptions.d.ts +99 -4
- package/dist/core/src/events/EventPriorityQueue.d.ts +36 -175
- package/dist/core/src/events/FlowControlStrategy.d.ts +109 -0
- package/dist/core/src/events/MessageQueueBridge.d.ts +184 -0
- package/dist/core/src/events/PriorityEscalationManager.d.ts +82 -0
- package/dist/core/src/events/RetryScheduler.d.ts +104 -0
- package/dist/core/src/events/WorkerPool.d.ts +98 -0
- package/dist/core/src/events/WorkerPoolConfig.d.ts +153 -0
- package/dist/core/src/events/WorkerPoolMetrics.d.ts +65 -0
- package/dist/core/src/events/aggregation/AggregationWindow.d.ts +77 -0
- package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +135 -0
- package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +108 -0
- package/dist/core/src/events/aggregation/EventBatcher.d.ts +99 -0
- package/dist/core/src/events/aggregation/types.d.ts +117 -0
- package/dist/core/src/events/index.d.ts +18 -6
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +92 -0
- package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +76 -0
- package/dist/core/src/events/observability/index.d.ts +4 -0
- package/dist/core/src/events/queue-core.d.ts +77 -0
- package/dist/core/src/events/task-executor.d.ts +51 -0
- package/dist/core/src/events/types.d.ts +59 -0
- package/dist/core/src/ffi/NativeAccelerator.d.ts +62 -0
- package/dist/core/src/ffi/NativeHasher.d.ts +139 -0
- package/dist/core/src/ffi/cbor-fallback.d.ts +96 -0
- package/dist/core/src/ffi/hash-fallback.d.ts +33 -0
- package/dist/core/src/ffi/index.d.ts +10 -0
- package/dist/core/src/ffi/types.d.ts +135 -0
- package/dist/core/src/health/HealthProvider.d.ts +67 -0
- package/dist/core/src/helpers/Str.d.ts +15 -0
- package/dist/core/src/hooks/ActionManager.d.ts +132 -0
- package/dist/core/src/hooks/AsyncDetector.d.ts +84 -0
- package/dist/core/src/hooks/FilterManager.d.ts +71 -0
- package/dist/core/src/hooks/MigrationWarner.d.ts +24 -0
- package/dist/core/src/hooks/dlq-operations.d.ts +60 -0
- package/dist/core/src/hooks/types.d.ts +107 -0
- package/dist/core/src/http/CookieJar.d.ts +2 -2
- package/dist/core/src/http/types.d.ts +43 -3
- package/dist/core/src/index.d.ts +504 -15
- package/dist/core/src/observability/QueueDashboard.d.ts +136 -0
- package/dist/core/src/observability/contracts.d.ts +137 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +36 -3
- package/dist/core/src/runtime/adapter-bun.d.ts +12 -0
- package/dist/core/src/runtime/adapter-deno.d.ts +12 -0
- package/dist/core/src/runtime/adapter-node.d.ts +12 -0
- package/dist/core/src/runtime/adapter-unknown.d.ts +13 -0
- package/dist/core/src/runtime/archive.d.ts +17 -0
- package/dist/core/src/runtime/compression.d.ts +21 -0
- package/dist/core/src/runtime/deep-equals.d.ts +56 -0
- package/dist/core/src/runtime/detection.d.ts +22 -0
- package/dist/core/src/runtime/escape.d.ts +34 -0
- package/dist/core/src/runtime/index.d.ts +44 -0
- package/dist/core/src/runtime/markdown.d.ts +44 -0
- package/dist/core/src/runtime/types.d.ts +436 -0
- package/dist/core/src/runtime-helpers.d.ts +67 -0
- package/dist/core/src/runtime.d.ts +10 -118
- package/dist/core/src/testing/HttpTester.d.ts +1 -0
- package/dist/core/src/transpiler-utils.d.ts +170 -0
- package/dist/{ripple/src/engines → engines}/BunEngine.d.ts +11 -0
- package/dist/engines/UWebSocketsEngine.d.ts +97 -0
- package/dist/engines/WsEngine.d.ts +69 -0
- package/dist/{ripple/src/engines → engines}/index.d.ts +4 -0
- package/dist/index.js +1 -7139
- package/dist/index.js.map +3 -69
- package/dist/{ripple/src/serializers → serializers}/ISerializer.d.ts +1 -1
- package/dist/{ripple/src/serializers → serializers}/JsonSerializer.d.ts +1 -1
- package/dist/{ripple/src/serializers → serializers}/ProtobufSerializer.d.ts +6 -3
- package/dist/{ripple/src/types.d.ts → types.d.ts} +11 -0
- package/package.json +7 -2
- package/dist/atlas/src/DB.d.ts +0 -301
- package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
- package/dist/atlas/src/config/defineConfig.d.ts +0 -14
- package/dist/atlas/src/config/index.d.ts +0 -7
- package/dist/atlas/src/config/loadConfig.d.ts +0 -48
- package/dist/atlas/src/connection/Connection.d.ts +0 -108
- package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -111
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -66
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -83
- package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
- package/dist/atlas/src/drivers/types.d.ts +0 -260
- package/dist/atlas/src/errors/index.d.ts +0 -45
- package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
- package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
- package/dist/atlas/src/index.d.ts +0 -67
- package/dist/atlas/src/migration/Migration.d.ts +0 -64
- package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
- package/dist/atlas/src/migration/Migrator.d.ts +0 -110
- package/dist/atlas/src/migration/index.d.ts +0 -6
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -11
- package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
- package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
- package/dist/atlas/src/observability/index.d.ts +0 -9
- package/dist/atlas/src/orm/index.d.ts +0 -5
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
- package/dist/atlas/src/orm/model/Model.d.ts +0 -449
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -136
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -87
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
- package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
- package/dist/atlas/src/orm/model/decorators.d.ts +0 -109
- package/dist/atlas/src/orm/model/errors.d.ts +0 -52
- package/dist/atlas/src/orm/model/index.d.ts +0 -10
- package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
- package/dist/atlas/src/orm/model/types.d.ts +0 -12
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -123
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
- package/dist/atlas/src/orm/schema/index.d.ts +0 -6
- package/dist/atlas/src/orm/schema/types.d.ts +0 -85
- package/dist/atlas/src/query/Expression.d.ts +0 -60
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
- package/dist/atlas/src/query/QueryBuilder.d.ts +0 -573
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
- package/dist/atlas/src/query/clauses/index.d.ts +0 -11
- package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
- package/dist/atlas/src/schema/Schema.d.ts +0 -131
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
- package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
- package/dist/atlas/src/schema/index.d.ts +0 -8
- package/dist/atlas/src/seed/Factory.d.ts +0 -90
- package/dist/atlas/src/seed/Seeder.d.ts +0 -28
- package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
- package/dist/atlas/src/seed/index.d.ts +0 -6
- package/dist/atlas/src/types/index.d.ts +0 -1100
- package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
- package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -171
- package/dist/core/src/adapters/photon-types.d.ts +0 -73
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
- package/dist/core/src/http/middleware/Cors.d.ts +0 -24
- package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
- package/dist/core/src/instrumentation/index.d.ts +0 -35
- package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
- package/dist/core/src/instrumentation/types.d.ts +0 -182
- package/dist/photon/src/index.d.ts +0 -84
- package/dist/photon/src/middleware/binary.d.ts +0 -31
- package/dist/photon/src/middleware/htmx.d.ts +0 -39
- package/dist/photon/src/middleware/ratelimit.d.ts +0 -157
- package/dist/photon/src/openapi.d.ts +0 -19
- /package/dist/{ripple/src/channels → channels}/Channel.d.ts +0 -0
- /package/dist/{ripple/src/channels → channels}/ChannelManager.d.ts +0 -0
- /package/dist/{ripple/src/channels → channels}/index.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/LocalDriver.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/NATSDriver.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/RedisDriver.d.ts +0 -0
- /package/dist/{ripple/src/drivers → drivers}/index.d.ts +0 -0
- /package/dist/{ripple/src/engines → engines}/IRippleEngine.d.ts +0 -0
- /package/dist/{ripple/src/errors → errors}/RippleError.d.ts +0 -0
- /package/dist/{ripple/src/errors → errors}/index.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/BroadcastEvent.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/BroadcastManager.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/Broadcaster.d.ts +0 -0
- /package/dist/{ripple/src/events → events}/index.d.ts +0 -0
- /package/dist/{ripple/src/health → health}/HealthChecker.d.ts +0 -0
- /package/dist/{ripple/src/health → health}/index.d.ts +0 -0
- /package/dist/{ripple/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{ripple/src/logging → logging}/Logger.d.ts +0 -0
- /package/dist/{ripple/src/logging → logging}/index.d.ts +0 -0
- /package/dist/{ripple/src/middleware → middleware}/InterceptorManager.d.ts +0 -0
- /package/dist/{ripple/src/observability → observability}/RippleMetrics.d.ts +0 -0
- /package/dist/{ripple/src/reliability → reliability}/AckManager.d.ts +0 -0
- /package/dist/{ripple/src/serializers → serializers}/index.d.ts +0 -0
- /package/dist/{ripple/src/tracking → tracking}/ConnectionTracker.d.ts +0 -0
- /package/dist/{ripple/src/tracking → tracking}/SessionManager.d.ts +0 -0
- /package/dist/{ripple/src/tracking → tracking}/index.d.ts +0 -0
- /package/dist/{ripple/src/utils → utils}/MessageSerializer.d.ts +0 -0
- /package/dist/{ripple/src/utils → utils}/TokenBucket.d.ts +0 -0
- /package/dist/{ripple/src/utils → utils}/index.d.ts +0 -0
|
@@ -10,12 +10,50 @@ export interface EventOptions {
|
|
|
10
10
|
async?: boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Priority level for event processing.
|
|
13
|
-
* - '
|
|
14
|
-
* - '
|
|
15
|
-
* - '
|
|
13
|
+
* - 'critical': Immediate processing, bypass queue (< 1ms)
|
|
14
|
+
* - 'high': High priority events (< 50ms)
|
|
15
|
+
* - 'normal': Standard events (< 200ms)
|
|
16
|
+
* - 'low': Non-critical events (< 500ms)
|
|
16
17
|
* @default 'normal'
|
|
17
18
|
*/
|
|
18
|
-
priority?: 'high' | 'normal' | 'low';
|
|
19
|
+
priority?: 'critical' | 'high' | 'normal' | 'low';
|
|
20
|
+
/**
|
|
21
|
+
* Automatic priority escalation configuration.
|
|
22
|
+
* Events can be automatically upgraded to higher priority based on wait time.
|
|
23
|
+
*/
|
|
24
|
+
escalation?: {
|
|
25
|
+
/**
|
|
26
|
+
* Whether to enable automatic priority escalation.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Escalation thresholds in milliseconds.
|
|
32
|
+
* Events exceeding these wait times are promoted.
|
|
33
|
+
*/
|
|
34
|
+
thresholds?: {
|
|
35
|
+
/**
|
|
36
|
+
* Wait time before LOW events are promoted to NORMAL.
|
|
37
|
+
* @default 200
|
|
38
|
+
*/
|
|
39
|
+
lowToNormal?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Wait time before NORMAL events are promoted to HIGH.
|
|
42
|
+
* @default 100
|
|
43
|
+
*/
|
|
44
|
+
normalToHigh?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Wait time before HIGH events are promoted to CRITICAL.
|
|
47
|
+
* @default 50
|
|
48
|
+
*/
|
|
49
|
+
highToCritical?: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Maximum wait time before forcing CRITICAL priority.
|
|
53
|
+
* @default 500
|
|
54
|
+
*/
|
|
55
|
+
maxWaitTimeMs?: number;
|
|
56
|
+
};
|
|
19
57
|
/**
|
|
20
58
|
* Execution timeout in milliseconds.
|
|
21
59
|
* If a listener exceeds this timeout, it will be terminated.
|
|
@@ -101,6 +139,63 @@ export interface EventOptions {
|
|
|
101
139
|
*/
|
|
102
140
|
halfOpenRequests?: number;
|
|
103
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Event aggregation configuration (FS-102).
|
|
144
|
+
* Enables deduplication and micro-batching for improved throughput.
|
|
145
|
+
* @default undefined (disabled)
|
|
146
|
+
*/
|
|
147
|
+
aggregation?: {
|
|
148
|
+
/**
|
|
149
|
+
* Enable event aggregation.
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
enabled?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Aggregation window size in milliseconds.
|
|
155
|
+
* Backpressure-aware adjustment: 50-500ms
|
|
156
|
+
* @default 200
|
|
157
|
+
*/
|
|
158
|
+
windowMs?: number;
|
|
159
|
+
/**
|
|
160
|
+
* Batch size threshold for auto-flush.
|
|
161
|
+
* @default 50
|
|
162
|
+
*/
|
|
163
|
+
batchSize?: number;
|
|
164
|
+
/**
|
|
165
|
+
* Deduplication strategy.
|
|
166
|
+
* @default 'pattern'
|
|
167
|
+
*/
|
|
168
|
+
deduplication?: 'pattern' | 'idempotencyKey' | 'off';
|
|
169
|
+
/**
|
|
170
|
+
* Deduplication pattern (string or function).
|
|
171
|
+
* String: hook-based pattern
|
|
172
|
+
* Function: custom pattern from event args
|
|
173
|
+
*/
|
|
174
|
+
pattern?: string | ((args: unknown) => string);
|
|
175
|
+
/**
|
|
176
|
+
* Priority merge strategy.
|
|
177
|
+
* - 'highest': keep highest priority event
|
|
178
|
+
* - 'earliest': keep earliest event
|
|
179
|
+
* - 'latest': keep latest event
|
|
180
|
+
* @default 'highest'
|
|
181
|
+
*/
|
|
182
|
+
mergePriority?: 'highest' | 'earliest' | 'latest';
|
|
183
|
+
/**
|
|
184
|
+
* Enable automatic cleanup of expired entries.
|
|
185
|
+
* @default true
|
|
186
|
+
*/
|
|
187
|
+
enableCleanup?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Cleanup interval in milliseconds.
|
|
190
|
+
* @default 300000 (5 minutes)
|
|
191
|
+
*/
|
|
192
|
+
cleanupIntervalMs?: number;
|
|
193
|
+
/**
|
|
194
|
+
* TTL for entries in milliseconds.
|
|
195
|
+
* @default 600000 (10 minutes)
|
|
196
|
+
*/
|
|
197
|
+
ttlMs?: number;
|
|
198
|
+
};
|
|
104
199
|
}
|
|
105
200
|
/**
|
|
106
201
|
* Default event options.
|
|
@@ -1,202 +1,63 @@
|
|
|
1
1
|
import type { Span } from '@opentelemetry/api';
|
|
2
2
|
import type { ActionCallback } from '../HookManager';
|
|
3
|
-
import {
|
|
3
|
+
import type { BackpressureManager } from './BackpressureManager';
|
|
4
4
|
import type { DeadLetterQueue } from './DeadLetterQueue';
|
|
5
5
|
import type { EventBackend } from './EventBackend';
|
|
6
6
|
import type { EventOptions } from './EventOptions';
|
|
7
7
|
import type { EventMetrics } from './observability/EventMetrics';
|
|
8
8
|
import type { EventTracing } from './observability/EventTracing';
|
|
9
|
-
import type {
|
|
9
|
+
import type { OTelEventMetrics } from './observability/OTelEventMetrics';
|
|
10
|
+
import type { PriorityStatistics } from './PriorityEscalationManager';
|
|
11
|
+
import type { RetryScheduler } from './RetryScheduler';
|
|
12
|
+
import type { BackpressureStrategy, EventQueueConfig, EventTask, MultiPriorityQueueDepth } from './types';
|
|
13
|
+
import type { WorkerPool } from './WorkerPool';
|
|
10
14
|
export type { EventTask, EventQueueConfig, BackpressureStrategy };
|
|
11
15
|
/**
|
|
12
16
|
* Priority queue for event processing.
|
|
13
17
|
* Events are processed based on their priority level:
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
18
|
+
* - Critical priority events are processed first (< 1ms)
|
|
19
|
+
* - High priority events are processed second (< 50ms)
|
|
20
|
+
* - Normal priority events are processed third (< 200ms)
|
|
21
|
+
* - Low priority events are processed last (< 500ms)
|
|
22
|
+
*
|
|
23
|
+
* Supports automatic priority escalation based on wait time.
|
|
24
|
+
*
|
|
25
|
+
* Composed of:
|
|
26
|
+
* - {@link QueueCore}: queue data structures and backpressure logic
|
|
27
|
+
* - {@link TaskExecutor}: task execution, retry, circuit breaker, DLQ
|
|
17
28
|
*
|
|
18
29
|
* @internal
|
|
19
30
|
*/
|
|
20
31
|
export declare class EventPriorityQueue implements EventBackend {
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private lowPriority;
|
|
32
|
+
private queueCore;
|
|
33
|
+
private taskExecutor;
|
|
24
34
|
private processing;
|
|
25
|
-
private
|
|
26
|
-
private dlq?;
|
|
27
|
-
private persistentDLQHandler?;
|
|
28
|
-
private config;
|
|
29
|
-
private processingPartitions;
|
|
30
|
-
private eventCircuitBreakers;
|
|
31
|
-
private eventMetrics?;
|
|
32
|
-
private eventTracing?;
|
|
33
|
-
private currentDispatchSpan?;
|
|
35
|
+
private workerPool?;
|
|
34
36
|
constructor(config?: EventQueueConfig);
|
|
35
|
-
/**
|
|
36
|
-
* Set the Dead Letter Queue for failed events.
|
|
37
|
-
*
|
|
38
|
-
* @param dlq - Dead Letter Queue instance
|
|
39
|
-
*/
|
|
40
37
|
setDeadLetterQueue(dlq: DeadLetterQueue): void;
|
|
41
|
-
/**
|
|
42
|
-
* Set the persistent DLQ handler for failed events.
|
|
43
|
-
*
|
|
44
|
-
* @param handler - Async handler function for persistent DLQ
|
|
45
|
-
*/
|
|
46
38
|
setPersistentDLQHandler(handler: (hook: string, args: unknown, options: EventOptions, error: Error, retryCount: number, firstFailedAt: number) => Promise<void>): void;
|
|
47
|
-
/**
|
|
48
|
-
* Set the EventMetrics instance for recording circuit breaker metrics.
|
|
49
|
-
*
|
|
50
|
-
* @param metrics - EventMetrics instance
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
39
|
setEventMetrics(metrics: EventMetrics): void;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* @param tracing - EventTracing instance
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
40
|
+
setOTelEventMetrics(metrics: OTelEventMetrics): void;
|
|
41
|
+
setPriorityStatistics(stats: PriorityStatistics): void;
|
|
42
|
+
getPriorityStatistics(): PriorityStatistics | undefined;
|
|
60
43
|
setEventTracing(tracing: EventTracing): void;
|
|
61
|
-
/**
|
|
62
|
-
* Set the current dispatch span for creating child spans.
|
|
63
|
-
*
|
|
64
|
-
* @param span - Parent dispatch span
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
44
|
setCurrentDispatchSpan(span: Span | undefined): void;
|
|
68
|
-
/**
|
|
69
|
-
* Get the current dispatch span.
|
|
70
|
-
*
|
|
71
|
-
* @returns Current dispatch span or undefined
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
74
45
|
getCurrentDispatchSpan(): Span | undefined;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Enqueue an event task for processing.
|
|
86
|
-
*
|
|
87
|
-
* @param hook - Event hook name
|
|
88
|
-
* @param args - Event arguments
|
|
89
|
-
* @param callbacks - Callbacks to execute
|
|
90
|
-
* @param options - Event options
|
|
91
|
-
* @returns Task ID
|
|
92
|
-
*/
|
|
93
|
-
enqueue(task: EventTask): void;
|
|
46
|
+
setRetryScheduler(scheduler: RetryScheduler): void;
|
|
47
|
+
getRetryScheduler(): RetryScheduler | undefined;
|
|
48
|
+
getCircuitBreaker(hook: string): import("@gravito/core").CircuitBreaker | undefined;
|
|
49
|
+
getCircuitBreakers(): Map<string, import("@gravito/core").CircuitBreaker>;
|
|
50
|
+
resetCircuitBreaker(hook: string): boolean;
|
|
51
|
+
setWorkerPool(pool: WorkerPool): void;
|
|
52
|
+
getWorkerPool(): WorkerPool | undefined;
|
|
53
|
+
getBackpressureManager(): BackpressureManager | undefined;
|
|
54
|
+
enqueue(task: EventTask): string;
|
|
94
55
|
enqueue(hook: string, args: unknown, callbacks: ActionCallback[], options: EventOptions): string;
|
|
95
|
-
|
|
96
|
-
* Handle backpressure when queue is full.
|
|
97
|
-
* @returns True if space was made, false if event should be dropped
|
|
98
|
-
*/
|
|
99
|
-
private handleBackpressure;
|
|
100
|
-
/**
|
|
101
|
-
* Drop the oldest event from the queue, prioritizing low priority events.
|
|
102
|
-
*/
|
|
103
|
-
private dropOldest;
|
|
104
|
-
/**
|
|
105
|
-
* Process the next task in the queue.
|
|
106
|
-
* Tasks are processed in priority order: high > normal > low
|
|
107
|
-
*
|
|
108
|
-
* @internal
|
|
109
|
-
*/
|
|
110
|
-
private processNext;
|
|
111
|
-
/**
|
|
112
|
-
* Dequeue the next task based on priority and partition ordering.
|
|
113
|
-
*
|
|
114
|
-
* @returns Next task to process, or undefined if queue is empty
|
|
115
|
-
* @internal
|
|
116
|
-
*/
|
|
117
|
-
private dequeue;
|
|
118
|
-
/**
|
|
119
|
-
* Dequeue a task from a priority queue, respecting partition ordering.
|
|
120
|
-
*
|
|
121
|
-
* @param queue - Priority queue to dequeue from
|
|
122
|
-
* @returns Next task to process, or undefined if all tasks are blocked by partition locks
|
|
123
|
-
* @internal
|
|
124
|
-
*/
|
|
125
|
-
private dequeueFromPriority;
|
|
126
|
-
/**
|
|
127
|
-
* Execute an event task by running all its callbacks.
|
|
128
|
-
* Implements circuit breaker protection, retry logic with exponential backoff, and DLQ integration.
|
|
129
|
-
* Also handles partition ordering by acquiring and releasing partition locks.
|
|
130
|
-
*
|
|
131
|
-
* @param task - Event task to execute
|
|
132
|
-
* @internal
|
|
133
|
-
*/
|
|
134
|
-
private executeTask;
|
|
135
|
-
/**
|
|
136
|
-
* Calculate retry delay based on backoff strategy.
|
|
137
|
-
*
|
|
138
|
-
* @param retryCount - Current retry attempt number
|
|
139
|
-
* @param backoff - Backoff strategy
|
|
140
|
-
* @param initialDelay - Initial delay in ms
|
|
141
|
-
* @param maxDelay - Maximum delay in ms
|
|
142
|
-
* @returns Delay in milliseconds
|
|
143
|
-
* @internal
|
|
144
|
-
*/
|
|
145
|
-
private calculateRetryDelay;
|
|
146
|
-
/**
|
|
147
|
-
* Re-enqueue a task for retry.
|
|
148
|
-
*
|
|
149
|
-
* @param task - Task to retry
|
|
150
|
-
* @internal
|
|
151
|
-
*/
|
|
152
|
-
private enqueueRetry;
|
|
153
|
-
/**
|
|
154
|
-
* Execute a callback with timeout.
|
|
155
|
-
*
|
|
156
|
-
* @param callback - Callback to execute
|
|
157
|
-
* @param args - Arguments to pass to callback
|
|
158
|
-
* @param timeoutMs - Timeout in milliseconds
|
|
159
|
-
* @internal
|
|
160
|
-
*/
|
|
161
|
-
private executeWithTimeout;
|
|
162
|
-
/**
|
|
163
|
-
* Get the current depth of the queue.
|
|
164
|
-
*
|
|
165
|
-
* @returns Total number of tasks in the queue
|
|
166
|
-
*/
|
|
56
|
+
enqueueBatch(tasks: EventTask[]): string[];
|
|
167
57
|
getDepth(): number;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
* @param priority - Priority level
|
|
172
|
-
* @returns Number of tasks in the specified priority queue
|
|
173
|
-
*/
|
|
174
|
-
getDepthByPriority(priority: 'high' | 'normal' | 'low'): number;
|
|
175
|
-
/**
|
|
176
|
-
* Clear all tasks from the queue.
|
|
177
|
-
*/
|
|
58
|
+
getDepthByPriority(priority: 'critical' | 'high' | 'normal' | 'low'): number;
|
|
59
|
+
getQueueDepthByPriority(): MultiPriorityQueueDepth;
|
|
178
60
|
clear(): void;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
* @param hook - Event hook name
|
|
183
|
-
* @returns Circuit breaker instance or undefined
|
|
184
|
-
* @internal
|
|
185
|
-
*/
|
|
186
|
-
getCircuitBreaker(hook: string): CircuitBreaker | undefined;
|
|
187
|
-
/**
|
|
188
|
-
* Get all circuit breakers.
|
|
189
|
-
*
|
|
190
|
-
* @returns Map of circuit breakers keyed by hook name
|
|
191
|
-
* @internal
|
|
192
|
-
*/
|
|
193
|
-
getCircuitBreakers(): Map<string, CircuitBreaker>;
|
|
194
|
-
/**
|
|
195
|
-
* Reset a circuit breaker for an event hook.
|
|
196
|
-
*
|
|
197
|
-
* @param hook - Event hook name
|
|
198
|
-
* @returns True if reset, false if circuit breaker not found
|
|
199
|
-
* @internal
|
|
200
|
-
*/
|
|
201
|
-
resetCircuitBreaker(hook: string): boolean;
|
|
61
|
+
dequeue(): EventTask | undefined;
|
|
62
|
+
private processNext;
|
|
202
63
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gravito/core - Flow Control Strategies
|
|
3
|
+
*
|
|
4
|
+
* Implements various flow control strategies for backpressure management.
|
|
5
|
+
* Strategies can be composed to create flexible backpressure policies.
|
|
6
|
+
*
|
|
7
|
+
* 流控策略:支援多種組合策略進行靈活的背壓管理。
|
|
8
|
+
*/
|
|
9
|
+
import { type BackpressureConfig, type BackpressureDecision, BackpressureState } from './BackpressureManager';
|
|
10
|
+
/**
|
|
11
|
+
* 流控評估上下文。
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface FlowControlContext {
|
|
16
|
+
/** 當前背壓狀態 */
|
|
17
|
+
state: BackpressureState;
|
|
18
|
+
/** 事件優先級 */
|
|
19
|
+
priority: 'high' | 'normal' | 'low';
|
|
20
|
+
/** 總隊列深度 */
|
|
21
|
+
totalDepth: number;
|
|
22
|
+
/** 分優先級隊列深度 */
|
|
23
|
+
depthByPriority: {
|
|
24
|
+
high: number;
|
|
25
|
+
normal: number;
|
|
26
|
+
low: number;
|
|
27
|
+
};
|
|
28
|
+
/** 當前入隊速率(events/sec) */
|
|
29
|
+
currentRate: number;
|
|
30
|
+
/** 配置 */
|
|
31
|
+
config: Omit<BackpressureConfig, 'onRejected' | 'onStateChange'>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 流控策略介面。
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export interface FlowControlStrategy {
|
|
39
|
+
/** 策略名稱 */
|
|
40
|
+
readonly name: string;
|
|
41
|
+
/** 評估是否應該限制此事件 */
|
|
42
|
+
evaluate(context: FlowControlContext): BackpressureDecision;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 隊列深度策略。
|
|
46
|
+
*
|
|
47
|
+
* 根據總隊列深度和分優先級隊列深度決定是否限制事件入隊。
|
|
48
|
+
*/
|
|
49
|
+
export declare class QueueDepthStrategy implements FlowControlStrategy {
|
|
50
|
+
readonly name = "queue-depth";
|
|
51
|
+
evaluate(context: FlowControlContext): BackpressureDecision;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 速率限制策略。
|
|
55
|
+
*
|
|
56
|
+
* 根據每秒入隊速率限制事件入隊。
|
|
57
|
+
*/
|
|
58
|
+
export declare class RateLimitStrategy implements FlowControlStrategy {
|
|
59
|
+
readonly name = "rate-limit";
|
|
60
|
+
evaluate(context: FlowControlContext): BackpressureDecision;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 優先級平衡策略。
|
|
64
|
+
*
|
|
65
|
+
* 在 WARNING 和 CRITICAL 狀態下降級低優先級事件,防止高優先級飢餓。
|
|
66
|
+
*/
|
|
67
|
+
export declare class PriorityRebalanceStrategy implements FlowControlStrategy {
|
|
68
|
+
readonly name = "priority-rebalance";
|
|
69
|
+
evaluate(context: FlowControlContext): BackpressureDecision;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 反飢餓保護策略。
|
|
73
|
+
*
|
|
74
|
+
* 防止低優先級事件被長期壓制。
|
|
75
|
+
* 當事件等待超過 starvationTimeoutMs 時,自動提升其優先級。
|
|
76
|
+
*/
|
|
77
|
+
export declare class StarvationProtectionStrategy implements FlowControlStrategy {
|
|
78
|
+
readonly name = "starvation-protection";
|
|
79
|
+
evaluate(_context: FlowControlContext): BackpressureDecision;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 組合策略。
|
|
83
|
+
*
|
|
84
|
+
* 組合多個策略。評估時所有子策略必須允許,否則拒絕。
|
|
85
|
+
* 取最嚴格的決策(拒絕 > 延遲 > 允許)。
|
|
86
|
+
*/
|
|
87
|
+
export declare class CompositeStrategy implements FlowControlStrategy {
|
|
88
|
+
readonly name: string;
|
|
89
|
+
private strategies;
|
|
90
|
+
constructor(name: string, strategies: FlowControlStrategy[]);
|
|
91
|
+
evaluate(context: FlowControlContext): BackpressureDecision;
|
|
92
|
+
/**
|
|
93
|
+
* 新增子策略。
|
|
94
|
+
*/
|
|
95
|
+
addStrategy(strategy: FlowControlStrategy): void;
|
|
96
|
+
/**
|
|
97
|
+
* 移除指定名稱的子策略。
|
|
98
|
+
*/
|
|
99
|
+
removeStrategy(name: string): boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 工廠方法:建立預設流控策略組合。
|
|
103
|
+
*
|
|
104
|
+
* @param config 背壓配置
|
|
105
|
+
* @returns 組合策略實例
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export declare function createDefaultStrategies(_config: Omit<BackpressureConfig, 'onRejected' | 'onStateChange'>): FlowControlStrategy[];
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gravito/core - Message Queue Bridge
|
|
3
|
+
*
|
|
4
|
+
* 橋接層,連接 HookManager 與 Bull Queue (via StreamEventBackend)
|
|
5
|
+
* 支持分佈式事件流:HookManager → Bull Queue → Worker → 完成/DLQ
|
|
6
|
+
*/
|
|
7
|
+
import type { HookManager } from '../HookManager';
|
|
8
|
+
import type { DeadLetterQueueManager } from '../reliability/DeadLetterQueueManager';
|
|
9
|
+
import type { EventBackend } from './EventBackend';
|
|
10
|
+
import type { EventTask } from './types';
|
|
11
|
+
import type { WorkerPool } from './WorkerPool';
|
|
12
|
+
/**
|
|
13
|
+
* 事件執行狀態
|
|
14
|
+
*/
|
|
15
|
+
export interface EventStatus {
|
|
16
|
+
eventId: string;
|
|
17
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'in_dlq';
|
|
18
|
+
attempts: number;
|
|
19
|
+
lastError?: string;
|
|
20
|
+
createdAt: number;
|
|
21
|
+
processedAt?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* MessageQueueBridge 配置
|
|
25
|
+
*/
|
|
26
|
+
export interface MessageQueueBridgeConfig {
|
|
27
|
+
/**
|
|
28
|
+
* HookManager 實例
|
|
29
|
+
*/
|
|
30
|
+
hookManager: HookManager;
|
|
31
|
+
/**
|
|
32
|
+
* Worker 線程池(可選)
|
|
33
|
+
*/
|
|
34
|
+
workerPool?: WorkerPool;
|
|
35
|
+
/**
|
|
36
|
+
* 分佈式事件後端(Bull Queue)
|
|
37
|
+
*/
|
|
38
|
+
eventBackend: EventBackend;
|
|
39
|
+
/**
|
|
40
|
+
* Dead Letter Queue 管理器
|
|
41
|
+
*/
|
|
42
|
+
dlqManager: DeadLetterQueueManager;
|
|
43
|
+
/**
|
|
44
|
+
* 是否啟用 CircuitBreaker 檢查
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
enableCircuitBreaker?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* MessageQueueBridge - 連接 HookManager 與 Bull Queue 的橋接層
|
|
51
|
+
*
|
|
52
|
+
* 功能:
|
|
53
|
+
* 1. 通過 Bull Queue 分發事件(dispatchWithQueue)
|
|
54
|
+
* 2. Worker 中處理隊列事件(processQueuedEvent)
|
|
55
|
+
* 3. 失敗任務轉移至 DLQ(handleJobFailure)
|
|
56
|
+
* 4. 查詢事件執行狀態(getEventStatus)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const bridge = new MessageQueueBridge({
|
|
61
|
+
* hookManager,
|
|
62
|
+
* eventBackend: streamEventBackend,
|
|
63
|
+
* dlqManager,
|
|
64
|
+
* enableCircuitBreaker: true
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* // 分發事件至 Bull Queue
|
|
68
|
+
* const jobId = await bridge.dispatchWithQueue('order:created', { orderId: 123 })
|
|
69
|
+
*
|
|
70
|
+
* // Worker 處理事件
|
|
71
|
+
* await bridge.processQueuedEvent(jobId, task)
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare class MessageQueueBridge {
|
|
75
|
+
private config;
|
|
76
|
+
constructor(config: MessageQueueBridgeConfig);
|
|
77
|
+
/**
|
|
78
|
+
* 通過 Bull Queue 分發事件(分佈式異步處理)
|
|
79
|
+
*
|
|
80
|
+
* 流程:
|
|
81
|
+
* 1. 驗證事件 listeners 存在
|
|
82
|
+
* 2. 檢查 CircuitBreaker 狀態(如果啟用)
|
|
83
|
+
* 3. 構建 EventTask
|
|
84
|
+
* 4. 入隊到 eventBackend (Bull Queue)
|
|
85
|
+
*
|
|
86
|
+
* @param eventName - 事件名稱
|
|
87
|
+
* @param args - 事件參數
|
|
88
|
+
* @param options - 事件選項(可選)
|
|
89
|
+
* @returns Job ID
|
|
90
|
+
* @throws 如果沒有 listeners 或 CircuitBreaker 打開
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const jobId = await bridge.dispatchWithQueue('order:created', {
|
|
95
|
+
* orderId: 'ORD-123',
|
|
96
|
+
* amount: 999.99
|
|
97
|
+
* })
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
dispatchWithQueue<TArgs = unknown>(eventName: string, args: TArgs, options?: any): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* 處理隊列事件(由 Bull Queue Worker 調用)
|
|
103
|
+
*
|
|
104
|
+
* 重要:使用 doActionSync() 避免遞迴
|
|
105
|
+
* - 不能使用 doActionAsync()(會導致事件再次入隊)
|
|
106
|
+
* - Worker 中直接同步執行 callbacks
|
|
107
|
+
*
|
|
108
|
+
* 流程:
|
|
109
|
+
* 1. 直接執行 callbacks(不使用 doActionSync,避免吞掉錯誤)
|
|
110
|
+
* 2. 記錄成功或失敗
|
|
111
|
+
* 3. 拋出錯誤讓 Bull Queue 處理重試
|
|
112
|
+
*
|
|
113
|
+
* @param jobId - Bull Queue Job ID
|
|
114
|
+
* @param task - 事件任務
|
|
115
|
+
* @throws 如果 callback 執行失敗,讓 Bull Queue 處理重試
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // 在 Bull Queue Worker 中:
|
|
120
|
+
* await bridge.processQueuedEvent(jobId, task)
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
processQueuedEvent(jobId: string, task: EventTask): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* 處理 Bull Queue 任務失敗(由 onFailed callback 調用)
|
|
126
|
+
*
|
|
127
|
+
* 流程:
|
|
128
|
+
* 1. 記錄警告日誌
|
|
129
|
+
* 2. 移至 persistent DLQ(DeadLetterQueueManager)
|
|
130
|
+
* 3. 持久化到 event_dlq 表,支持延遲重試
|
|
131
|
+
*
|
|
132
|
+
* @param jobId - Bull Queue Job ID
|
|
133
|
+
* @param task - 事件任務
|
|
134
|
+
* @param error - 導致失敗的錯誤
|
|
135
|
+
* @param retryCount - 已重試次數(可選)
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* // 在 Bull Queue onFailed callback 中:
|
|
140
|
+
* await bridge.handleJobFailure(jobId, task, error, 3)
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
handleJobFailure(jobId: string, task: EventTask, error: Error, retryCount?: number): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* 查詢事件執行狀態
|
|
146
|
+
*
|
|
147
|
+
* 支持查詢:
|
|
148
|
+
* 1. 待處理事件
|
|
149
|
+
* 2. 正在處理的事件
|
|
150
|
+
* 3. 已完成事件
|
|
151
|
+
* 4. 失敗事件(在 DLQ 中)
|
|
152
|
+
*
|
|
153
|
+
* @param eventId - 事件 ID(task.id 或 jobId)
|
|
154
|
+
* @returns 事件狀態
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const status = await bridge.getEventStatus('queue-1707000000000-abc123')
|
|
159
|
+
* console.log(status) // { eventId, status, attempts, ... }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
getEventStatus(eventId: string): Promise<EventStatus>;
|
|
163
|
+
/**
|
|
164
|
+
* 獲取 EventBackend 實例(用於高級操作)
|
|
165
|
+
*
|
|
166
|
+
* @returns EventBackend 實例
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
getEventBackend(): EventBackend;
|
|
170
|
+
/**
|
|
171
|
+
* 獲取 DLQ 管理器實例(用於高級操作)
|
|
172
|
+
*
|
|
173
|
+
* @returns DeadLetterQueueManager 實例
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
getDLQManager(): DeadLetterQueueManager;
|
|
177
|
+
/**
|
|
178
|
+
* 獲取 HookManager 實例(用於高級操作)
|
|
179
|
+
*
|
|
180
|
+
* @returns HookManager 實例
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
getHookManager(): HookManager;
|
|
184
|
+
}
|