Overseer: subsystems communicate directly (#2227)

* overseer: pass messages directly between subsystems

* test that message is held on to

* Update node/overseer/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* give every subsystem an unbounded sender too

* remove metered_channel::name

1. we don't provide good names
2. these names are never used anywhere

* unused mut

* remove unnecessary &mut

* subsystem unbounded_send

* remove unused MaybeTimer

We have channel size metrics that serve the same purpose better now and the implementation of message timing was pretty ugly.

* remove comment

* split up senders and receivers

* update metrics

* fix tests

* fix test subsystem context

* fix flaky test

* fix docs

* doc

* use select_biased to favor signals

* Update node/subsystem/src/lib.rs

Co-authored-by: Andronik Ordian <write@reusable.software>

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
Robert Habermeier
2021-03-28 17:55:10 +02:00
committed by GitHub
parent c6f07d8f31
commit 5952e790fa
9 changed files with 1353 additions and 690 deletions
+5 -12
View File
@@ -30,8 +30,6 @@ pub use self::unbounded::*;
/// A peek into the inner state of a meter.
#[derive(Debug, Clone, Default)]
pub struct Meter {
/// Name of the receiver and sender pair.
name: &'static str,
// Number of sends on this channel.
sent: Arc<AtomicUsize>,
// Number of receives on this channel.
@@ -60,11 +58,6 @@ impl Meter {
}
}
/// Obtain the name of the channel `Sender` and `Receiver` pair.
pub fn name(&self) -> &'static str {
self.name
}
fn note_sent(&self) {
self.sent.fetch_add(1, Ordering::Relaxed);
}
@@ -92,7 +85,7 @@ mod tests {
#[test]
fn try_send_try_next() {
block_on(async move {
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
let (mut tx, mut rx) = channel::<Msg>(5);
let msg = Msg::default();
assert_eq!(rx.meter().read(), Readout { sent: 0, received: 0 });
tx.try_send(msg).unwrap();
@@ -116,7 +109,7 @@ mod tests {
fn with_tasks() {
let (ready, go) = futures::channel::oneshot::channel();
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
let (mut tx, mut rx) = channel::<Msg>(5);
block_on(async move {
futures::join!(
async move {
@@ -149,7 +142,7 @@ mod tests {
#[test]
fn stream_and_sink() {
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
let (mut tx, mut rx) = channel::<Msg>(5);
block_on(async move {
futures::join!(
@@ -175,8 +168,8 @@ mod tests {
#[test]
fn failed_send_does_not_inc_sent() {
let (mut bounded, _) = channel::<Msg>(5, "pluto");
let (mut unbounded, _) = unbounded::<Msg>("pluto");
let (mut bounded, _) = channel::<Msg>(5);
let (mut unbounded, _) = unbounded::<Msg>();
block_on(async move {
assert!(bounded.send(Msg::default()).await.is_err());