Skip to content

Redis streams

Spout for Redis streams

Bases: Spout

__init__(output, state, **kwargs)

Initialize the RedisStream class.

Parameters:

Name Type Description Default
output StreamingOutput

An instance of the StreamingOutput class for saving the data.

required
state State

An instance of the State class for maintaining the state.

required
**kwargs

Additional keyword arguments.

{}

Using geniusrise to invoke via command line

genius RedisStream rise \
    streaming \
        --output_kafka_topic redis_stream_test \
        --output_kafka_cluster_connection_string localhost:9094 \
    none \
    listen \
        --args stream_key=my_stream host=localhost port=6379 db=0

Using geniusrise to invoke via YAML file

version: "1"
spouts:
    my_redis_stream:
        name: "RedisStream"
        method: "listen"
        args:
            stream_key: "my_stream"
            host: "localhost"
            port: 6379
            db: 0
        output:
            type: "streaming"
            args:
                output_topic: "redis_stream_test"
                kafka_servers: "localhost:9094"

listen(stream_key, host='localhost', port=6379, db=0, password=None)

📖 Start the asyncio event loop to listen for data from the Redis stream.

Parameters:

Name Type Description Default
stream_key str

The Redis stream key to listen to.

required
host str

The Redis server host. Defaults to "localhost".

'localhost'
port int

The Redis server port. Defaults to 6379.

6379
db int

The Redis database index. Defaults to 0.

0
password Optional[str]

The password for authentication. Defaults to None.

None