Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Consumer<T>

Type parameters

  • T

Hierarchy

  • Consumer

Index

Constructors

constructor

  • new Consumer(uri: string, stream: string, group: string, consumer: string): Consumer
  • new Consumer(uri: string, stream: string, group: string, consumer: string, opts: ConsumerOptions): Consumer
  • new Consumer(client: Redis, stream: string, group: string, consumer: string): Consumer
  • new Consumer(client: Redis, stream: string, group: string, consumer: string, opts: ConsumerOptions): Consumer
  • Creates a new Consumer.

    Parameters

    • uri: string

      The uri of the Redis server.

    • stream: string

      The name of the stream to read from.

    • group: string

      The name of the group to attach to.

    • consumer: string

      The name of the consumer to identify as.

    Returns Consumer

  • Creates a new Consumer.

    Parameters

    • uri: string

      The uri of the Redis server.

    • stream: string

      The name of the stream to read from.

    • group: string

      The name of the group to attach to.

    • consumer: string

      The name of the consumer to identify as.

    • opts: ConsumerOptions

      The options for the consumer.

    Returns Consumer

  • Creates a new Consumer.

    Parameters

    • client: Redis

      An IORedis client instance.

    • stream: string

      The name of the stream to read from.

    • group: string

      The name of the group to attach to.

    • consumer: string

      The name of the consumer to identify as.

    Returns Consumer

  • Creates a new Consumer.

    Parameters

    • client: Redis

      An IORedis client instance.

    • stream: string

      The name of the stream to read from.

    • group: string

      The name of the group to attach to.

    • consumer: string

      The name of the consumer to identify as.

    • opts: ConsumerOptions

      The options for the consumer.

    Returns Consumer

Properties

Private block

block: number

Private checkBacklog

checkBacklog: boolean = true

Private client

client: Redis

Private consumer

consumer: string

The name of the consumer to identify as.

Private count

count: number

Private from

from: string

Private group

group: string

The name of the group to attach to.

Private reading

reading: boolean = false

Private running

running: boolean = true

Private stream

stream: string

The name of the stream to read from.

Methods

__@asyncIterator

  • __@asyncIterator(): AsyncIterableIterator<[string, T]>
  • Iterates over the consumer, asynchronously yielding messages in an [id, data] pair.

    Returns AsyncIterableIterator<[string, T]>

Private _ensureGroup

  • _ensureGroup(): Promise<void>

Private _iterate

  • _iterate(): AsyncIterableIterator<[string, T]>

Private _read

  • _read(fromId: Id): Promise<null | [string, T][]>
  • Parameters

    • fromId: Id

    Returns Promise<null | [string, T][]>

ack

  • ack(id: Id): Promise<void>
  • Acknowledges successful message delivery by id, removing the message from the pending entries list on the server.

    Parameters

    • id: Id

      The id of the message.

    Returns Promise<void>

claim

  • Claims pending messages to be re-delievered to this consumer.

    Noting that even though the claimed messages are returned by the server, they will still be re-delivered during normal iteration.

    Parameters

    • ids: Id[]

      The ids of the pending messages to claim.

    Returns Promise<Array<DeserializedPair<T>>>

    A list of [id, data] pairs which were claimed.

deleteConsumer

  • deleteConsumer(): Promise<void>
  • Deletes the consumer from the consumer group.

    Any delievered but unacked messages for this consumer will be discarded from the server.

    Returns Promise<void>

disconnect

  • disconnect(): void
  • Immediately disconnects from the wrapped Redis client.

    Returns void

on

  • on(name: string, callback: listener): Redis
  • Attaches an event handler to the wrapped Redis client.

    Parameters

    • name: string
    • callback: listener

      The handler for the event.

    Returns Redis

pending

  • pending(start?: string, end?: string, length?: number): Promise<Pending[]>
  • Returns a list of pending messages for the consumer group.

    Parameters

    • Default value start: string = "-"

      The id to start at.

    • Default value end: string = "+"

      The id to end at.

    • Default value length: number = 100

      The max length of pending messages to return.

    Returns Promise<Pending[]>

    A list of pending messages, along with their metadata.

shutdown

  • shutdown(): void
  • Allows for graceful shutdown of the consumer, setting up a disconnect to be run after pending messages can be acked.

    Returns void

Generated using TypeDoc