Abstract

BaseRedisBroker

export declare abstract class BaseRedisBroker<TEvents extends Record<string, any>> extends AsyncEventEmitter<ToEventMap<TEvents>> implements IBaseBroker<TEvents>
export declare abstract class BaseRedisBroker<TEvents extends Record<string, any>> extends AsyncEventEmitter<ToEventMap<TEvents>> implements IBaseBroker<TEvents>
Helper class with shared Redis logic

Extends

AsyncEventEmitter<ToEventMap<TEvents>>

Implements

IBaseBroker<TEvents>
NameConstraintsOptionalDefaultDescription
TEventsRecord<string, any>NoNone
constructor(options)
Constructs a new instance of the BaseRedisBroker class
NameTypeOptionalDescription
optionsRedisBrokerOptionsNoNone
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, group, event, data):unknown
Handles an incoming Redis event
NameTypeOptionalDescription
idBufferNoNone
groupstringNoNone
eventstringNoNone
dataunknownNoNone
Protected
listen(group):Promise<void>
Begins polling for events, firing them to listen
NameTypeOptionalDescription
groupstringNoNone
subscribe(group, events):Promise<void>
Subscribes to the given events, grouping them by the given group name
NameTypeOptionalDescription
groupstringNoNone
events(keyof TEvents)[]NoNone
unsubscribe(group, events):Promise<void>
Unsubscribes from the given events - it's required to pass the same group name as when subscribing for proper cleanup
NameTypeOptionalDescription
groupstringNoNone
events(keyof TEvents)[]NoNone