Ejemplo n.º 1
0
 public UserController(
     IAmACommandProcessor commandProcessor,
     IQueryProcessor queryProcessor)
 {
     _commandProcessor = commandProcessor ?? throw new ArgumentNullException(nameof(commandProcessor));
     _queryProcessor   = queryProcessor ?? throw new ArgumentNullException(nameof(queryProcessor));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dispatcher"/> class.
 /// </summary>
 /// <param name="commandProcessor">The command processor.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="connections">The connections.</param>
 public Dispatcher(
     IAmACommandProcessor commandProcessor,
     IAmAMessageMapperRegistry messageMapperRegistry,
     IEnumerable <Connection> connections)
     : this(commandProcessor, messageMapperRegistry, connections, LogProvider.For <Dispatcher>())
 {
 }
Ejemplo n.º 3
0
 public ConsumerFactory(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, Connection connection)
 {
     _commandProcessor      = commandProcessor;
     _messageMapperRegistry = messageMapperRegistry;
     _connection            = connection;
     _consumerName          = new ConsumerName($"{_connection.Name}-{DateTime.Now.Ticks}");
 }
Ejemplo n.º 4
0
 public TaskEndPointHandler(ITaskRetriever taskRetriever, ITaskListRetriever taskListRetriever, IAmACommandProcessor commandProcessor, ICommunicationContext communicationContext)
 {
     this.taskRetriever        = taskRetriever;
     this.taskListRetriever    = taskListRetriever;
     this.commandProcessor     = commandProcessor;
     this.communicationContext = communicationContext;
 }
Ejemplo n.º 5
0
 public TaskEndPointHandler(ITaskRetriever taskRetriever, ITaskListRetriever taskListRetriever, IAmACommandProcessor commandProcessor, ICommunicationContext communicationContext)
 {
     this.taskRetriever = taskRetriever;
     this.taskListRetriever = taskListRetriever;
     this.commandProcessor = commandProcessor;
     this.communicationContext = communicationContext;
 }
Ejemplo n.º 6
0
        public CommandProcessorUsingInboxTests()
        {
            _inbox = new InMemoryInbox();

            var registry = new SubscriberRegistry();

            registry.Register <MyCommand, MyStoredCommandHandler>();
            registry.Register <MyCommandToFail, MyStoredCommandToFailHandler>();

            var container = new ServiceCollection();

            container.AddTransient <MyStoredCommandHandler>();
            container.AddTransient <MyStoredCommandToFailHandler>();
            container.AddSingleton(_inbox);
            container.AddTransient <UseInboxHandler <MyCommand> >();
            container.AddTransient <UseInboxHandler <MyCommandToFail> >();

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _command = new MyCommand {
                Value = "My Test String"
            };

            _contextKey       = typeof(MyStoredCommandHandler).FullName;
            _commandProcessor = new CommandProcessor(registry, (IAmAHandlerFactory)handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());
        }
Ejemplo n.º 7
0
        public OnceOnlyAttributeAsyncTests()
        {
            _inbox = new InMemoryInbox();

            var registry = new SubscriberRegistry();

            registry.RegisterAsync <MyCommand, MyStoredCommandHandlerAsync>();

            var container = new ServiceCollection();

            container.AddTransient <MyStoredCommandHandlerAsync>();
            container.AddSingleton(_inbox);
            container.AddTransient <UseInboxHandlerAsync <MyCommand> >();
            container.AddSingleton <IBrighterOptions>(new BrighterOptions()
            {
                HandlerLifetime = ServiceLifetime.Transient
            });


            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _command = new MyCommand {
                Value = "My Test String"
            };

            _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());
        }
Ejemplo n.º 8
0
        public MessageDispatcherMultiplePerformerTests()
        {
            _channel          = new FakeChannel();
            _commandProcessor = new SpyCommandProcessor();

            var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory((_) => new MyEventMessageMapper()));

            messageMapperRegistry.Register <MyEvent, MyEventMessageMapper>();

            var connection = new Subscription <MyEvent>(new SubscriptionName("test"), noOfPerformers: 3, timeoutInMilliseconds: 100, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey"));

            _dispatcher = new Dispatcher(_commandProcessor, messageMapperRegistry, new List <Subscription> {
                connection
            });

            var @event  = new MyEvent();
            var message = new MyEventMessageMapper().MapToMessage(@event);

            for (var i = 0; i < 6; i++)
            {
                _channel.Enqueue(message);
            }

            _dispatcher.State.Should().Be(DispatcherState.DS_AWAITING);
            _dispatcher.Receive();
        }
Ejemplo n.º 9
0
        private static async Task MainAsync(IAmACommandProcessor commandProcessor)
        {
            // To allow the event handler(s) to release the thread
            // while doing potentially long running operations,
            // await the async (but inline) handling of the events
            await commandProcessor.PublishAsync(new GreetingEvent("Ian"));

            try
            {
                // This will cause an exception in one event handler
                await commandProcessor.PublishAsync(new GreetingEvent("Roger"));
            }
            catch (AggregateException e)
            {
                Console.WriteLine("Aggregate exception thrown after event Roger:");
                ShowExceptions(e, 1);
            }

            try
            {
                // This will cause an exception in both event handlers
                await commandProcessor.PublishAsync(new GreetingEvent("Devil"));
            }
            catch (AggregateException e)
            {
                Console.WriteLine("Aggregate exception thrown after event Devil:");
                ShowExceptions(e, 1);
            }
        }
        public MonitorHandlerPipelineTests()
        {
            _controlBusSender = new SpyControlBusSender();
            var registry = new SubscriberRegistry();

            registry.Register <MyCommand, MyMonitoredHandler>();

            var container = new ServiceCollection();

            container.AddTransient <MyMonitoredHandler>();
            container.AddTransient <MonitorHandler <MyCommand> >();
            container.AddSingleton <IAmAControlBusSender>(_controlBusSender);
            container.AddSingleton(new MonitorConfiguration {
                IsMonitoringEnabled = true, InstanceName = "UnitTests"
            });
            container.AddSingleton <IBrighterOptions>(new BrighterOptions()
            {
                HandlerLifetime = ServiceLifetime.Transient
            });

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());

            _command = new MyCommand();

            _originalRequestAsJson = JsonSerializer.Serialize(_command, JsonSerialisationOptions.Options);

            _at = DateTime.UtcNow.AddMilliseconds(-500);
        }
Ejemplo n.º 11
0
 public UpdateShipOwnerHandlerAsync(
     IShipRegistryContextFactory contextFactory,
     IAmACommandProcessor commandProcessor)
 {
     _contextFactory   = contextFactory;
     _commandProcessor = commandProcessor;
 }
Ejemplo n.º 12
0
 public ToDoController(
     IAmACommandProcessor commandProcessor,
     IQueryProcessor queryProcessor)
 {
     _commandProcessor = commandProcessor;
     _queryProcessor   = queryProcessor;
 }
 public NewShipRegistrationHandlerAsync(
     IShipRegistryContextFactory contextFactory,
     IAmACommandProcessor commandProcessor)
 {
     _contextFactory   = contextFactory;
     _commandProcessor = commandProcessor;
 }
Ejemplo n.º 14
0
        public MailOrderModule(IAmACommandProcessor messageProcessor)
        {
            Post["/mail/send"] = _ =>
            {
                var request = this.Bind <SendMailRequestModel>();

                try
                {
                    messageProcessor.Send(
                        new CreateSendMailOrderCommand(
                            request.Sender,
                            request.Destination,
                            request.Body,
                            request.Type,
                            request.ScheduleAt
                            ));
                }
                catch (MailOrderValidationException e)
                {
                    Console.WriteLine(e);
                    return(HttpStatusCode.BadRequest);
                }

                return(HttpStatusCode.OK);
            };
        }
Ejemplo n.º 15
0
 public RemoveShipHandlerAsync(
     IShipRegistryContextFactory contextFactory,
     IAmACommandProcessor commandProcessor)
 {
     _contextFactory   = contextFactory;
     _commandProcessor = commandProcessor;
 }
        public void Establish()
        {
            var subscriberRegistry = new SubscriberRegistry();

            subscriberRegistry.RegisterAsync <MyEvent, MyEventHandlerAsyncWithContinuation>();

            _commandProcessor = new CommandProcessor(
                subscriberRegistry,
                new CheapHandlerFactoryAsync(),
                new InMemoryRequestContextFactory(),
                new PolicyRegistry());

            _channel = new FakeChannel();
            var mapper = new MyEventMessageMapper();

            _messagePump = new MessagePumpAsync <MyEvent>(_commandProcessor, mapper)
            {
                Channel = _channel, TimeoutInMilliseconds = 5000
            };

            _event = new MyEvent();

            var message = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(_event)));

            _channel.Add(message);
            var quitMessage = new Message(new MessageHeader(Guid.Empty, "", MessageType.MT_QUIT), new MessageBody(""));

            _channel.Add(quitMessage);
        }
Ejemplo n.º 17
0
 public ConsumerFactory(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, Connection connection, ILog logger)
 {
     this.commandProcessor      = commandProcessor;
     this.messageMapperRegistry = messageMapperRegistry;
     this.connection            = connection;
     this.logger = logger;
 }
Ejemplo n.º 18
0
 public BrighterWorksheetController(
     IAmACommandProcessor commandProcessor,
     IQueryProcessor queryProcessor)
 {
     _commandProcessor = commandProcessor;
     _queryProcessor   = queryProcessor;
 }
Ejemplo n.º 19
0
        public DispatcherRestartConnectionTests()
        {
            _channel          = new FakeChannel();
            _commandProcessor = new SpyCommandProcessor();

            var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory((_) => new MyEventMessageMapper()));

            messageMapperRegistry.Register <MyEvent, MyEventMessageMapper>();

            _subscription    = new Subscription <MyEvent>(new SubscriptionName("test"), noOfPerformers: 1, timeoutInMilliseconds: 100, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey"));
            _newSubscription = new Subscription <MyEvent>(new SubscriptionName("newTest"), noOfPerformers: 1, timeoutInMilliseconds: 100, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: new RoutingKey("fakekey"));
            _dispatcher      = new Dispatcher(_commandProcessor, messageMapperRegistry, new List <Subscription> {
                _subscription, _newSubscription
            });

            var @event  = new MyEvent();
            var message = new MyEventMessageMapper().MapToMessage(@event);

            _channel.Enqueue(message);

            _dispatcher.State.Should().Be(DispatcherState.DS_AWAITING);
            _dispatcher.Receive();
            Task.Delay(250).Wait();
            _dispatcher.Shut("test");
            _dispatcher.Shut("newTest");
            Task.Delay(500).Wait();
            _dispatcher.Consumers.Should().HaveCount(0);
        }
Ejemplo n.º 20
0
        private static async Task MainAsync(IAmACommandProcessor commandProcessor)
        {
            // To allow the event handler(s) to release the thread
            // while doing potentially long running operations,
            // await the async (but inline) handling of the events
            await commandProcessor.PublishAsync(new GreetingEvent("Ian"));

            try
            {
                // This will cause an exception in one event handler
                await commandProcessor.PublishAsync(new GreetingEvent("Roger"));
            }
            catch (AggregateException e)
            {
                Console.WriteLine("Aggregate exception thrown after event Roger:");
                ShowExceptions(e, 1);
            }

            try
            {
                // This will cause an exception in both event handlers
                await commandProcessor.PublishAsync(new GreetingEvent("Devil"));
            }
            catch (AggregateException e)
            {
                Console.WriteLine("Aggregate exception thrown after event Devil:");
                ShowExceptions(e, 1);
            }
        }
        public MonitorHandlerPipelineAsyncTests()
        {
            _controlBusSender = new SpyControlBusSender();
            var registry = new SubscriberRegistry();

            registry.RegisterAsync <MyCommand, MyMonitoredHandlerAsync>();

            var container      = new TinyIoCContainer();
            var handlerFactory = new TinyIocHandlerFactoryAsync(container);

            container.Register <IHandleRequestsAsync <MyCommand>, MyMonitoredHandlerAsync>();
            container.Register <IHandleRequestsAsync <MyCommand>, MonitorHandlerAsync <MyCommand> >();
            container.Register <IAmAControlBusSenderAsync>(_controlBusSender);
            container.Register(new MonitorConfiguration {
                IsMonitoringEnabled = true, InstanceName = "UnitTests"
            });

            _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());

            _command = new MyCommand();

            _originalRequestAsJson = JsonConvert.SerializeObject(_command);

            _at = DateTime.UtcNow.AddMilliseconds(-500);
        }
Ejemplo n.º 22
0
 public ConsumerFactory(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, Connection connection)
 {
     _commandProcessor      = commandProcessor;
     _messageMapperRegistry = messageMapperRegistry;
     _connection            = connection;
     _consumerName          = new ConsumerName($"{_connection.Name}-{Guid.NewGuid()}");
 }
        public MonitorHandlerPipelineAsyncTests()
        {
            _controlBusSender = new SpyControlBusSender();
            var registry = new SubscriberRegistry();

            registry.RegisterAsync <MyCommand, MyMonitoredHandlerAsync>();

            var container = new ServiceCollection();

            container.AddTransient <MyMonitoredHandlerAsync>();
            container.AddTransient <MonitorHandlerAsync <MyCommand> >();
            container.AddSingleton <IAmAControlBusSenderAsync>(_controlBusSender);
            container.AddSingleton(new MonitorConfiguration {
                IsMonitoringEnabled = true, InstanceName = "UnitTests"
            });

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _commandProcessor = new CommandProcessor(registry, (IAmAHandlerFactoryAsync)handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());

            _command = new MyCommand();

            _originalRequestAsJson = JsonConvert.SerializeObject(_command);

            _at = DateTime.UtcNow.AddMilliseconds(-500);
        }
Ejemplo n.º 24
0
 public SetTaskDueDateController(
     IQueryProcessor queryProcessor,
     IAmACommandProcessor commandProcessor)
 {
     _queryProcessor   = queryProcessor;
     _commandProcessor = commandProcessor;
 }
 public GitProcessor(IAmACommandProcessor commandProcessor, IQueryProcessor queryProcessor,
                     GitHubClientOptions gitHubClientOptions)
 {
     _commandProcessor    = commandProcessor;
     _queryProcessor      = queryProcessor;
     _gitHubClientOptions = gitHubClientOptions;
 }
        public void Establish()
        {
            _controlBusSender = new SpyControlBusSender();
            var registry = new SubscriberRegistry();

            registry.Register <MyCommand, MyMonitoredHandler>();

            var container      = new TinyIoCContainer();
            var handlerFactory = new TinyIocHandlerFactory(container);

            container.Register <IHandleRequests <MyCommand>, MyMonitoredHandler>();
            container.Register <IHandleRequests <MyCommand>, MonitorHandler <MyCommand> >();
            container.Register <IAmAControlBusSender>(_controlBusSender);
            container.Register <MonitorConfiguration>(new MonitorConfiguration {
                IsMonitoringEnabled = true, InstanceName = "UnitTests"
            });
            _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());

            _command = new MyCommand();

            _originalRequestAsJson = JsonConvert.SerializeObject(_command);

            _at = DateTime.UtcNow;
            Clock.OverrideTime = _at;
        }
        public void Establish()
        {
            _channel          = new FakeChannel();
            _commandProcessor = new SpyCommandProcessor();

            var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory(() => new MyEventMessageMapper()));

            messageMapperRegistry.Register <MyEvent, MyEventMessageMapper>();

            _connection = new Connection(name: new ConnectionName("test"), dataType: typeof(MyEvent), noOfPerformers: 3, timeoutInMilliseconds: 1000, channelFactory: new InMemoryChannelFactory(_channel), channelName: new ChannelName("fakeChannel"), routingKey: "fakekey");
            _dispatcher = new Dispatcher(_commandProcessor, messageMapperRegistry, new List <Connection> {
                _connection
            });

            var @event  = new MyEvent();
            var message = new MyEventMessageMapper().MapToMessage(@event);

            for (var i = 0; i < 6; i++)
            {
                _channel.Add(message);
            }

            Assert.AreEqual(DispatcherState.DS_AWAITING, _dispatcher.State);
            _dispatcher.Receive();
        }
Ejemplo n.º 28
0
 /// <summary>
 /// This sweeper clears an outbox of any outstanding messages within the time interval
 /// </summary>
 /// <param name="millisecondsSinceSent">How long can a message sit in the box before we attempt to resend</param>
 /// <param name="commandProcessor">Who should post the messages</param>
 /// <param name="batchSize">The maximum number of messages to dispatch.</param>
 /// <param name="useBulk">Use the producers bulk dispatch functionality.</param>
 public OutboxSweeper(int millisecondsSinceSent, IAmACommandProcessor commandProcessor, int batchSize = 100,
                      bool useBulk = false)
 {
     _millisecondsSinceSent = millisecondsSinceSent;
     _commandProcessor      = commandProcessor;
     _batchSize             = batchSize;
     _useBulk = useBulk;
 }
Ejemplo n.º 29
0
 public CategoryController(IAmACommandProcessor commandProcessor,
                           IQueryProcessor queryProcessor,
                           IRenderCategory categoryRenderer)
 {
     _commandProcessor = commandProcessor;
     _queryProcessor   = queryProcessor;
     _categoryRenderer = categoryRenderer;
 }
Ejemplo n.º 30
0
        public AuthController(IConfiguration configuration, IAmACommandProcessor commandProcessor, IQueryProcessor queryProcessor)
        {
            _commandProcessor = commandProcessor;
            _queryProcessor   = queryProcessor;

            _jwtSecretKey = configuration.GetValue <string>("JWTSecretKey");
            _jwtLifespan  = configuration.GetValue <int>("JWTLifespan");
        }
Ejemplo n.º 31
0
 public ArticleController(IAmACommandProcessor commandProcessor,
                          IQueryProcessor queryProcessor,
                          IRenderArticle articleRenderer)
 {
     _commandProcessor = commandProcessor;
     _queryProcessor   = queryProcessor;
     _articleRenderer  = articleRenderer;
 }
Ejemplo n.º 32
0
 public MessagePump(
     IAmACommandProcessor commandProcessor,
     IAmAMessageMapper <TRequest> messageMapper
     )
 {
     _commandProcessor = commandProcessor;
     _messageMapper    = messageMapper;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public Consumer(ILastReadFeedItemDAO lastReadFeedItemDao, IAmACommandProcessor commandProcessor, ILog logger)
 {
     _lastReadFeedItemDao = lastReadFeedItemDao;
     _commandProcessor = commandProcessor;
     _logger = logger;
     _atomFeedGateway = new AtomFeedGateway(_lastReadFeedItemDao, _logger);
     _retryPolicy = Policy
         .Handle<ApplicationException>()
         .RetryForever(exception => logger.WarnException("Error connecting to the server - will retry", exception));
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DomainController"/> class.
 /// </summary>
 /// <param name="commandProcessor">The command processor.</param>
 /// <param name="domainRepository">The domain repository.</param>
 /// <param name="feedRepository">The feed repository.</param>
 /// <param name="pipeRepository">The pipe repository.</param>
 public DomainController(
     IAmACommandProcessor commandProcessor,
     IAmARepository<Domain> domainRepository,
     IAmARepository<Feed> feedRepository,
     IAmARepository<Pipe> pipeRepository)
 {
     _commandProcessor = commandProcessor;
     _domainRepository = domainRepository;
     _feedRepository = feedRepository;
     _pipeRepository = pipeRepository;
 }
Ejemplo n.º 35
0
        public TaskListModule(ITaskListRetriever taskListRetriever, ITaskRetriever taskRetriever, IAmACommandProcessor commandProcessor)
        {
            this.taskListRetriever = taskListRetriever;
            this.taskRetriever = taskRetriever;
            this.commandProcessor = commandProcessor;

            Get["/todo/index"] = _ => TasksView();
            Get["/todo/task/{id}"] = parameters => TaskDetails(parameters.id);
            Get["/todo/add"] = _ => TaskForm();
            Post["/todo/add"] = _ => AddTask();

        }
Ejemplo n.º 36
0
        public Dispatcher(IAmACommandProcessor commandProcessor, IAmAMessageMapperRegistry messageMapperRegistry, IEnumerable<Connection> connections, ILog logger)
        {
            this.commandProcessor = commandProcessor;
            this.messageMapperRegistry = messageMapperRegistry;
            this.logger = logger;
            State = DispatcherState.DS_NOTREADY;

            Consumers = new SynchronizedCollection<Consumer>();
            CreateConsumers(connections).Each(consumer => Consumers.Add(consumer));
            
            State = DispatcherState.DS_AWAITING;
            logger.Debug(m => m("Dispatcher is ready to recieve"));
        }
Ejemplo n.º 37
0
        public EmailsModule(IAmACommandProcessor commandProcessor)
            : base("/emails")
        {
            Post["/"] = _ =>
            {
                var request = this.Bind<EmailRequest>();

                commandProcessor.Send( new CreateAnEmailCommand(
                    email: new Email(
                        id: Guid.NewGuid(),
                        from: request.From,
                        to: request.To,
                        subject: request.Subject,
                        body: request.Body)));
                return HttpStatusCode.OK;
            };
        }
Ejemplo n.º 38
0
        public TasksModule(IRetrieveTaskViewModels taskViewModelRetriever,
            IBuildViews<TaskViewModel, TaskView> taskViewBuilder,
            IAmACommandProcessor commandProcessor)
        {
            this.taskViewModelRetriever = taskViewModelRetriever;
            this.taskViewBuilder = taskViewBuilder;
            this.commandProcessor = commandProcessor;

            Get["/tasks/{id}"] = _ =>
            {
                var viewModel = taskViewModelRetriever.Get(_.id);
                return taskViewBuilder.Build(viewModel);
            };

            Delete["/tasks/{id}"] = _ =>
            {
                var command = new CompleteTaskCommand(_.id, DateTime.UtcNow);
                commandProcessor.Send(command);
                return Negotiate.WithStatusCode(HttpStatusCode.OK);
            };
        }
 public StoreFrontController(IAmACommandProcessor commandProcessor)
 {
     _commandProcessor = commandProcessor;
 }
Ejemplo n.º 40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dispatcher"/> class.
        /// </summary>
        /// <param name="commandProcessor">The command processor.</param>
        /// <param name="messageMapperRegistry">The message mapper registry.</param>
        /// <param name="connections">The connections.</param>
        public Dispatcher(
            IAmACommandProcessor commandProcessor, 
            IAmAMessageMapperRegistry messageMapperRegistry,
            IEnumerable<Connection> connections)
        {
            CommandProcessor = commandProcessor;
            Connections = connections;
            _messageMapperRegistry = messageMapperRegistry;

            State = DispatcherState.DS_NOTREADY;

            _tasks = new ConcurrentDictionary<int, Task>();
            _consumers = new ConcurrentDictionary<string, IAmAConsumer>();

            State = DispatcherState.DS_AWAITING;
        }
Ejemplo n.º 41
0
 public VenueEndPointHandler(IAmAUnitOfWorkFactory unitOfWorkFactory, IAmACommandProcessor commandProcessor)
 {
     _unitOfWorkFactory = unitOfWorkFactory;
     this.commandProcessor = commandProcessor;
 }
 public CategoriesEndPointHandler(IAmACommandProcessor commandProcessor,
     IAmACategoryViewModelRetriever categoryViewModelRetriever)
 {
     _commandProcessor = commandProcessor;
     _categoryViewModelRetriever = categoryViewModelRetriever;
 }
 public TaskReminderEndpointHandler(IAmACommandProcessor commandProcessor)
 {
     _commandProcessor = commandProcessor;
 }
Ejemplo n.º 44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dispatcher"/> class.
        /// Use this if you need to inject a logger, for example for testing
        /// </summary>
        /// <param name="commandProcessor">The command processor.</param>
        /// <param name="messageMapperRegistry">The message mapper registry.</param>
        /// <param name="connections">The connections.</param>
        /// <param name="logger">The logger.</param>
        public Dispatcher(
            IAmACommandProcessor commandProcessor, 
            IAmAMessageMapperRegistry messageMapperRegistry, 
            IEnumerable<Connection> connections,
            ILog logger)
        {
            CommandProcessor = commandProcessor;
            _messageMapperRegistry = messageMapperRegistry;
            this.Connections = connections;
            _logger = logger;
            State = DispatcherState.DS_NOTREADY;

            Consumers = new SynchronizedCollection<IAmAConsumer>();

            State = DispatcherState.DS_AWAITING;
        }
Ejemplo n.º 45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dispatcher"/> class.
 /// </summary>
 /// <param name="commandProcessor">The command processor.</param>
 /// <param name="messageMapperRegistry">The message mapper registry.</param>
 /// <param name="connections">The connections.</param>
 public Dispatcher(
     IAmACommandProcessor commandProcessor, 
     IAmAMessageMapperRegistry messageMapperRegistry,
     IEnumerable<Connection> connections)
     :this(commandProcessor, messageMapperRegistry, connections, LogProvider.GetCurrentClassLogger())
 {}
Ejemplo n.º 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageController"/> class.
 /// </summary>
 /// <param name="commandProcessor"></param>
 /// <param name="pipeRepository">The pipe repository.</param>
 public MessageController(IAmACommandProcessor commandProcessor, IAmARepository<Pipe> pipeRepository)
 {
     _commandProcessor = commandProcessor;
     _pipeRepository = pipeRepository;
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedController"/> class.
 /// </summary>
 /// <param name="commandProcessor">The command processor.</param>
 /// <param name="feedRepository">The feed repository.</param>
 /// <param name="cachingHandler">The caching handler, used to invalidate related resources</param>
 public FeedController(IAmACommandProcessor commandProcessor, IAmARepository<Feed> feedRepository, ICachingHandler cachingHandler)
 {
     _commandProcessor = commandProcessor;
     _feedRepository = feedRepository;
     _cachingHandler = cachingHandler;
 }
 public ProductsController(ProductsDAO productsDao, IAmACommandProcessor commandProcessor)
 {
     _productsDao = productsDao;
     _commandProcessor = commandProcessor;
 }
Ejemplo n.º 49
0
 public OrdersController(OrdersDAO ordersDao, IAmACommandProcessor commandProcessor)
 {
     _ordersDao = ordersDao;
     _commandProcessor = commandProcessor;
 }
Ejemplo n.º 50
0
 public RemindersController(IAmACommandProcessor commandProcessor)
 {
     _commandProcessor = commandProcessor;
 }
Ejemplo n.º 51
0
 public TasksController(ITaskRetriever taskRetriever, ITaskListRetriever taskListRetriever, IAmACommandProcessor commandProcessor)
 {
     _taskRetriever = taskRetriever;
     _taskListRetriever = taskListRetriever;
     _commandProcessor = commandProcessor;
 }