Exemplo n.º 1
0
        /// <summary>
        /// Backpressure.
        /// </summary>
        /// <returns></returns>
        static async Task RequestChannelTest_Backpressure()
        {
            string testName = "RequestChannelTest_Backpressure";

            Console.WriteLine($"{testName} start....................................................");

            int initialRequest = 2;
            //int initialRequest = int.MaxValue;

            var source = new OutputPublisher(_client, 5);             //Create an object that supports backpressure.
            IPublisher <Payload> result = _client.RequestChannel("data".ToReadOnlySequence(), "metadata".ToReadOnlySequence(), source, initialRequest);

            result = result.ObserveOn(TaskPoolScheduler.Default);
            StreamSubscriber subscriber = new StreamSubscriber(initialRequest);

            subscriber.MaxReceives = 3;
            var subscription = result.Subscribe(subscriber);

            subscriber.OnSubscribe(subscription);

            await subscriber.Block();

            Console.WriteLine($"server message: {subscriber.MsgList.Count}");

            Console.WriteLine($"{testName} over....................................................");
        }
Exemplo n.º 2
0
        static async Task RequestStreamTest1()
        {
            int initialRequest = 2;
            //int initialRequest = int.MaxValue;

            IPublisher <Payload> result = _client.RequestStream("data".ToReadOnlySequence(), "metadata".ToReadOnlySequence(), initialRequest);

            result = result.ObserveOn(TaskPoolScheduler.Default);
            StreamSubscriber subscriber = new StreamSubscriber(initialRequest);

            subscriber.MaxReceives = 3;
            var subscription = result.Subscribe(subscriber);

            subscriber.OnSubscribe(subscription);

            await subscriber.Block();

            Console.WriteLine($"server message total: {subscriber.MsgList.Count}");

            Console.WriteLine($"RequestStreamTest1 over....................................................");
        }
Exemplo n.º 3
0
        static async Task RequestChannelTest1()
        {
            string testName = "RequestChannelTest1";

            Console.WriteLine($"{testName} start....................................................");
            int initialRequest = 2;
            //int initialRequest = int.MaxValue;

            IPublisher <Payload> result = RequestChannel(5, initialRequest);

            result = result.ObserveOn(TaskPoolScheduler.Default);
            StreamSubscriber subscriber = new StreamSubscriber(initialRequest);

            subscriber.MaxReceives = 3;
            var subscription = result.Subscribe(subscriber);

            subscriber.OnSubscribe(subscription);

            await subscriber.Block();

            Console.WriteLine($"server message: {subscriber.MsgList.Count}");

            Console.WriteLine($"{testName} over....................................................");
        }