Beispiel #1
0
        private static async Task UnaryRetry(Retrier.RetrierClient client)
        {
            Console.WriteLine("Delivering packages...");
            foreach (var product in Products)
            {
                try
                {
                    var package = new Package {
                        Name = product
                    };
                    var call     = client.DeliverPackageAsync(package);
                    var response = await call;

                    #region Print success
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write(response.Message);
                    Console.ResetColor();
                    Console.Write(" " + await GetRetryCount(call.ResponseHeadersAsync));
                    Console.WriteLine();
                    #endregion
                }
                catch (RpcException ex)
                {
                    #region Print failure
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Status.Detail);
                    Console.ResetColor();
                    #endregion
                }

                await Task.Delay(TimeSpan.FromSeconds(0.2));
            }
        }
Beispiel #2
0
        static async Task Main(string[] args)
        {
            using var channel = CreateChannel();
            var client = new Retrier.RetrierClient(channel);

            await UnaryRetry(client);

            Console.WriteLine("Shutting down");
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }