Code Monkey home page Code Monkey logo

arbitrer's Introduction

Arbitrer

NuGet NuGet

Arbitrer provides MediatR Pipelines to transform mediator from In-process to Out-Of-Process messaging via RPC calls implemented with popular message dispatchers.

When you need Arbitrer.

Mediatr is very good to implement some patterns like CQRS

Implementing CQRS in an in-process application does not bring to you all the power of the pattern but gives you the opportunity to have organized, easy to maintain code. When the application grow you may need to refactor your things to a microservices architecture.

Microservices and patterns like CQRS are very powerfull combination. In this scenario you will need to rewrite communication part to use some kind of out of process message dispatcher.

Arbitrer change Mediatr behaviour and let you decide which call needs to be in-process and which needs to be Out-of-process and dispatched remotely, via a configuration without changing a single row of your code.

Versioning

Arbitrer follow MediatR versioning.

Arbitrer v.12.x is for MediatR from 12.x
Arbitrer v.9.0 is for MediatR from 9.x to 11.x

Installation

You should install Arbitrer with NuGet:

Install-Package Arbitrer

Or via the .NET Core command line interface:

dotnet add package Arbitrer

Either commands, from Package Manager Console or .NET Core CLI, will download and install Arbitrer and all required dependencies.

Basic Configuration

Configuring Arbitrer is an easy task.

  1. Add Arbitrer to services configuration via AddArbitrer extension method.
  services.AddArbitrer(opt => ...
  1. Decide what is the default behaviour, available options are
    1. ImplicitLocal : all mediator.Send() calls will be delivered in-process unless further configuration.
    2. ImplicitRemote : all mediator.Send() calls will be delivered out-of-process unless further configuration.
    3. Explicit : you have the responsability do declare how to manage every single call.
    services.AddArbitrer(opt =>
    {
      opt.Behaviour = ArbitrerBehaviourEnum.Explicit;
    });
  1. Configure calls delivery type according with you behaviour:
    services.AddArbitrer(opt =>
    {
      opt.Behaviour = ArbitrerBehaviourEnum.Explicit;
      opt.SetAsRemoteRequest<MediatRRequest1>();
      opt.SetAsRemoteRequest<MediatRRequest2>();
      ....
    }

Of course you will have some processes with requests declared Local and other processes with same requests declared Remote.

Example of process with all local calls and some remote calls

    services.AddArbitrer(opt =>
    {
      opt.Behaviour = ArbitrerBehaviourEnum.ImplicitLocal;
      opt.SetAsRemoteRequest<MediatRRequest1>();
      opt.SetAsRemoteRequest<MediatRRequest2>();
      opt.SetAsRemoteRequests(typeof(MediatRRequest2).Assembly); // All requests in an assembly
    });

Example of process with local handlers.

    services.AddArbitrer(opt =>
    {
      opt.Behaviour = ArbitrerBehaviourEnum.ImplicitLocal;
    });

Example of process with remore handlers.

    services.AddArbitrer(opt =>
    {
      opt.Behaviour = ArbitrerBehaviourEnum.ImplicitRemote;
    });

Arbitrer with RabbitMQ

Installing Arbitrer RabbitMQ extension.

    Install-Package Arbitrer.RabbitMQ

Or via the .NET Core command line interface:

    dotnet add package Arbitrer.RabbitMQ

Configuring RabbitMQ Extension.

Once installed you need to configure rabbitMQ extension.

    services.AddArbitrerRabbitMQMessageDispatcher(opt =>
    {
      opt.HostName = "rabbit instance";
      opt.Port = 5672;
      opt.Password = "password";
      opt.UserName = "rabbituser";
      opt.VirtualHost = "/";
    });
    services.ResolveArbitrerCalls();

or if you prefer use appsettings configuration

    services.AddArbitrerRabbitMQMessageDispatcher(opt => context.Configuration.GetSection("rabbitmq").Bind(opt));
    services.ResolveArbitrerCalls();

Arbitrer with Kafka

Installing Arbitrer Kafka extension.

    Install-Package Arbitrer.Kafka

Or via the .NET Core command line interface:

    dotnet add package Arbitrer.Kafka

Configuring Kafka Extension.

Once installed you need to configure Kafka extension.

    services.AddArbitrerKafkaMessageDispatcher(opt =>
    {
      opt.BootstrapServers = "localhost:9092";
    });
    services.ResolveArbitrerCalls();

or if you prefer use appsettings configuration

    services.AddArbitrerKafkaMessageDispatcher(opt => context.Configuration.GetSection("kafka").Bind(opt));
    services.ResolveArbitrerCalls();

Arbitrer with Azure Message Queues

Coming soon.

arbitrer's People

Contributors

ppossanzini avatar aeteamdev avatar snys98 avatar

Watchers

 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.