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

Asynchronous subscribe callback #639

Closed
BrennanConroy opened this issue Jun 1, 2017 · 6 comments
Closed

Asynchronous subscribe callback #639

BrennanConroy opened this issue Jun 1, 2017 · 6 comments

Comments

@BrennanConroy
Copy link

Currently you can pass in an Action to Subscribe and SubscribeAsync
We would like to be able to pass in an asynchronous Action i.e. Func<Task> callback that gets awaited in StackExchange.Redis.

@mgravell
Copy link
Collaborator

mgravell commented Jun 1, 2017 via email

@Salgat
Copy link

Salgat commented Jul 18, 2017

@mgravell For sequential subs, how do you pause the subscription without blocking a thread? The usual response is to offload to a queue, but the problem with that is if there are too many pending events to fit into a queue.

@niemyjski
Copy link

I also have that same question. I'm changing our implementation back to async void as I feel like I could be contributing to thread pool exhaustion with the current GetAwaiter().GetResult(). Do you have any suggestions?

@NickCraver
Copy link
Collaborator

I'm marking as v2, not as a promise, but that we'll take a hard look at this along with the other API additions and changes.

@mgravell
Copy link
Collaborator

mgravell commented Jul 6, 2018

The entire concept of an async task here only makes sense in the "everything in sequence" (PreserveAsyncOrder) scenario - in the "any order" scenario... meh, just use async void, nobody is waiting for you.

So; on the latter: this is implemented in v2; you need to use a slightly different API:

foo.Subscribe(key).OnMessage(handler);

The foo.Subscribe(key) here gives you a ChannelMessageQueue, which has OnMessage overloads for both synchronous (Action<RedisChannel, RedisValue>) and asynchronous (Func<RedisChannel, RedisValue, Task>) operations; in the latter case, it is awaited correctly for each operation.

@mgravell mgravell closed this as completed Jul 6, 2018
NickCraver pushed a commit that referenced this issue Jul 21, 2019
Including v2 API mentioned in #639 for both synchronous and asynchronous handlers.
ttingen pushed a commit to ttingen/StackExchange.Redis that referenced this issue Nov 19, 2019
Including v2 API mentioned in StackExchange#639 for both synchronous and asynchronous handlers.
ttingen pushed a commit to ttingen/StackExchange.Redis that referenced this issue Nov 19, 2019
Including v2 API mentioned in StackExchange#639 for both synchronous and asynchronous handlers.
ttingen pushed a commit to ttingen/StackExchange.Redis that referenced this issue Nov 19, 2019
Including v2 API mentioned in StackExchange#639 for both synchronous and asynchronous handlers.
ttingen pushed a commit to ttingen/StackExchange.Redis that referenced this issue Nov 19, 2019
Including v2 API mentioned in StackExchange#639 for both synchronous and asynchronous handlers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants