Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

jeremiahredekop/NancyWorker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nancy Workers

This .net library is inspired by the Nancy FX project. The purpose is to have a little framework that workers can use to handle messages in a matter that is decoupled from any particular queueing infrastructure.

Goals:

  • Simple Modules to contain handlers
  • Handlers declared in Nancy style, as opposed to IHandle < TMessage >
  • Minimum fluent api to set up

Decisions:

  • Messages are deserialized by type
  • Message type identified by string value
  • Modules do not have address
  • Message can include Module name as a filter

State:

This library is currently an experiment. I am exploring to find the sweet spot I'll be using in a project or two.

License:

Open source - BSD.

The Code:

Here's an example of what I'm aiming for.


[TestFixture]  
public class When_invoking_handler_created_from_fluent_api : SpecificationBase
{
    public static bool Handled;
       
    private IMessage _message;
    private IMessageHandlerFacade _facade;

    private class MyModule : MessageModule
    {
        protected override void RegisterHandlers()
        {
            ForMessageType().Handle(m => Handled = true);
        }
    }

    protected override void Given()
    {
        _message = JsonTypedMessage.FromMessage(new PrototypeMessage());

        _facade = FluentHandlers.Init()
                                .UsingTypeResolver()
                                .WithAssemblyModuleTypes(GetType().Assembly, t => t == typeof (MyModule))
                                .UsingReflectionModuleFactory()
                                .Build();
    }

    protected override void When()
    {
        _facade.HandleMessage(_message);
    }

    [Then]
    public void The_message_should_have_been_handled()
    {
        Handled.Should().BeTrue();
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages