Python

The python client wraps the rust client and uses nearly the exact same function definitions. It currently does not support the administrator features that the rust client does. Handling async runners across the rust FFI is a bit tricky so for now, this client does not support async python.

The PartitionConsumer.stream returns an object which implements python iterator convention to allow for iterating over the stream in a for-loop.

To see the full docs, visit our pdoc page.

 

Connect

To connect to fluvio do:

from fluvio import Fluvio
fluvio = Fluvio.connect()
 

Produce

To get a producer do:

producer = fluvio.topic_producer("my-topic")
 

Send

To send a record for the producer do:

partition = 0
producer.send_record_string("my-record", partition)

send is also available. You will need to convert your key/value into a byte array first to use it.

 

Consumer

To get a consumer, do:

partition = 0
consumer = fluvio.partition_consumer("my-topic", partition)
 

Stream

To get a stream from the consumer do:

stream = consumer.stream(Offset.beginning())
for i in stream:
    key = i.key_string()
    value = i.value_string()
    print("%s - %s" % (key, value))