UBERF-9694: Queue processing improvements (#8418)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-04-02 00:15:06 +07:00
committed by GitHub
parent 19ea34f260
commit 08434ccb3c
20 changed files with 1240 additions and 407 deletions
+6 -2
View File
@@ -22,7 +22,7 @@ class DummyQueueProducer<T> implements PlatformQueueProducer<T> {
* A dummy implementation of PlatformQueue for testing and development
*/
export class DummyQueue implements PlatformQueue {
createProducer<T>(ctx: MeasureContext, topic: QueueTopic): PlatformQueueProducer<T> {
createProducer<T>(ctx: MeasureContext, topic: QueueTopic | string): PlatformQueueProducer<T> {
return new DummyQueueProducer<T>()
}
@@ -30,9 +30,11 @@ export class DummyQueue implements PlatformQueue {
return 'dummy'
}
async shutdown (): Promise<void> {}
createConsumer<T>(
ctx: MeasureContext,
topic: QueueTopic,
topic: QueueTopic | string,
groupId: string,
onMessage: (
msg: { id: WorkspaceUuid | string, value: T }[],
@@ -59,6 +61,8 @@ export class DummyQueue implements PlatformQueue {
async createTopics (tx: number): Promise<void> {
await Promise.resolve()
}
async deleteTopics (topics?: (QueueTopic | string)[]): Promise<void> {}
}
/**
+8 -2
View File
@@ -30,7 +30,7 @@ export interface ConsumerControl {
}
export interface PlatformQueue {
createProducer: <T>(ctx: MeasureContext, topic: QueueTopic) => PlatformQueueProducer<T>
createProducer: <T>(ctx: MeasureContext, topic: QueueTopic | string) => PlatformQueueProducer<T>
/**
* Create a consumer for a topic.
@@ -38,7 +38,7 @@ export interface PlatformQueue {
*/
createConsumer: <T>(
ctx: MeasureContext,
topic: QueueTopic,
topic: QueueTopic | string,
groupId: string,
onMessage: (msg: ConsumerMessage<T>[], queue: ConsumerControl) => Promise<void>,
options?: {
@@ -47,7 +47,13 @@ export interface PlatformQueue {
) => ConsumerHandle
createTopics: (tx: number) => Promise<void>
// If not passed will delete all topica from QueueTopic enum
deleteTopics: (topics?: (QueueTopic | string)[]) => Promise<void>
getClientId: () => string
// Will close all producers and consumers
shutdown: () => Promise<void>
}
/**