ZeroEventHubClient 1.0.1
See the version list below for details.
dotnet add package ZeroEventHubClient --version 1.0.1
NuGet\Install-Package ZeroEventHubClient -Version 1.0.1
<PackageReference Include="ZeroEventHubClient" Version="1.0.1" />
paket add ZeroEventHubClient --version 1.0.1
#r "nuget: ZeroEventHubClient, 1.0.1"
// Install ZeroEventHubClient as a Cake Addin #addin nuget:?package=ZeroEventHubClient&version=1.0.1 // Install ZeroEventHubClient as a Cake Tool #tool nuget:?package=ZeroEventHubClient&version=1.0.1
ZeroEventHub
This README file contains information specific to the dotnet
port of the ZeroEventHub. Please see the main repository for an overview of what this project is about.
Client
We recommend that you store the latest checkpoint/cursor for each partition in the client's database. Example of simple single-partition consumption. Note about the example:
- Things starting with "my" is supplied by you
- Things starting with "their" is supplied by the service you connect to
// Step 1: Setup
const int TheirPartitionCount = 1 //documented contract with server
var requestCallback = new Func<HttpRequestMessage, Task>(message =>
{
// you can setup the authentication on the request
});
var client = new Client(TheirServerUrl, TheirPartitionCount, requestCallback);
// Step 2: Load the cursors from last time we ran
var cursors = GetMyCursorFromDb();
if (!cursor.Any()){
// we have never run before, so we can get all events with Cursor.First(0)
// (if we just want to receive new events from now, we would use Cursor.Last(0))
cursors = new[] { Cursor.First(0) };
}
// Step 3: Enter listening loop...
while (ShouldContinue)
{
// Step 4: Use ZeroEventHub client to fetch the next page of events.
var eventReceiver = EventReceiver<MyDataType>()
await client.FetchEvents(cursors, MyPageHint, eventReceiver);
// Step 5: Write the effect of changes to our own database and the updated
// cursor value in the same transaction.
using var transactionScope = new TransactionScope();
MyWriteEffectOfEventsToDb(eventReceiver.Events);
cursors = eventReceiver.LatestCheckpoints;
MyWriteCursorsToDb(cursors);
}
Development
To run the test suite, assuming you already have dotnet 6
installed and added to your PATH:
dotnet restore
dotnet test
To pass the CI checks, you may need to run the following before pushing your changes:
dotnet format
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.