Abstract

BaseRedisBroker

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>
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

Extends

AsyncEventEmitter<ToEventMap<TEvents, TResponses>>

Implements

IBaseBroker<TEvents>
NameConstraintsOptionalDefaultDescription
TEventsRecord<string, any[]>NoNone
TResponsesRecord<keyof TEvents, any> | undefinedYesundefinedNone
constructor(redisClient, options)
Constructs a new instance of the BaseRedisBroker class
NameTypeOptionalDescription
redisClientRedisNoNone
optionsRedisBrokerOptionsNoNone
Protected
listening:boolean
Whether this broker is currently polling events
ProtectedReadonly
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, group, event, data):unknown
Handles an incoming Redis event
NameTypeOptionalDescription
idBufferNoNone
groupstringNoNone
eventstringNoNone
dataunknownNoNone
Protected
listen():Promise<void>
Begins polling for events, firing them to listen
subscribe(events):Promise<void>
Subscribes to the given events
NameTypeOptionalDescription
events(keyof TEvents)[]NoNone
unsubscribe(events):Promise<void>
Unsubscribes from the given events
NameTypeOptionalDescription
events(keyof TEvents)[]NoNone