mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 12:04:56 +02:00
UBERF-9694: Queue processing improvements (#8418)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -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> {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user