Search...

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

listening

:

boolean

Whether this broker is currently polling events
Readonly

options

:

Required<RedisBrokerOptions>

Options this broker is using
Readonly

STREAM_DATA_KEY

:

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

streamReadClient

:

Redis

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

subscribedEvents

:

Set<string>

Events this broker has subscribed to

destroy()

:

Promise<void>

Destroys the broker, closing all connections
Protected

emitEvent(id, group, event, data)

:

unknown

Handles an incoming Redis event
NameTypeOptionalDescription
idBuffer_2NoNone
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