public void Should_display_a_FilterSegment() { var end = PipeSegment.End <ClaimModified>(); Pipe filter = PipeSegment.Filter <object>(end); new TracePipeVisitor().Trace(filter); }
private Pipe VisitObjectRecipientList(RecipientListSegment recipientList) { var result = base.VisitRecipientList(recipientList) as RecipientListSegment; if (result == null) { return(null); } if (_bound) { return(result); } Pipe list = PipeSegment.RecipientList(_segment.MessageType, new[] { _segment }); Pipe filter = PipeSegment.Filter(list, _segment.MessageType); IList <Pipe> recipients = new List <Pipe>(result.Recipients); recipients.Add(filter); _bound = true; return(new RecipientListSegment(recipientList.MessageType, recipients)); }
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 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(); }
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); }