Class PartitionConsumer

Partition Consumer

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.

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.

Methods

  • Parameters

    Returns 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>>

  • Returns Promise<void>

  • Parameters

    • offset: Offset
    • cb: ((record: Record) => void)
        • (record): void
        • Parameters

          Returns void

    Returns Promise<void>

  • Parameters

    • offset: Offset
    • cb: ((record: Record) => void)
        • (record): void
        • Parameters

          Returns void

    Returns Promise<void>