Node.js

This client uses node-bindgen to wrap the rust client. It supports most administrator features. The blocking calls to fluvio return promises allowing for async on blocking fluvio calls.

The PartitionConsumer.createStream call returns an asyncIterator to allow iterating over the stream in a for-loop.

To see the full docs, visit our typedoc page.

 

Connect

To connect to fluvio do:

import Fluvio from '@fluvio/client';
const fluvio = await Fluvio.connect();
 

Produce

To create a producer do:

const producer = await fluvio.topicProducer("my-topic");
 

Send

To send a record for a producer do:

producer.send("my-key", "my-value");

Note: The send call can take either an ArrayBuffer or a string for the key/value fields in send.

 

Consume

To get a consumer do:

const partition = 0;
const consumer = await fluvio.partitionConsumer("my-topic", partition)
 

Stream

To iterate over the items in a consumer do create a stream and iterate over it like this:

const stream = await consumer.createStream(Offset.FromBeginning());
for await (const record of stream) {
    let value = record.valueString();
    let key = record.keyString();
    console.log(`${key} - ${value});
}