class BaseRedisBroker

implements

IBaseBroker<TEvents>

extends

AsyncEventEmitter<ToEventMap<TEvents, TResponses>>
abstract
export declare abstract class BaseRedisBroker<TEvents extends Record<string, any[]>, TResponses extends Record<keyof TEvents, any> | undefined = undefined> extends AsyncEventEmitter<ToEventMap<TEvents, TResponses>> implements IBaseBroker<TEvents>

Helper class with shared Redis logic

Constructors

constructor(
redisClient: Redis
)

Constructs a new instance of the BaseRedisBroker class

Type Parameters

TEvents extends Record<string, any[]>

optional
TResponses? extends Record<keyof TEvents, any> | undefined = undefined

protected
listening : boolean

Whether this broker is currently polling events

protectedreadonly
options : Required<RedisBrokerOptions>

Options this broker is using

protectedreadonly
redisClient : Redis

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() : Promise<void>

Begins polling for events, firing them to listen

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

Subscribes to the given events

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

Unsubscribes from the given events