split NetworkBridge into two subsystems (#5616)

* foo

* rolling session window

* fixup

* remove use statemetn

* fmt

* split NetworkBridge into two subsystems

Pending cleanup

* split

* chore: reexport OrchestraError as OverseerError

* chore: silence warnings

* fixup tests

* chore: add default timenout of 30s to subsystem test helper ctx handle

* single item channel

* fixins

* fmt

* cleanup

* remove dead code

* remove sync bounds again

* wire up shared state

* deal with some FIXMEs

* use distinct tags

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>

* use tag

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>

* address naming

tx and rx are common in networking and also have an implicit meaning regarding networking
compared to incoming and outgoing which are already used with subsystems themselvesq

* remove unused sync oracle

* remove unneeded state

* fix tests

* chore: fmt

* do not try to register twice

* leak Metrics type

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
Bernhard Schuster
2022-07-12 18:22:36 +02:00
committed by GitHub
parent c11c1f38f4
commit 3240cb5e4d
40 changed files with 1880 additions and 1429 deletions
@@ -245,20 +245,37 @@ pub struct TestSubsystemContextHandle<M> {
}
impl<M> TestSubsystemContextHandle<M> {
/// Fallback timeout value used to never block test execution
/// indefinitely.
pub const TIMEOUT: Duration = Duration::from_secs(120);
/// Send a message or signal to the subsystem. This resolves at the point in time when the
/// subsystem has _read_ the message.
pub async fn send(&mut self, from_overseer: FromOrchestra<M>) {
self.tx.send(from_overseer).await.expect("Test subsystem no longer live");
self.tx
.send(from_overseer)
.timeout(Self::TIMEOUT)
.await
.expect("`fn send` does not timeout")
.expect("Test subsystem no longer live");
}
/// Receive the next message from the subsystem.
pub async fn recv(&mut self) -> AllMessages {
self.try_recv().await.expect("Test subsystem no longer live")
self.try_recv()
.timeout(Self::TIMEOUT)
.await
.expect("`fn recv` does not timeout")
.expect("Test subsystem no longer live")
}
/// Receive the next message from the subsystem, or `None` if the channel has been closed.
pub async fn try_recv(&mut self) -> Option<AllMessages> {
self.rx.next().await
self.rx
.next()
.timeout(Self::TIMEOUT)
.await
.expect("`try_recv` does not timeout")
}
}