Example #1
0
        static Task Connector(ChainFactory factory, TransportMessage message)
        {
            var pipeline = factory.Create();
            var context  = new IncomingContext(message);

            return(pipeline.Invoke(context));
        }
Example #2
0
        public async Task Do()
        {
            var messages = new ConcurrentQueue<TransportMessage>();
            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());

            var countdown = new AsyncCountdownEvent(3);

            var chainFactory = new ChainFactory();
            chainFactory.Register(() => new DelayElement());
            chainFactory.Register(() => new LogElement());
            chainFactory.Register(() => new DecrementElement(countdown));

            var pushMessages = new PushMessages(messages, maxConcurrency: 1);

            await pushMessages.StartAsync(tm => Connector(chainFactory, tm));

            await countdown.WaitAsync();

            await pushMessages.StopAsync();
        }
Example #3
0
        public async Task Do()
        {
            var messages = new ConcurrentQueue <TransportMessage>();

            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());

            var countdown = new AsyncCountdownEvent(3);

            var chainFactory = new ChainFactory();

            chainFactory.Register(() => new DelayElement());
            chainFactory.Register(() => new LogElement());
            chainFactory.Register(() => new DecrementElement(countdown));

            var pushMessages = new PushMessages(messages, maxConcurrency: 1);

            await pushMessages.StartAsync(tm => Connector(chainFactory, tm));

            await countdown.WaitAsync();

            await pushMessages.StopAsync();
        }
Example #4
0
 static Task Connector(ChainFactory factory, TransportMessage message)
 {
     var pipeline = factory.Create();
     var context = new IncomingContext(message);
     return pipeline.Invoke(context);
 }