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>Name | Constraints | Optional | Default | Description |
---|---|---|---|---|
TEvents | Record<string, any> | No | None |
constructor(options)
Constructs a new instance of the
BaseRedisBroker
className | Type | Optional | Description |
---|---|---|---|
options | RedisBrokerOptions | No | None |
listening
:
boolean
Whether this broker is currently polling events
Readonly
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
Name | Type | Optional | Description |
---|---|---|---|
id | Buffer_2 | No | None |
group | string | No | None |
event | string | No | None |
data | unknown | No | None |
Protected
listen(group)
:
Promise<void>
Begins polling for events, firing them to listen
Name | Type | Optional | Description |
---|---|---|---|
group | string | No | None |
subscribe(group, events)
:
Promise<void>
Subscribes to the given events, grouping them by the given group name
Name | Type | Optional | Description |
---|---|---|---|
group | string | No | None |
events | (keyof TEvents)[] | No | None |
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
Name | Type | Optional | Description |
---|---|---|---|
group | string | No | None |
events | (keyof TEvents)[] | No | None |