Example #1
0
        public static void DependendRequestsExample(MathGrpc.IMathServiceClient stub)
        {
            var numberList = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(), new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            numberList.ToObservable();

            //IObserver<Num> numbers;
            //Task<Num> call = stub.Sum(out numbers);
            //foreach (var num in numberList)
            //{
            //	numbers.OnNext(num);
            //}
            //numbers.OnCompleted();

            //Num sum = call.Result;

            //DivReply result = stub.Div(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numberList.Count }.Build());
        }
Example #2
0
        public static void SumExample(MathGrpc.IMathServiceClient stub)
        {
            List <Num> numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            var res = stub.Sum();

            foreach (var num in numbers)
            {
                res.Inputs.OnNext(num);
            }
            res.Inputs.OnCompleted();

            Console.WriteLine("Sum Result: " + res.Task.Result);
        }
Example #3
0
        public static void DivManyExample(MathGrpc.IMathServiceClient stub)
        {
            List <DivArgs> divArgsList = new List <DivArgs> {
                new DivArgs.Builder {
                    Dividend = 10, Divisor = 3
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 100, Divisor = 21
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 7, Divisor = 2
                }.Build()
            };

            var recorder = new RecordingObserver <DivReply>();

            var inputs = stub.DivMany(recorder);

            foreach (var input in divArgsList)
            {
                inputs.OnNext(input);
            }
            inputs.OnCompleted();

            Console.WriteLine("DivMany Result: " + string.Join("|", recorder.ToList().Result));
        }
Example #4
0
        public static void DivExample(MathGrpc.IMathServiceClient stub)
        {
            DivReply result = stub.Div(new DivArgs.Builder {
                Dividend = 10, Divisor = 3
            }.Build());

            Console.WriteLine("Div Result: " + result);
        }
Example #5
0
        public static void DivAsyncWithCancellationExample(MathGrpc.IMathServiceClient stub)
        {
            Task <DivReply> call = stub.DivAsync(new DivArgs.Builder {
                Dividend = 4, Divisor = 5
            }.Build());
            DivReply result = call.Result;

            Console.WriteLine(result);
        }
Example #6
0
        public static async Task DivAsyncWithCancellationExample(MathGrpc.IMathServiceClient stub)
        {
            Task <DivReply> resultTask = stub.DivAsync(new DivArgs.Builder {
                Dividend = 4, Divisor = 5
            }.Build());
            DivReply result = await resultTask;

            Console.WriteLine(result);
        }
Example #7
0
        public static async Task FibExample(MathGrpc.IMathServiceClient stub)
        {
            var recorder = new RecordingObserver <Num>();

            stub.Fib(new FibArgs.Builder {
                Limit = 5
            }.Build(), recorder);
            List <Num> result = await recorder.ToList();

            Console.WriteLine("Fib Result: " + string.Join("|", result));
        }
Example #8
0
        public void Init()
        {
            GrpcEnvironment.Initialize();

            server = new Server();
            server.AddServiceDefinition(MathGrpc.BindService(new MathServiceImpl()));
            int port = server.AddPort(host + ":0");

            server.Start();
            channel = new Channel(host + ":" + port);
            client  = MathGrpc.NewStub(channel);
        }
Example #9
0
        public static void DependendRequestsExample(MathGrpc.IMathServiceClient stub)
        {
            var numberList = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(), new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            numberList.ToObservable();
        }
Example #10
0
        public static async Task SumExample(MathGrpc.IMathServiceClient stub)
        {
            var numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            var clientStreamingResult = stub.Sum();

            numbers.Subscribe(clientStreamingResult.Inputs);
            Console.WriteLine("Sum Result: " + await clientStreamingResult.Task);
        }
Example #11
0
        public void Init()
        {
            GrpcEnvironment.Initialize();

            server = new Server();
            server.AddServiceDefinition(MathGrpc.BindService(new MathServiceImpl()));
            int port = server.AddListeningPort(host + ":0");

            server.Start();
            channel = new Channel(host + ":" + port);

            // TODO: get rid of the custom header here once we have dedicated tests
            // for header support.
            var stubConfig = new StubConfiguration((headerBuilder) =>
            {
                headerBuilder.Add(new Metadata.MetadataEntry("customHeader", "abcdef"));
            });

            client = MathGrpc.NewStub(channel, stubConfig);
        }
Example #12
0
        public static async Task DivManyExample(MathGrpc.IMathServiceClient stub)
        {
            var divArgsList = new List <DivArgs>
            {
                new DivArgs.Builder {
                    Dividend = 10, Divisor = 3
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 100, Divisor = 21
                }.Build(),
                new DivArgs.Builder {
                    Dividend = 7, Divisor = 2
                }.Build()
            };

            var recorder = new RecordingObserver <DivReply>();
            var inputs   = stub.DivMany(recorder);

            divArgsList.Subscribe(inputs);
            var result = await recorder.ToList();

            Console.WriteLine("DivMany Result: " + string.Join("|", result));
        }
Example #13
0
        public static async Task DependendRequestsExample(MathGrpc.IMathServiceClient stub)
        {
            var numbers = new List <Num>
            {
                new Num.Builder {
                    Num_ = 1
                }.Build(),
                new Num.Builder {
                    Num_ = 2
                }.Build(),
                new Num.Builder {
                    Num_ = 3
                }.Build()
            };

            var clientStreamingResult = stub.Sum();

            numbers.Subscribe(clientStreamingResult.Inputs);
            Num sum = await clientStreamingResult.Task;

            DivReply result = await stub.DivAsync(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numbers.Count }.Build());

            Console.WriteLine("Avg Result: " + result);
        }
Example #14
0
        public void Init()
        {
            GrpcEnvironment.Initialize();

            server = new Server();
            server.AddServiceDefinition(MathGrpc.BindService(new MathServiceImpl()));
            int port = server.AddPort(host + ":0");
            server.Start();
            channel = new Channel(host + ":" + port);
            client = MathGrpc.NewStub(channel);
        }
Example #15
0
        public void Init()
        {
            GrpcEnvironment.Initialize();

            server = new Server();
            server.AddServiceDefinition(MathGrpc.BindService(new MathServiceImpl()));
            int port = server.AddListeningPort(host + ":0");
            server.Start();
            channel = new Channel(host + ":" + port);

            // TODO: get rid of the custom header here once we have dedicated tests
            // for header support.
            var stubConfig = new StubConfiguration((headerBuilder) =>
            {
                headerBuilder.Add(new Metadata.MetadataEntry("customHeader", "abcdef"));
            });
            client = MathGrpc.NewStub(channel, stubConfig);
        }