public void ProcessingServer_PipelineOptions() { var factory = new EventBusFactory(); var server = new ProcessingServer(factory); var config = new PipelineConfiguration { Id = "test", InputHandler = new HandlerNode { Type = typeof(LogInputHandler) }, OutputHandlers = new List <HandlerNode> { new HandlerNode { Type = typeof(ConsoleOutputHandler) } }, Options = new PipelineOptions { MinProcessors = 1, MaxItemsInQueue = 100, MaxProcessors = 1 } }; server.SetupPipeline("test", config); var bus = factory.GetEventBus("test"); Assert.AreSame(bus.PipelineFactory.Options, config.Options); }
public void StaticServer_SetupPipeline_SimpleServer() { var pipelineId = new Guid("42C75D31-8679-49B4-B0EE-2B90D4C6B893").ToString(); var server = new ProcessingServer(); server.SetupPipeline(pipelineId, s => { s.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(new ConsoleOutputHandler()); return(pipeline); }); s.Register(new LogInputHandler()); }); var client = new EventDispatcher(server); client.Process(pipelineId, new LogMessage { Message = "SetupPipeline_SimpleServer" }); }
public void PluginManagerTests_BuildConfig() { var ctx = new ActivationContext(); ctx.Register <IEventDataConverter, EventDataConverter>(); var inputPlugin = _pluginMgr.GetPlugin(typeof(IInputHandler), "CustomInput"); var input = ctx.Resolve <IInputHandler>(inputPlugin.Type); var outputPlugin = _pluginMgr.GetPlugin(typeof(IOutputHandler), "ConsoleOutput"); var output = ctx.Resolve <IOutputHandler>(outputPlugin.Type); var pipelineId = Guid.NewGuid().ToString(); var loghandler = new LogQueueHandler(); var cnt = 0; var server = new ProcessingServer(); server.SetupPipeline(pipelineId, s => { s.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(output); pipeline.AddHandler(loghandler); cnt = cnt + 1; return(pipeline); }); s.Register(input); }); var client = new EventDispatcher(server); client.Process(pipelineId, new LogMessage { Message = "Event1" }); client.Process(pipelineId, new LogMessage { Message = "Event2" }); server.WaitAll(pipelineId); //Assert.That(cnt == 1, () => $"Count is {cnt} but is expected to be 1"); Assert.That(loghandler.Log.Count() == 2, () => $"Logcount is {loghandler.Log.Count()} but is expected to be 2"); }
public void ProcessingServer_UpdatePipeline() { var factory = new EventBusFactory(); var server = new ProcessingServer(factory); var config = new PipelineConfiguration { Id = "test", InputHandler = new HandlerNode { Type = typeof(LogInputHandler) }, OutputHandlers = new List <HandlerNode> { new HandlerNode { Type = typeof(ConsoleOutputHandler) } } }; server.SetupPipeline("test", config); var first = factory.GetEventBus("test"); var second = factory.GetEventBus("test"); Assert.AreSame(first, second); // update server.SetupPipeline("test", config); var third = factory.GetEventBus("test"); Assert.AreNotSame(first, third); }
public void Setup_Register_Factory_SetupPipeline_AddFilters() { var pipelineId = Guid.NewGuid().ToString(); var handler = new SetupOutputHandler(); var server = new ProcessingServer(); server.SetupPipeline(pipelineId, c => { c.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(handler, new[] {"Level -> dst_lvl", "Message"}); return pipeline; }); }); Assert.That(((DataFilterDecorator)GetOutputHandlers(server, pipelineId).Single()).Converter.Filters.Count() == 2); }
public void Setup_Register_Factory_SetupPipeline_FilterDecorator() { var pipelineId = Guid.NewGuid().ToString(); var handler = new SetupOutputHandler(); var server = new ProcessingServer(); server.SetupPipeline(pipelineId, c => { c.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(handler, new[] { "Level -> dst_lvl", "Message" }); return pipeline; }); }); Assert.IsAssignableFrom<DataFilterDecorator>(GetOutputHandlers(server, pipelineId).Single()); }
public void Setup_Register_Factory_SetupPipeline() { var pipelineId = Guid.NewGuid().ToString(); var handler = new SetupOutputHandler(); var server = new ProcessingServer(); server.SetupPipeline(pipelineId, c => { c.Register(() => { var pipeline = new EventPipeline(); pipeline.AddHandler(handler); return pipeline; }); }); Assert.AreSame(handler, GetOutputHandlers(server, pipelineId).Single()); }