This repository provides an in-development messaging and service layer ontop of RabbitMQ.
Holon was created to satisfy a mix-match of goals that are not completely fullfiled by competing libraries. Some are too heavy, others have dependency bloat or inconsistent API's. This library attempts to provide the following tenants:
- Decoupled transport architecture and few dependencies
- No use of language specific technologies
- Support various types of services
- Decoupling remote-procedure call from the service layer
- Event system built-in
You can install the package using either the CLI:
dotnet add package Holon
or from the NuGet package manager:
Install-Package Holon
The repository comes with an example project, but a practical example of how this library can be used is documented below.
The factory service provides a way to look at the total production and command a factory to start and stop. The implementation here is a console application but it can be embedded anywhere that is async friendly.
[RpcContract]
interface IFactoryController
{
[RpcOperation]
Task<double> GetProductionToday();
[RpcOperation]
Task StartProduction();
[RpcOperation]
Task StopProduction();
}
class FruitFactory : IFactoryController
{
public async Task GetProductionToday() {
return 10000.0;
}
public async Task StartProduction() {
// start our factory up!
}
public async Task StopProduction() {
// shut it down before any fruit gets bruised
}
}
class ServiceHost {
static void Main() => MainAsync().Wait();
static async Task MainAsync() {
// attach node
Node node = await Node.CreateAsync("amqp://localhost");
// attach our service
await node.AttachAsync("factory:fruit", ServiceType.Singleton, RpcBehaviour.Bind<IFactoryController>(new FruitFactory()));
// wait forever
await Task.Delay(Timeout.InfiniteSpan);
}
}
The client can also be embedded anywhere that is async friendly, and provides a simple way to obtain a proxy and begin communicating with the fruit factory. The interface class is carried over from the previous example.
class Client {
static void Main() => MainAsync().Wait();
static async Task MainAsync() {
// attach node
Node node = await Node.CreateAsync("amqp://localhost");
// get a proxy to the factory
IFactoryController controller = node.Proxy<IFactoryController>("factory:fruit");
// start production!
await controller.StartProduction();
}
}
Package | License |
---|---|
Newtonsoft.Json | MIT |
PeNet.Asn1 | MIT |
protobuf-net | Apache 2.0 |
RabbitMQ.Client | Apache 2.0 & MPL 1.1 |
.NET Core | MIT |
Any pull requests or bug reports are welcome, please try and keep to the existing style conventions and comment any additions.