UNPKG

@allgemein/eventbus

Version:
60 lines (50 loc) 2.92 kB
import { IReader } from '../IReader'; import { IRedisOptions } from './IRedisOptions'; import { IRedisMessage } from './IRedisMessage'; import { AbstractRedisConnection } from './AbstractRedisConnection'; export declare class RedisReader extends AbstractRedisConnection implements IReader { topic: string; /** * identifies the instance (nodeId) */ channel: string; redisChannel: string; constructor(topic: string, channel: string, options: IRedisOptions); close(): Promise<void>; /** Subscriber Events If a client has subscriptions active, it may emit these events: "message" (channel, message) Client will emit message for every message received that matches an active subscription. Listeners are passed the channel name as channel and the message as message. "pmessage" (pattern, channel, message) Client will emit pmessage for every message received that matches an active subscription pattern. Listeners are passed the original pattern used with PSUBSCRIBE as pattern, the sending channel name as channel, and the message as message. "message_buffer" (channel, message) This is the same as the message event with the exception, that it is always going to emit a buffer. If you listen to the message event at the same time as the message_buffer, it is always going to emit a string. "pmessage_buffer" (pattern, channel, message) This is the same as the pmessage event with the exception, that it is always going to emit a buffer. If you listen to the pmessage event at the same time as the pmessage_buffer, it is always going to emit a string. "subscribe" (channel, count) Client will emit subscribe in response to a SUBSCRIBE command. Listeners are passed the channel name as channel and the new count of subscriptions for this client as count. "psubscribe" (pattern, count) Client will emit psubscribe in response to a PSUBSCRIBE command. Listeners are passed the original pattern as pattern, and the new count of subscriptions for this client as count. "unsubscribe" (channel, count) Client will emit unsubscribe in response to a UNSUBSCRIBE command. Listeners are passed the channel name as channel and the new count of subscriptions for this client as count. When count is 0, this client has left subscriber mode and no more subscriber events will be emitted. "punsubscribe" (pattern, count) Client will emit punsubscribe in response to a PUNSUBSCRIBE command. Listeners are passed the channel name as channel and the new count of subscriptions for this client as count. When count is 0, this client has left subscriber mode and no more subscriber events will be emitted. */ open(): Promise<true>; subscribe(callback: (msg: IRedisMessage) => void): void; private onPMessage; }