Example #1
0
        private static void GreetWithDelay(Channel channel)
        {
            Console.WriteLine("Greet unary with delay");
            var client = new GreetingService.GreetingServiceClient(channel);

            var greeting = new Greeting()
            {
                FirstName = "Stanislaw",
                LastName  = "Banski"
            };

            try
            {
                var request = new GreetWithDeadlineRequest()
                {
                    Greeting = greeting
                };

                var response = client.GreetWithDeadline(request, deadline: DateTime.UtcNow.AddMilliseconds(100));

                Console.WriteLine(response.Result);
                Console.WriteLine("");
            }
            catch (RpcException e) when(e.StatusCode == StatusCode.DeadlineExceeded)
            {
                Console.WriteLine("Error : " + e.Status.Detail);
            }
        }
Example #2
0
        public override async Task <GreetWithDeadlineResponse> GreetWithDeadline(GreetWithDeadlineRequest request, ServerCallContext context)
        {
            await Task.Delay(300);

            return(new GreetWithDeadlineResponse()
            {
                Result = $"Hello {request.Greeting.FirstName} {request.Greeting.LastName}"
            });
        }