class BaseRedisBroker

implements

IBaseBroker<TEvents>

extends

AsyncEventEmitter<ToEventMap<TEvents>>
abstract
export declare abstract class BaseRedisBroker<TEvents extends Record<string, any>> extends AsyncEventEmitter<ToEventMap<TEvents>> implements IBaseBroker<TEvents>

Helper class with shared Redis logic

Constructors

constructor()

Constructs a new instance of the BaseRedisBroker class

Type Parameters

TEvents extends Record<string, any>

protected
listening : boolean

Whether this broker is currently polling events

protectedreadonly
options : Required<RedisBrokerOptions>

Options this broker is using

staticreadonly
STREAM_DATA_KEY :

Used for Redis queues, see the 3rd argument taken by xadd

protectedreadonly
streamReadClient : Redis

Internal copy of the Redis client being used to read incoming payloads

protectedreadonly
subscribedEvents : Set<string>

Events this broker has subscribed to

destroy() : Promise<void>

Destroys the broker, closing all connections

protectedabstract
emitEvent(
id: Buffer
group: string
event: string
data: unknown
) : unknown

Handles an incoming Redis event

protected
listen(
group: string
) : Promise<void>

Begins polling for events, firing them to listen

subscribe(
group: string
events: (keyof TEvents)[]
) : Promise<void>

Subscribes to the given events, grouping them by the given group name

unsubscribe(
group: string
events: (keyof TEvents)[]
) : Promise<void>

Unsubscribes from the given events - it's required to pass the same group name as when subscribing for proper cleanup