bytewax_redis.sinks#

Sinks for Redis.

Classes#

class RedisStreamSink(stream_name: str, host: str, port: int, db: int)#
Bases:

Redis stream sink.

This sink takes a stream of dictionaries containing key-value pairs that will be sent to a redis stream defined by the stream_name argument.

Initialization

Initialize the Redis stream sink.

Parameters:
  • stream_name – The name of the Redis stream to write to.

  • host – Redis server hostname.

  • port – Redis server port.

  • db – Redis database index.

build(
step_id: str,
worker_index: int,
worker_count: int,
) bytewax_redis.sinks._RedisStreamSinkPartition#

Build a stateless sink partition for each worker.

This method creates a _RedisStreamSinkPartition for each worker in the dataflow. Each worker will independently write messages to the Redis stream.

Parameters:
  • step_id – The ID of the current dataflow step.

  • worker_index – The index of the current worker.

  • worker_count – The total number of workers in the dataflow.

Returns:

A _RedisStreamSinkPartition object for writing data to the Redis stream.

class RedisKVSink(host: str = 'localhost', port: int = 6379, db: int = 0)#
Bases:

Redis key-value sink.

This sink take a stream of (key, value) 2-tuples, and writes every key to the specified Redis instance.

Initialization

Initialize the Redis key-value dynamic sink.

Parameters:
  • host – Redis server hostname.

  • port – Redis server port.

  • db – Redis database index.

build(
step_id: str,
worker_index: int,
worker_count: int,
) bytewax_redis.sinks._RedisKVSinkPartition#

Build a stateless sink partition for each worker.

This creates a _RedisKVSinkPartition for each worker in the dataflow. Each worker will independently write key-value pairs to Redis.

Parameters:
  • step_id – The ID of the current dataflow step.

  • worker_index – The index of the current worker.

  • worker_count – The total number of workers in the dataflow.

Returns:

A _RedisKVSinkPartition object for writing key-value pairs to Redis.

Join our community Slack channel

Need some help? Join our community!

If you have any trouble with the process or have ideas about how to improve this document, come talk to us in the #questions-answered Slack channel!

Join now