private static async Task AddProductAsync(ProductsProtoService.ProductsProtoServiceClient client) { Console.WriteLine("AddProductAsync started.."); var addProductResponse = await client.AddProductAsync( new AddProductRequest { Product = new ProductModel { Created = Timestamp.FromDateTime(DateTime.UtcNow), Description = "Added Product", Name = "Name", Price = 1799, Status = ProductStatus.Instock } } ); Console.WriteLine("GetAllProducts started.." + addProductResponse.ToString()); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { await Task.Delay(_config.GetValue <int>("WorkerService:TaskInterval"), stoppingToken); while (!stoppingToken.IsCancellationRequested) { _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); using var channel = GrpcChannel.ForAddress(_config.GetValue <string>("WorkerService:ServerUrl")); var client = new ProductsProtoService.ProductsProtoServiceClient(channel); _logger.LogInformation("AddProduct started"); var addProductResponse = await client.AddProductAsync(await _factory.Generate()); _logger.LogInformation("AddProduct - " + addProductResponse.ToString()); await Task.Delay(_config.GetValue <int>("WorkerService:TaskInterval"), stoppingToken); } }