Upstash.Kafka.Client 0.1.0-alpha

This is a prerelease version of Upstash.Kafka.Client.
dotnet add package Upstash.Kafka.Client --version 0.1.0-alpha                
NuGet\Install-Package Upstash.Kafka.Client -Version 0.1.0-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Upstash.Kafka.Client" Version="0.1.0-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Upstash.Kafka.Client --version 0.1.0-alpha                
#r "nuget: Upstash.Kafka.Client, 0.1.0-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Upstash.Kafka.Client as a Cake Addin
#addin nuget:?package=Upstash.Kafka.Client&version=0.1.0-alpha&prerelease

// Install Upstash.Kafka.Client as a Cake Tool
#tool nuget:?package=Upstash.Kafka.Client&version=0.1.0-alpha&prerelease                

Upstash.Kafka.Client

An HTTP/REST based Kafka client built on top of Upstash REST API.

C# implementation of a client library using Upstash HTTP/REST api, suited for situations where HTTP is the only option.

Disclaimer!
This library is not associated with Upstash in any way, but it is inspired by the javascript implementation from Upstash. Some of the text in this readme is borrowed from there.

Installation

dotnet add package Upstash.Kafka.Client

Quickstart

Auth

  1. Go to upstash and select your database.
  2. Copy the REST API secrets at the bottom of the page
using Upstash.Kafka.Client;

var settings = new UpstashSettings(
    url: "<UPSTASH_KAFKA_REST_URL>",
    username: "<UPSTASH_KAFKA_REST_USERNAME>",
    password: "<UPSTASH_KAFKA_REST_PASSWORD>"
);

using (var kafka = new Kafka(settings))
{
  // Implementation (Examples below).
}

Produce a single message

var producer = kafka.Producer;
var message = new { Amount = 108, Name = "Product 1" };

var result = await producer.ProduceAsync("test-topic", message);

Produce multiple messages.

The same options from the example above can be set for every message.

var producer = kafka.Producer;
var messages = new[]
    {
        new { Amount = 108, Name = "Product 1" },
        new { Amount = 42, Name = "Product 2" }
        new { Amount = 1337, Name = "Product 3" }
    };

var res = await producer.ProduceManyAsync("test-topic", messages);

Consume

The first time a consumer is created, it needs to figure out the group coordinator by asking the Kafka brokers and joins the consumer group. This process takes some time to complete. That's why when a consumer instance is created first time, it may return empty messages until consumer group coordination is completed.

//TODO: Write Example

Commit manually

While consume can handle committing automatically, you can also use Consumer.commit to manually commit.

//TODO: Write Example

Fetch

You can also manage offsets manually by using Consumer.fetch

//TODO: Write Example

Contributing

Requirements

Setup

Running tests

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0-alpha 271 4/22/2024