Code Monkey home page Code Monkey logo

brighter's Introduction

canon Brighter
Brighter is a framework for building messaging app with .NET and C#. It can be used with an in-memory bus, or for interoperability in a microservices architecture, out of process via a wider range of middleware transports.
Version NuGet Version
Download NuGet Downloads
Documentation Technical Documentation
Source https://github.com/BrighterCommand/Brighter
Keywords task queue, job queue, asynchronous, async, rabbitmq, amqp, sqs, sns, kafka, redis, c#, command, command dispatcher, command processor, queue, distributed

What Scenarios Can You Use Brighter in?

  • When implementing a clean architecture (ports & adapters), one question is how to implement the interactor or port layer (sometimes called a mediator).

    • A common solution is to use the Command pattern to implement the Interactor (port) or a pattern derived from that.
    • Brighter provides an implementation the Interactor (port) using the Command Dispatcher pattern.
    • You can write a command, that is then dispatched to a handler that you write.
    • Alternatively you can write an event, that is dispatched to zero or more handlers that you write.
    • Brighter also supports the Command Processor pattern, so that you can add middleware between the sender and handler.
    • Handlers are tagged via attributes to include middleware in thier pipeline.
    • Out-of-the-box middleware is provided for logging and Polly (retry, and circuit breaker).
  • When integrating two microservices using messaging, one question is how to abstract from the developer the code that sends and receives messages in favor of writing domain code.

    • A common solution is a message pump that: gets a message, translates a message, and dispatches it to user code.
    • Brighter provides a service activator that implements a message pump.
    • The message pump dispatches to user code via Brighter's Command Dispatcher/Processor.
    • This hides the complexity of a message pump; developers need only write a handler that subscribes to a message
    • This hides the complexity of messaging from developers who just write commands/events and handlers.
    • Developers can take full advantage of Brighter's middleware pipeline when processing messages
    • Brighter can be configured for a variety of transports including RabbitMQ, and SNS+SQS.

Documentation

  • More detailed documentation on the project can be found on the GitBook pages for the project here: Paramore

What are the different branches?

Branch Description
Master The tip of active development. Anything in master should ship at the next release. Code here should conform to CI basics: compile, pass tests etc.
[Other] A branch for any work that is not ready to go into master (for example would break CI) or is experimental i.e. we don't know if we intend to ever ship, we are just trying out ideas.

Using Docker Compose to test

We provide a Docker Compose file to allow you to run the test suite, without having to install the pre-requisites, such as brokers or databases locally.

To run it, you will need to scale the redis sentinel to at least 3 nodes, and use at least two redis slaves. For example:

docker-compose up -d --build --scale redis-slave=2 --scale redis-sentinel=3

The goal is to allow you to begin working with Brighter as easily as possible for development.

Note that if you have locally installed versions of these services you will either need to stop them, or edit a local version of the docker compose file.

How do I get the NuGet packages for the latest build?

We release the build artefacts (NuGet packages) to NuGet on a regular basis and we update the release notes on those drops. We also tag the master code line. If you want to take the packages that represent master at any point you can download the packages for the latest good build from GitHub Packages.

Coverity Scan Build Status

CI

brighter's People

Contributors

a2glukhov avatar acraven avatar dcomartin avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar devjonny avatar domspektrix avatar drawaes avatar dstockhammer avatar holytshirt avatar honkuan86 avatar ianbattersby avatar iancooper avatar jonnyollifflee avatar josephwoodward avatar jtsalva avatar mrhypnos avatar penderi avatar preardon avatar red-f avatar samrumley88 avatar shanselman avatar simoncropp avatar slang25 avatar snyk-bot avatar thijmen avatar whunsley avatar wilsonretailsuccess avatar yiannistri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brighter's Issues

Support 0MQ

As well as amqp and RestMS it would be worth supporting 0MQ to 'get the set'

Implement Go consumer

Given we have defined the Brighter message format we can use work queues to become platform independent i.e. send from a producer written in one languages to a consumer in another language. This is the most useful initial set for Huddle.

In essence they need to replace ServiceActivator, but idiomatically for their own runtime


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Inserting the same Message into the Message Store causing duplicate exception

The command processor post method has the writing to the message store and the writing to Message Gateway wrapped in a single Retry and Circuit breaker.

If the writing to the message store is successful and writing to the gateway fails and the the retry is triggered, the writing to the message store will fail on the retry.

Writing to the Message Store should be an idempotent operation.

Support management and Monitoring of ServiceActivator instances

We want both command line and web based monitoring and control of service activator instances. We want to support a view of the message store(s) and sending messages to active instances via a control bus.

The web site should be self-hosted and allow multiple message stores to be viewed in one location.

The control bus ought to accept over-HTTP control inputs. It needs to publish it's statistics. We envisage using the RestMS as a messaging hub to send messages to Brighter, and to publish stats. Those stats could update the message store web interface to show who consumed messages and ack/reject/requeue.

A simple command line like Curl and WGet could then be used to manage instances. In particular we want to report the passage of messages through, and be able to start and stop individual performers. It would be nice to be able to introduce new performers to handle load. Because it might be a pain to keep formatting and sending RestMS control messages we envisage a python script being developed to help automate this.

The web site could then provide a 'nicer' interface but similar functionality

The goal here is to produce something like Celery management and monitoring tools: http://celery.readthedocs.org/en/latest/userguide/monitoring.html


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Possible RmqMessageProducer Dispose Problem

I've created a microservice setup that uses TopShelf to host a OWIN self host service which starts a WebApp... pretty standard setup. This microservice accepts a command, handles it, packages it up into an event which gets published to a RabbitMQ exchange.

My command processor setup seems trivial:

        RmqMessageProducer gateway = new RmqMessageProducer(logger);

            var commandProcessorBuilder = CommandProcessorBuilder
                .With()
                .Handlers(new HandlerConfiguration(BuildSubscriberRegistry(),
                    new AutofacCommandHandlerFactory(c.Resolve<IComponentContext>())))
                //.NoPolicy()
                .Policies(BuildPolicyRegistry())
                .Logger(logger)
                //.NoTaskQueues()
                .TaskQueues(new MessagingConfiguration(couchbaseMessageStore,
                    gateway, BuildMessageMapperRegistry(c.Resolve<IComponentContext>())))
                .RequestContextFactory(new InMemoryRequestContextFactory());

When I start the service and immediately stop it everything shuts down fine.

If I start it and actually send in a command the command is handled properly but when I shut down the service the service stops but the window does not close. Visual Studio indicates that there is still a process running. My investigation seems to point to the RmqMessageProducer not getting cleaned up. If I turn off the policies and the task queues (bypassing the queue code) the service will shut down correctly. Something is keeping the process running despite the Stop method being called on my service.

Any suggestions of what I can look into?

Automate the build

We don't have an automated build process, just some batch scripts. Use FAKE by preference.
The hard part is building the NuGet packages, particularly the symbol files, which need to understand the files to include, as well as ensuring dependencies to internal projects are aligned.
We also need a deploy script to push to NuGet

Implement Python consumer

Implement a Python equivalent to ServiceActivator, allowing us to send messages from components running one one platform to components running on another.

RestMS Message Broker ToDo List

1: Replace the broker in the Tasks example with the RestMS broker
2: Implement persistent repository; needs to support distribution i.e.multiple broker nodes (Raven?) via AP over CP. This requires the async pipeline from commandprocessor
3: Add a user key api, to generate new user id and key (API not UI based for now)
4: Documentation - stress this is not production quality
5: Support HTTPS

Implement F# Producer

Similar to the consumers issue, but the idea here is to allow you to push messages supporting the Brighter message format on the queue and have them consumed by a consumer in a different format i.e. a golang http server pushes messages onto a queue that are handled by a .NET consumer.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Consider moving RestMS server to its own repository

Once we have the gateway working for this application layer, it may make sense to put it into it's own repository. It's not part of the Command Dispatcher/Task Queue project, it's a way to implement it. It also has it's own potential backlog to make a version with persistent queues, HA etc.

The only real advantage of keeping it with the project is that it could be used as the server for the examples, which prevents people from needing to have RabbitMQ installed to run them. One of our goals is to make running the examples easy, because it is often difficult in OSS projects to spin up the examples and see how they work. This is one reason we embed the examples in the project

Support Fallback Options Better

We use Policy to provide Circuit Breaker, but we don't provide a way to fall back to something other than the call, leaving that to the implementer. Hystrix advice is fail fast, fail silent, static, stubbed, cached via network. This involves raising a new command that is queued or serviced by cache in case those elements are also defective.

https://github.com/Netflix/Hystrix/wiki/How-To-Use

Should we offer more support for fallback options?

The main issue here is that Hystix commands return results. We have strict CQS and so don't do this. So our only model for resilience is to queue for eventual execution. It could suggest that we need to provide a Brighter Query library that supports all these options...

Implement Python Producer

Similar to the consumers issue, but the idea here is to allow you to push messages supporting the Brighter message format on the queue and have them consumed by a consumer in a different format i.e. a python django server pushes messages onto a queue that are handled by a .NET consumer.

Can I use Brighter to run a pipeline of commands?

Hi,

I've seen the Not just layers! What can pipelines and events do for you? by Ian Cooper.

In the presentation Ian uses a framework to build a Pipes and Filters pipeline.

I was wondering if I can use Brighter to create pipelines of chained commands.

Since the RequestHandler has a Successor property I've been able to run chained commands like this:

var pump = new PumpCommandHandler(logger);
var filter1 = new Filter1CommandHandler(logger);
var filter2 = new Filter2CommandHandler(logger);  
var sink = new SinkCommandHandler(logger);
pump.Successor = filter1;
filter1.Successor = filter2;
filter2.Successor = sink;

I'm wondering if I'm supposed to use Brighter to do this... or if I should implement a Pipes and Filters pipeline instead.

Can you advise?

Thanks in advance

Support fluent configuration as well as attibutes

The fluent configuration needs to work with SubscriberRegistry and register the first item in the chain. In order to support fluent and attributes we might to parse all handlers in the chain for attributes and insert into the chain where there are attributes even if using fluent.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

HandlerFactory Release

I took notice that my handler factory Release was not being called for my command handler. Digging into the Brighter code I realized that the handler is not added to the LifetimeScope unless the handler implements IDisposable. Since a handler that doesn't implement IDisposable is never added to the LifetimeScope, Release will not be called for the handler. I suppose if I have no real cleanup to do in my handler not calling Release would be OK and that it would eventually be disposed.

I thought I'd tell you because based on the documentation I fully expected Release to be called all the time. So I don't know if this is really a code issue or a documentation issue.

Nuget Version Rollback?

As late as 02/27 1:46 PM EST NuGet pulled down version 3.0.94 with all the LibLog goodness and other changes. When I pulled from NuGet at 02/27 6:36 PM EST I'm back at 2.0.1.0 with Common logging, etc.

Dazed and confused...

ConfigSection duplicated on NuGet Update

Low Priority...

In the ServiceActivator app.config.install.xdt

<section name="serviceActivatorConnections" type="paramore.brighter.serviceactivator.ServiceActivatorConfiguration.ServiceActivatorConfigurationSection, paramore.brighter.serviceactivator" allowLocation="true" allowDefinition="Everywhere" xdt:Transform="Insert"/>

should be InsertIfMissing maybe? Every time I upgrade I get the section even if it is already present.

Add Feature Switch toggling as a Policy Attribute

At an attribute of the form

[FeatureSwitch(""MyCoolNewFeature)]

That looks for a FeatureSwitch config setting, in a custom config section with an entry for the feature and a yes/no as to whether the feature is enabled or disabled.

Throw a FeatureNotEnabled exception on trying to access a non-enabled feature.

Default to throw i.e. we forgot to add the config setting

Working together

I'm newbie about distributed systems.

IMHO, The ideal world is working together Paramore (https://github.com/iancooper/Paramore/) and Wolfpack (https://wolfpack.codeplex.com/) and another like:

Asimov Deploy https://github.com/asimov-deploy by Torkel Ödegaard (@torkelo).

https://periscope.codeplex.com/Wikipage?ProjectName=periscope

https://github.com/chucknorris/dropkick
https://github.com/mmooney/Sriracha.Deploy
https://github.com/asimov-deploy/asimov-deploy-winagent
http://presto.codeplex.com/

https://wolfpack.codeplex.com/

From all the good answers provided by everyone here I am now getting a better understanding of appropriate use of this topic and IMHO other programmers will definitely benifit from the

knowledge sharing here. Some of the implementations that I had worked in the past could have been better implemented using this knowledge.
IMHO, better samples for minimize learning curve are real applications with full source code and good patterns

Now this is the kind of invetigative reporting, that I am interested in. Real world problems, with real world solutions. Most real world solutions start with kick ass debugging.

Document a Brighter message format

If we want to support multiple application layer protocols we need to separate header and body for the message. The header needs things like id, routing key, retries, delivery date, and content type (JSON, BSON, XML, YAML, pickle, protobuf etc.). The body contains the content in that content-type.

Once messages have an agreed format we can become independent of the application layer protocol used to transport them

Support the Celery message format

The advantage is that this leads towards interop between .NET producers and consumers with other Celery clients and consumers. So it becomes a way to easily platform decouple a solution

Should Brighter move into its own repository

The concept behind Brighter being with Paramore was that Paramore was to provide a fuller example of building a hexagonal architecture service using Brighter. I still think that is a valid goal, but it may become questionable for them to live in the same repository over time.

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.