MyNatsClient.Encodings.Protobuf 0.14.1

Protobuf Encoding for assisting with sending and consuming Protobuf messages using MyNatsClient which provides a simple, effective sync and async library for interacting with NATS Server using .NET and .NET Core. It uses IObservable so it is ReactiveX (RX) friendly.

Install-Package MyNatsClient.Encodings.Protobuf -Version 0.14.1
dotnet add package MyNatsClient.Encodings.Protobuf --version 0.14.1
<PackageReference Include="MyNatsClient.Encodings.Protobuf" Version="0.14.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MyNatsClient.Encodings.Protobuf --version 0.14.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Pub-Sub sample

Simple pub-sub sample showing one client that publishes and one that subscribes. This can of course be the same client and you can also have more clients subscribing etc.

Publisher

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await client.ConnectAsync();

await client.PubAsync("tick", GetNextTick());

//or using an encoding package e.g. Json
await client.PubAsJsonAsync("tickItem", new Tick { Value = GetNextTick() });

Subscriber

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await _client.ConnectAsync();

await client.SubAsync("tick", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.GetPayloadAsString()}");
}));

//or using an encoding package e.g Json
await client.SubAsync("tickItem", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.FromJson<TestItem>().Value}");
}))

Pub-Sub sample

Simple pub-sub sample showing one client that publishes and one that subscribes. This can of course be the same client and you can also have more clients subscribing etc.

Publisher

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await client.ConnectAsync();

await client.PubAsync("tick", GetNextTick());

//or using an encoding package e.g. Json
await client.PubAsJsonAsync("tickItem", new Tick { Value = GetNextTick() });

Subscriber

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await _client.ConnectAsync();

await client.SubAsync("tick", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.GetPayloadAsString()}");
}));

//or using an encoding package e.g Json
await client.SubAsync("tickItem", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.FromJson<TestItem>().Value}");
}))

Release Notes

https://github.com/danielwertheim/mynatsclient/releases

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MyNatsClient.Encodings.Protobuf:

Package Downloads
Mi.Fx.Nats
macula.io Nats abstraction
Mi.Fx.Contract
Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.14.1 3,108 1/6/2020
0.13.0 16,730 6/29/2018