Metadata-Version: 2.1
Name: superstream-beta
Version: 1.0.3
Summary: Default template for PDM package
Author-Email: Dev <placeholder@temp.mail>
License: MIT
Requires-Python: >=3.8
Requires-Dist: pydantic>=2.6.3
Requires-Dist: nats-py>=2.7.2
Requires-Dist: protobuf>=4.25.3
Requires-Dist: asyncio>=3.4.3
Requires-Dist: confluent-kafka>=2.3.0
Requires-Dist: requests>=2.31.0
Requires-Dist: jsonschema>=4.21.1
Requires-Dist: nest-asyncio>=1.6.0
Requires-Dist: pytest>=8.0.2; extra == "pytest"
Requires-Dist: pytest-mock>=3.12.0; extra == "pytest"
Provides-Extra: pytest
Description-Content-Type: text/markdown

# Superstream

## Installation

```sh
 pip install superstream
```

## Importing

```python
import superstream
from superstream.types import Option
```

## Producer

To use `superstream` with kafka producer, first define the kafka and superstream configurations:
  
```python
token = "<superstream-token>"
superstream_host = "<superstream-host>"
brokers = "<kafka-broker>"
topic = "<kafka-topic>"
config = {"bootstrap.servers": brokers}
options = Option(learning_factor=10, servers=brokers)
```

To initialize superstream, use `init` function and pass the producer instance as an argument:

```python
producer = Producer(config)
producer = superstream.init(token, superstream_host, config, options, producer=producer)
```

Finally, to produce messages to kafka, use `produce` function:

```python
person = {"name": "John Doe", "message": f"Hello, World!"}
producer.produce(
    topic,
    person,
    on_delivery=delivery_callback,
    headers={"key": "value"},
)
```

## Consumer

To use `superstream` with kafka consumer, first define the consumer configurations:

```python
token = "<superstream-token>"
superstream_host = "<superstream-host>"
group = "<kafka-consumer-group>"
topics = ["<kafka-topic>"]
brokers = "<kafka-broker>"
config = {
    "bootstrap.servers": brokers,
    "group.id": group
}
options = Option(learning_factor=10, servers=brokers)
```

To initialize superstream, use `init` function and pass the consumer instance as an argument:

```python
consumer = Consumer(config)
consumer = superstream.init(token, superstream_host, config, options, consumer=consumer)
```
