Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Latest commit

 

History

History
128 lines (90 loc) · 4.02 KB

README.md

File metadata and controls

128 lines (90 loc) · 4.02 KB

GitHub license GitHub issues GitHub stars GitHub forks GitHub forks

Holon

This repository provides an in-development messaging and service layer ontop of RabbitMQ.

Goals

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

Getting Started

NuGet Status

You can install the package using either the CLI:

dotnet add package Holon

or from the NuGet package manager:

Install-Package Holon

Example

The repository comes with an example project, but a practical example of how this library can be used is documented below.

Factory Service

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);
	}
}

Client

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();
	}
}

Licenses

Package License
Newtonsoft.Json MIT
PeNet.Asn1 MIT
protobuf-net Apache 2.0
RabbitMQ.Client Apache 2.0 & MPL 1.1
.NET Core MIT

Contributing

Any pull requests or bug reports are welcome, please try and keep to the existing style conventions and comment any additions.