Metadata-Version: 2.3
Name: bytewax-valkey
Version: 0.2.0
Summary: Valkey connectors for Bytewax
Project-URL: Repository, https://github.com/imnotjames/bytewax-valkey.git
Project-URL: Issues, https://github.com/imnotjames/bytewax-valkey/issues
Author-email: James Ward <james@notjam.es>
License: MIT License
        
        Copyright (c) 2024 James Ward
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Keywords: bytewax,valkey
Requires-Python: >=3.12
Requires-Dist: bytewax>=0.21.0
Requires-Dist: valkey>=6.0.2
Description-Content-Type: text/markdown

[![PyPI](https://img.shields.io/pypi/v/bytewax-valkey.svg?style=flat-square)][pypi-package]

# Bytewax Valkey

[Valkey][valkey] connectors for [Bytewax][bytewax].

This connector offers 2 sources and 2 sinks:

* `StreamSink` - writes [Valkey streams][valkey-streams] using `xadd`
* `StreamSource` - reads [Valkey streams][valkey-streams] using `xread`
* `PubSubSink` - writes [Valkey pubsub][valkey-pubsub] using `publish`
* `PubSubSource` - reads [Valkey pubsub][valkey-pubsub] using `subscribe`

## Installation

This package is available via [PyPi][pypi-package] as
`bytewax-valkey` and can be installed via your package manager of choice.

## Usage

### Pub/Sub Source

```python
import os

from bytewax_valkey import PubSubSource
from bytewax.connectors.stdio import StdOutSink

import bytewax.operators as op
from bytewax.dataflow import Dataflow

VALKEY_URL = os.environ["VALKEY_URL"]

flow = Dataflow("valkey_example")
flow_input = op.input("input", flow, PubSubSource.from_url(VALKEY_URL, "example"))
op.output("output", flow_input, StdOutSink())
```

### Pub/Sub Sink

```python
import os

from bytewax_valkey import PubSubSink
from bytewax.testing import TestingSource

import bytewax.operators as op
from bytewax.dataflow import Dataflow

VALKEY_URL = os.environ["VALKEY_URL"]

flow = Dataflow("valkey_example")
flow_input = op.input("input", flow, TestingSource([b"example message"]))
op.output("output", flow_input, PubSubSink.from_url(VALKEY_URL, "example"))
```

### Stream Source

```python
import os

from bytewax_valkey import StreamSource
from bytewax.connectors.stdio import StdOutSink

import bytewax.operators as op
from bytewax.dataflow import Dataflow

VALKEY_URL = os.environ["VALKEY_URL"]

flow = Dataflow("valkey_example")
flow_input = op.input("input", flow, StreamSource.from_url(VALKEY_URL, "example"))
op.output("output", flow_input, StdOutSink())
```

### Stream Sink

```python
import os

from bytewax_valkey import StreamSink
from bytewax.testing import TestingSource

import bytewax.operators as op
from bytewax.dataflow import Dataflow

VALKEY_URL = os.environ["VALKEY_URL"]

flow = Dataflow("valkey_example")
flow_input = op.input("input", flow, TestingSource([{"key": "value"}]))
op.output("output", flow_input, StreamSink.from_url(VALKEY_URL, "example"))
```

## License

Licensed under the [MIT License](./LICENSE).

[valkey]: https://valkey.io
[bytewax]: https://bytewax.io
[valkey-streams]: https://valkey.io/topics/streams-intro/
[valkey-pubsub]: https://valkey.io/topics/pubsub/
[pypi-package]: https://pypi.org/project/bytewax-valkey