It should be _easy_ to detect when a stream ends
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Feature Request
Simply put, when I have stream, I may need to do cleanup when it is closed. Everything else is a memory leak.
There are multiple issues that discuss this, most notably https://github.com/hyperium/tonic/issues/377
The solution proposed in the referenced issue is far from trivial. I don't consider replacing low level details related to future impls a sufficient solution for a library at the level of tonic. While I will be forced to get down to that level in my app, I am fairly certain that the API this should be providing is one of an enum, say
```rust
enum StreamEvent {
Message(T),
ClientDisconnect,
// the following is more of a guess
Error(E),
}
```
This feels quite natural to me, and so I wonder why it isn't already done this (or a similar) way. Are there technical difficulties to detect connection termination? Any other "hard" reason? Or was this just never tackled?
### Motivation
It is of utmost relevance to clean up resources that are not needed anymore
### Proposal
See above
### Alternatives
One could track connections via IDs and have a separate event that tells us which ones have terminated, but I feel that would increase complexity
Contributor guide
Assessment
This issue has not been assessed yet.