An asynchronous client library for 신경, a dynamic metadata-oriented service mesh.
If 신경 is alpha quality software, then Singyeong.Net is pre-alpha quality software. Expect things to break spectacularly.
At the simplest level:
var client = new SingyeongClientBuilder("application id here")
// Repeat this for how much initial metadata you have
.AddMetadata<TValue>("name", value)
// Repeat this for however many endpoints you have
.AddEndpoint("ws://localhost:4000/gateway/websocket", null)
.Build();
Then, wherever else:
// Cancel the cancel token to cause the client to stop... hopefully gracefully.
await client.RunAsync(cancellationToken);
To publish events, use:
await client.SendToAsync("application id here", payload,
allowRestricted: true, // or false
query: (x) =>
x.Metadata<double>("latency") < 50.0 &&
x.Metadata<string[]>("tags").Contains("production")
);
To update/remove metadata, use:
await client.SetMetadataAsync<TValue>("key", value);
await client.RemoveMetadataAsync("key");
To read dispatches, use:
var reader = client.DispatchReader;
while (await reader.WaitToReadAsync(cancellationToken))
{
while (reader.TryRead(out var dispatch))
{
// dispatch is the raw payload sent in the dispatch, including the
// nonce field. This is so you can implement your own reading logic on
// top of this, as well as get access to the nonce for indempotency if
// necessary.
}
}
- Add further error handling
- Set up CI
- Publish NuGet packages
- Add unit tests
- Clean up the codebase
- Add better failover strategies