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

Awaiting disconnection of Receiver or Sender #119

Open
Kijewski opened this issue Mar 2, 2023 · 2 comments
Open

Awaiting disconnection of Receiver or Sender #119

Kijewski opened this issue Mar 2, 2023 · 2 comments

Comments

@Kijewski
Copy link

Kijewski commented Mar 2, 2023

I want to do something similar to this:

let msg = select! {
    tx.disconnected() => return Err("disconnected");
    result = read_some_stream() => result?,
};
let msg = process(msg);
if tx.send_async(msg).await.is_err() {
    return Err("disconnected");
}

I.e. I want to asynchronously read from some source, and pass the result to a channel. If the channel gets disconnected in the meantime, I want to know that immediately, not only when I send a message.

Would it be possible to add such a feature? I did try to read the code and to implement it myself, but I failed miserably.

@zesterer
Copy link
Owner

zesterer commented Mar 2, 2023

I think implementing a disconnect signal would probably take some time. Is it not feasible to have the thread/task on the other end of the channel to send some sort of shutdown signal?

@Kijewski
Copy link
Author

Kijewski commented Mar 2, 2023

Yes, I could use a CancellationToken for example. I thought maybe you would know a simple way to implemented that feature.

I think it such a method would be nice to have in flume itself, but if it does not get added, that would not be too terrible either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants