public StraightThroughPipelineRunner() { Pipe consumer = PipeSegment.Consumer <ClaimModified>(m => Interlocked.Increment(ref _count)); _input = PipeSegment.Input(consumer); _message = new ClaimModified(); }
public void Should_display_a_complex_segment_chain() { var consumer = PipeSegment.Consumer <ClaimModified>(x => { }); var end = PipeSegment.End <ClaimModified>(); var recipientList = PipeSegment.RecipientList <ClaimModified>(new Pipe[] { consumer, end }); var filter = PipeSegment.Filter <object>(recipientList); Pipe input = PipeSegment.Input(filter); new TracePipeVisitor().Trace(input); }
public void Subscribe <T>(MessageConsumer <T> consumer) where T : class { Pipe segment = PipeSegment.Consumer(consumer); var binder = new SubscriberBinder(segment); binder.Bind(_pipe); _disposables.Add(segment); }
public void Should_not_pass_unwanted_types_through_the_filter() { var received = new Future <bool>(); Pipe consumer = PipeSegment.Consumer <SubClass>(x => received.Complete(true)); Pipe filter = PipeSegment.Filter <object>(consumer); filter.Send(new BaseClass()); received.WaitUntilCompleted(TimeSpan.Zero).ShouldBeFalse(); }
// ReSharper disable UnusedMember.Local private void SubscribeComponent <TConsumer, TMessage>(Func <TConsumer> getConsumer) // ReSharper restore UnusedMember.Local where TConsumer : IConsumer <TMessage> where TMessage : class { Pipe segment = PipeSegment.Consumer <TConsumer, TMessage>(getConsumer); var binder = new SubscriberBinder(segment); binder.Bind(_pipe); _disposables.Add(segment); }
public void Should_result_in_an_expression_being_called() { var called = new ManualResetEvent(false); var consumer = PipeSegment.Consumer <ClaimModified>(message => called.Set()); var recipients = new[] { consumer }; var recipientList = PipeSegment.RecipientList <ClaimModified>(recipients); recipientList.Send(new ClaimModified()); Assert.IsTrue(called.WaitOne(TimeSpan.Zero, false)); }
public RecipientListPipelineRunner() { Pipe consumer = PipeSegment.Consumer <ClaimModified>(m => Interlocked.Increment(ref _count)); Pipe consumer2 = PipeSegment.Consumer <ClaimModified>(m => Interlocked.Increment(ref _count2)); var recipients = new[] { consumer, consumer2 }; Pipe recipientList = PipeSegment.RecipientList <ClaimModified>(recipients); Pipe filter = PipeSegment.Filter <object>(recipientList); Pipe objectRecipientList = PipeSegment.RecipientList <object>(new[] { filter }); _input = PipeSegment.Input(objectRecipientList); _message = new ClaimModified(); }
public void Should_contain_all_nodes() { MessageConsumerSegment consumer = PipeSegment.Consumer <SomethingHappenedEvent>(x => { }); EndSegment end = PipeSegment.End <SomethingHappenedEvent>(); RecipientListSegment recipientList = PipeSegment.RecipientList <SomethingHappenedEvent>(new Pipe[] { consumer, end }); FilterSegment filter = PipeSegment.Filter <object>(recipientList); Pipe input = PipeSegment.Input(filter); //var generator = new PipelineGraphGenerator(); //string filename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "graph.png"); //generator.SaveGraphToFile(input.GetGraphData(), 2560, 1920, filename); PipelineDebugVisualizer.TestShowVisualizer(input.GetGraphData()); }
public void How_many_messages_can_the_pipe_send_per_second() { _count = 0; _count2 = 0; _limit = 5000000; Pipe consumer = PipeSegment.Consumer <ClaimModified>(m => { Interlocked.Increment(ref _count); }); Pipe consumer2 = PipeSegment.Consumer <ClaimModified>(m => { Interlocked.Increment(ref _count2); }); var recipients = new[] { consumer, consumer2 }; Pipe recipientList = PipeSegment.RecipientList <ClaimModified>(recipients); Pipe filter = PipeSegment.Filter <object>(recipientList); Pipe objectRecipientList = PipeSegment.RecipientList <object>(new[] { filter }); _input = PipeSegment.Input(objectRecipientList); var message = new ClaimModified(); for (int i = 0; i < 100; i++) { _input.Send(message); } _count = 0; _count2 = 0; Thread pusherThread = new Thread(Pusher); Thread pusherThread2 = new Thread(Pusher); Stopwatch timer = Stopwatch.StartNew(); pusherThread.Start(); pusherThread2.Start(); pusherThread.Join(10000); pusherThread2.Join(1000); timer.Stop(); Trace.WriteLine("Received: " + (_count + _count2) + ", expected " + _limit * 2); Trace.WriteLine("Elapsed Time: " + timer.ElapsedMilliseconds + "ms"); Trace.WriteLine("Messages Per Second: " + _limit * 1000 / timer.ElapsedMilliseconds); }
public void Should_display_a_MessageConsumerSegment() { Pipe consumer = PipeSegment.Consumer <ClaimModified>(x => { }); new TracePipeVisitor().Trace(consumer); }