コード例 #1
0
        public void PartitionWithRouter()
        {
            var config = new MemoryAccount();
            var raw    = new RawEngineBuilder();

            var inWriter = config.CreateQueueWriter("in");
            var doWriter = config.CreateQueueWriter("do");

            // forwarder in => do
            raw.Dispatch(config.CreateInbox("in"), doWriter.PutMessage);
            // forwarder do => in
            raw.Dispatch(config.CreateInbox("do"), inWriter.PutMessage);


            TestConfiguration(inWriter, raw);
        }
コード例 #2
0
        public void Test()
        {
            using (var source = new CancellationTokenSource())
            {
                var dev = AzureStorage.CreateConfigurationForDev();
                WipeAzureAccount.Fast(s => s.StartsWith("test-"), dev);
                var b = new RawEngineBuilder();
                b.Dispatch(dev.CreateInbox("test-publish"), bytes =>
                {
                    if (bytes[0] == 42)
                    {
                        source.Cancel();
                    }
                });


                using (var engine = b.Build())
                {
                    var task = engine.Start(source.Token);

                    dev.CreateQueueWriter("test-publish").PutMessage(new byte[] { 42 });
                    if (!task.Wait(5000))
                    {
                        source.Cancel();
                    }
                }
            }
        }
コード例 #3
0
        public void RouterChain()
        {
            var config   = new MemoryAccount();
            var raw      = new RawEngineBuilder();
            var doWriter = config.CreateQueueWriter("do");

            var route1 = config.CreateQueueWriter("route1");
            var route2 = config.CreateQueueWriter("route2");

            // in => (route1 OR route2)
            raw.Dispatch(config.CreateInbox("in"), bytes => LoadBalance(bytes, route1, route2));
            // forwarder (route1,route2) => do
            raw.Dispatch(config.CreateInbox("route1", "route2"), doWriter.PutMessage);

            raw.Dispatch(config.CreateInbox("do"), bytes => LoadBalance(bytes, route1, route2));
            TestConfiguration(config.CreateQueueWriter("in"), raw);
        }
コード例 #4
0
        public void Direct()
        {
            var config   = new MemoryAccount();
            var raw      = new RawEngineBuilder();
            var doWriter = config.CreateQueueWriter("do");

            // forwarder do => do
            raw.Dispatch(config.CreateInbox("do"), doWriter.PutMessage);
            TestConfiguration(doWriter, raw);
        }
コード例 #5
0
        public void Memory_lambda()
        {
            var config = new MemoryAccount();
            var writer = config.CreateQueueWriter("test");
            var inbox  = config.CreateInbox("test");

            var builder = new RawEngineBuilder();

            builder.Dispatch(inbox, bytes => { });

            var setup = new Setup
            {
                Send   = i => writer.PutMessage(new[] { i }),
                Engine = builder.Build()
            };

            TestConfiguration(setup, 1000000);
        }
コード例 #6
0
        public void File_lambda()
        {
            var config = FileStorage.CreateConfig("throughput-tests");

            config.Wipe();

            var writer  = config.CreateQueueWriter("test");
            var inbox   = config.CreateInbox("test", u => TimeSpan.FromMilliseconds(0));
            var builder = new RawEngineBuilder();

            builder.Dispatch(inbox, bytes => { });

            var setup = new Setup
            {
                Send   = i => writer.PutMessage(new[] { i }),
                Engine = builder.Build()
            };

            TestConfiguration(setup, 1000);
        }
コード例 #7
0
        public void Throughput_Azure_lambda()
        {
            var config = AzureStorage.CreateConfigurationForDev();

            WipeAzureAccount.Fast(s => s.StartsWith("throughput"), config);

            var writer  = config.CreateQueueWriter("test");
            var inbox   = config.CreateInbox("test", u => TimeSpan.Zero);
            var builder = new RawEngineBuilder();

            builder.Dispatch(inbox, bytes => { });

            var setup = new Setup
            {
                Send   = i => writer.PutMessage(new[] { i }),
                Engine = builder.Build()
            };

            TestConfiguration(setup, 100);
        }