Esempio 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....................................................");
        }
Esempio n. 2
0
 public Task RequestChannel(IRSocketRPCStream stream, string service, string method, ReadOnlySequence <byte> data, ReadOnlySequence <byte> metadata       = default, ReadOnlySequence <byte> tracing = default, int initial = RSocketClient.INITIALDEFAULT) => Client.RequestChannel(new RemoteProcedureCall(stream), data, new RemoteProcedureCall.RemoteProcedureCallMetadata(service, method, metadata, tracing), initial);