bytewax_redis.sinks#
Sinks for Redis.
Classes#
- class RedisStreamSink(stream_name: str, host: str, port: int, db: int)#
- Bases:
DynamicSink[dict[FieldT,EncodableT]]
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_nameargument.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( ) bytewax_redis.sinks._RedisStreamSinkPartition#
Build a stateless sink partition for each worker.
This method creates a
_RedisStreamSinkPartitionfor 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
_RedisStreamSinkPartitionobject for writing data to the Redis stream.
- class RedisKVSink(host: str = 'localhost', port: int = 6379, db: int = 0)#
- Bases:
DynamicSink[tuple[Any,Any]]
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( ) bytewax_redis.sinks._RedisKVSinkPartition#
Build a stateless sink partition for each worker.
This creates a
_RedisKVSinkPartitionfor 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
_RedisKVSinkPartitionobject for writing key-value pairs to Redis.