simple

Implements SimpleProducer, a file-based producer for local development and testing.

class unistream.producers.simple.SimpleProducer(buffer: AbcBuffer = REQ, retry_config: RetryConfig = REQ, path_sink: Path = REQ)[source]

A simple producer that write data to a local, append-only file.

It is a good example to show how to implement a producer and understand the behavior of the producer.

You should use this producer along with SimpleConsumer

Note

Don’t initialize this class directly, use the SimpleProducer.new() method

Parameters:

path_sink – the path of the file you want to write data to.

classmethod new(buffer: AbcBuffer, retry_config: RetryConfig, path_sink: Path)[source]

Create a SimpleProducer instance.

Parameters:
  • record_class – the record class.

  • path_sink – the path of the file you want to write data to.

  • buffer – the buffer you want to use.

  • retry_config – the retry configuration.

send(records: list[AbcRecord])[source]

Send records to the sink, which is an append-only file