Skip to content

Instantly share code, notes, and snippets.

@neuecc
Created March 16, 2022 09:50
Show Gist options
  • Select an option

  • Save neuecc/76c0ef8dba112b3b9919f4d601c6d707 to your computer and use it in GitHub Desktop.

Select an option

Save neuecc/76c0ef8dba112b3b9919f4d601c6d707 to your computer and use it in GitHub Desktop.
public class GrpcTest : Workload
{
GrpcChannel? channel;
Greeter.GreeterClient? client;
public override async Task SetupAsync(WorkloadContext context)
{
channel = GrpcChannel.ForAddress("http://localhost:5027");
client = new Greeter.GreeterClient(channel);
}
public override async Task ExecuteAsync(WorkloadContext context)
{
await client!.SayHelloAsync(new HelloRequest(), cancellationToken: context.CancellationToken);
}
public override async Task TeardownAsync(WorkloadContext context)
{
if (channel != null)
{
await channel.ShutdownAsync();
channel.Dispose();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment