Git Product home page Git Product logo

dotnetcqs's Introduction

Asynchronous Command/Query library

This library contains interfaces used to be able to use messaging (commands, queries and events) in applications without tightly coupling it to a specific implementation.

Example

Define a message:

public class ActivateAccount
{
	public int AccountId {get; set; }
	public string ActivationKey { get; set; }
}

Invoke it:

var msg = new ActivateAccount { AccountId = 35, ActivationKey = "dfkldsie93kcn22" };
await _messageBus.SendAsync(msg);

Handle it:

public class ActivateAccountHandler : IMessageHandler<ActivateAccount>
{
    private readonly IAccountRepository _repository;
	
	public ActivateAccountHandler(IAccountRepository repository)
	{
		if (repository == null) throw new ArgumentNullException(repository);
		
		_repository = repository;
	}
	
	public async Task HandleAsync(IMessageContext context, ActivateAccount message)
	{
		var user = await _repository.Get(message.AccountId);
		user.Activate(message.ActivationKey);
		await _repository.UpdateAsync(user);
		
		await context.SendAsync(new AccountActivated(message.AccountId));
	}
}

Message handlers are fully isolated from the rest of the specification and therefore easy to test and maintain.

Implementations

The following implementations exist.

Bus

The MessageBus and QueryBus currently have the following implementations:

  • DependenyInjection: Use your favorite container to execute and queue messages.
  • Microsoft.Extensions.DependencyInjection: Currently under implementation
  • Griffin.Container: Currently under implementation

Queues

  • ADO.NET: Uses a table in your database to enqueue and dequeue messages (to get persistance).
  • Azure ServiceBus: Under development

dotnetcqs's People

Contributors

jgauffin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.