https://github.com/superstreamlabs/superstream.net
https://github.com/superstreamlabs/superstream.net
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/superstreamlabs/superstream.net
- Owner: superstreamlabs
- License: apache-2.0
- Created: 2024-01-18T07:40:15.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-08T15:28:50.000Z (about 2 years ago)
- Last Synced: 2026-04-03T02:58:02.211Z (3 months ago)
- Language: C#
- Size: 72.3 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Superstream
## Installation
```sh
dotnet add package Superstream -v ${SUPERSTREAM_VERSION}
```
## Importing
```c#
using Superstream;
```
## Producer
To use `Superstream` with kafka producer, first define the producer configurations:
```c#
var config = new ProducerConfig { BootstrapServers = brokerList };
var options = new ProducerBuildOptions(config);
```
Then create a new instance of kafka producer and use `SuperstreamInitializer.Init` to initialize the producer with `Superstream` options:
```c#
var kafkaProducer = new ProducerBuilder(config)
.Build();
using var producer = SuperstreamInitializer.Init("", "", kafkaProducer, options);
```
Finally, to produce messages to kafka, use `ProduceAsync` or `Produce`:
```c#
producer.ProduceAsync("", new() { Value = JsonSerializer.SerializeToUtf8Bytes("{\"test_key\":\"test_value\"}") });
```
## Consumer
To use `Superstream` with kafka consumer, first define the consumer configurations:
```c#
var config = new ConsumerConfig
{
GroupId = "groupid",
BootstrapServers = brokerList,
EnableAutoCommit = false
};
var options = new ConsumerBuildOptions(config);
```
Then create a new instance of kafka consumer and use `SuperstreamInitializer.Init` to initialize the consumer with `Superstream` options:
```c#
var kafkaConsumer = new ConsumerBuilder(config)
.SetErrorHandler((_, e) => Console.WriteLine($"Error: {e.Reason}"))
.Build();
using var consumer = SuperstreamInitializer.Init("", "",kafkaConsumer, options);
```
Finally, to consume messages from kafka, use `Consume`:
```c#
var consumeResult = consumer.Consume();
Console.WriteLine($"Message : ${Encoding.UTF8.GetString(consumeResult.Message.Value)}");
```