Options
All
  • Public
  • Public/Protected
  • All
Menu

Overview

An interface for consuming events from a particular partition

There are two ways to consume events: by "fetching" events and by "streaming" events. Fetching involves specifying a range of events that you want to consume via their Offset.

A fetch is a sort of one-time batch operation: you'll receive all of the events in your range all at once.

When you consume events via Streaming, you specify a starting Offset and receive an object that will continuously yield new events as they arrive.

Example Construction

Do not call this constructor manually, instead use the method below:

const fluvio = new Fluvio({ host, port })

const partition = 0;

await fluvio.connect();
const consumer = await fluvio.partitionConsumer("topic-name", partition);

This class constructor is used internally by the Fluvio client to provision a topic producer.

The inner object is a private object that is the native module created by the top-level Fluvio client.

This class is not intended to be constructed manually.

Hierarchy

  • PartitionConsumer

Index

Constructors

Properties

Methods

Constructors

Private constructor

  • This method is not intended to be used directly. This is a helper method used by the Fluvio class to pass in a native object, along with top-level Fluvio client options, if any.

    Parameters

    • inner: PartitionConsumer

      The native node module created by new Fluvio().connect().partitionConsumer()

    Returns PartitionConsumer

Properties

Private inner

inner: any

Methods

createStream

  • createStream(offset: Offset): Promise<AsyncIterable<Record>>
  • This returns an AsyncIterable. Usage:

    const stream = await consumer.getIterator(Offset.FromBeginning())
    for await (const next of stream) {
        console.log(next)
    }
    

    Parameters

    Returns Promise<AsyncIterable<Record>>

endStream

  • endStream(): Promise<void>

fetch

  • Parameters

    Returns Promise<FetchablePartitionResponse>

  • Fetches events from a particular offset in the consumer's partition

    A "fetch" is one of the two ways to consume events in Fluvio. It is a batch request for records from a particular offset in the partition.

    You specify the position of records to retrieve using an Offset, and receive the events as a list of records.

    Parameters

    • Optional offset: Offset

      Describes the location of an event stored in a Fluvio partition

    Returns Promise<FetchablePartitionResponse>

stream

  • stream(offset: Offset, cb: (record: Record) => void): Promise<void>
  • stream(offset: Offset, cb: (record: Record) => void): Promise<void>

Static create

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Private property
  • Private method
  • Static method

Generated using TypeDoc