Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

etcd watch function support asynchronous method #64

Closed
MJEdwin opened this issue Sep 14, 2020 · 1 comment · Fixed by #163
Closed

etcd watch function support asynchronous method #64

MJEdwin opened this issue Sep 14, 2020 · 1 comment · Fixed by #163
Labels
enhancement New feature or request up-for-grabs
Projects

Comments

@MJEdwin
Copy link

MJEdwin commented Sep 14, 2020

when i use dotnet-etcd some watch method,it was blocked my code and i can not run code after watch method invoked

code:

etcdClient.Watch("services", WatchDelegate, cancellationToken: cancellationTokenSource.Token); //blocked

//Set
await etcdClient.PutAsync(new PutRequest { Key = ByteString.CopyFromUtf8("services"), Value = ByteString.CopyFromUtf8("test") });
await etcdClient.PutAsync("services/demo", "test");

future:

add asynchronous method

Task watchTask = etcdClient.WatchAsync("services", WatchDelegate, cancellationToken: cancellationTokenSource.Token); //unblocked
//Set
await etcdClient.PutAsync(new PutRequest { Key = ByteString.CopyFromUtf8("services"), Value = ByteString.CopyFromUtf8("test") });
await etcdClient.PutAsync("services/demo", "test");
await watchTask;   //blocked
@shubhamranjan
Copy link
Owner

Hi, With the current implementation you can use other watch overloads which accept WatchRequest instead of a string param. You can create a watch request like this:

            WatchRequest request = new WatchRequest()
            {
                CreateRequest = new WatchCreateRequest()
                {
                    Key = ByteString.CopyFromUtf8(services)
                }
            };

and pass it over.

There are a lot of async overloads here.

I agree that there should be overloads for string params as well since there is one for sync calls. I will keep this open until I provide one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request up-for-grabs
Projects
dotnet-etcd
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants