sync: support cancel_rx in ttrpc context#197
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #197 +/- ##
==========================================
- Coverage 24.47% 24.17% -0.30%
==========================================
Files 17 17
Lines 2521 2552 +31
==========================================
Hits 617 617
- Misses 1904 1935 +31
☔ View full report in Codecov by Sentry. |
9def45a to
f9bff19
Compare
| async-trait = { version = "0.1.31", optional = true } | ||
| tokio = { version = "1", features = ["rt", "sync", "io-util", "macros", "time"], optional = true } | ||
| futures = { version = "0.3", optional = true } | ||
| crossbeam = "0.8.0" |
There was a problem hiding this comment.
Is there a reason to use crossbeam here? The rest of the code uses the std::sync::mpsc::Receiver/Sender
There was a problem hiding this comment.
With crossbeam channel, we can use select! in ttrpc method handler.
like:
select! {
recv(ticker) -> _ => println!("elapsed: {:?}", start.elapsed()),
recv(timeout) -> _ => break,
}
There was a problem hiding this comment.
interesting! seems like a possibly good improvement thought I would tend towards bring in crossbeam as dep in separate PR across all the areas where std::sync::mpsc::Receiver/Sender is used to keep it similiar throughout the codebase. I will defer to the maintainers though.
src/sync/server.rs
Outdated
| .send(()) | ||
| .unwrap_or_else(|err| trace!("Failed to send {:?}", err)); | ||
| trace!("Socket error send control_tx"); | ||
| trace!("wrokload_rx recv error, send control_tx"); |
There was a problem hiding this comment.
| trace!("wrokload_rx recv error, send control_tx"); | |
| trace!("workload_rx recv error, send control_tx"); |
f9bff19 to
b743c4e
Compare
just rustup format code Signed-off-by: yuqitao <yuqitao1024@qq.com>
add cancel_rx in ttrpcContext which can help method.handler to realize the client has been closed, like context.Done in golang ttrpc. Signed-off-by: yuqitao <yuqitao1024@qq.com>
b743c4e to
100cff9
Compare
|
@lifupan @jsturtevant PTAL. |
|
@Tim-Zhang The CI seems to have some wired error, could you help solving it please? |
Cut the release for containerd#196, containerd#197, containerd#200, containerd#203, containerd#208 Signed-off-by: Tim Zhang <tim@hyper.sh>
sync: support cancel_rx in ttrpc context
Cut the release for containerd#196, containerd#197, containerd#200, containerd#203, containerd#208 Signed-off-by: Tim Zhang <tim@hyper.sh>
Fixes: #180