shubhamranjan / dotnet-etcd

A C# .NET (dotnet) GRPC client for etcd v3 +
MIT License
266 stars 60 forks source link

Avoiding using 'async void' as function signature #40

Closed 9chu closed 4 years ago

9chu commented 4 years ago

Like calling LeaseKeepAlive, I have no way to detect whether it throws exception or not. Please consider using async Task to return a Task object to user.

shubhamranjan commented 4 years ago

Agreed. Using void with async is considered a bad practice as well. Something I learnt recently. Thanks for pointing out. Will fix this by tomorrow.

9chu commented 4 years ago

Thank you for your reply.

BTW, I am confused with the LeaseKeepAlive method. Seems I have to manually call it many times to keep a lease key alived, and the method it self will create a grpc stream every time.

I think providing a method to automatically call keepalive may be more convenient :)

// returns a infinite loop task that keeps the lease key any TTL/2 seconds
await client.LeaseKeepAlive(leaseId, cancellationToken);
shubhamranjan commented 4 years ago

Thank you for your reply.

BTW, I am confused with the LeaseKeepAlive method. Seems I have to manually call it many times to keep a lease key alived, and the method it self will create a grpc stream every time.

I think providing a method to automatically call keepalive may be more convenient :)

// returns a infinite loop task that keeps the lease key any TTL/2 seconds
await client.LeaseKeepAlive(leaseId, cancellationToken);

I will look into this and get back.