Skip to content

lulzzz/holon-net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Contributing

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

About

A library for cross-language service and event bus communication over RabbitMQ

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%