Skip to content

Commit

Permalink
update dora_coordinator::start to return bound addr instead of just t…
Browse files Browse the repository at this point in the history
…he port
  • Loading branch information
Michael-J-Ward committed Apr 16, 2024
1 parent 279530e commit 1ba763c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions binaries/coordinator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ mod tcp_utils;
pub async fn start(
bind: SocketAddr,
external_events: impl Stream<Item = Event> + Unpin,
) -> Result<(u16, impl Future<Output = eyre::Result<()>>), eyre::ErrReport> {
) -> Result<(SocketAddr, impl Future<Output = eyre::Result<()>>), eyre::ErrReport> {
let listener = listener::create_listener(bind).await?;
let port = listener
let bound_addr = listener
.local_addr()
.wrap_err("failed to get local addr of listener")?
.port();
.wrap_err("failed to get local addr of listener")?;
let mut tasks = FuturesUnordered::new();

// Setup ctrl-c handler
Expand All @@ -61,7 +60,7 @@ pub async fn start(
tracing::debug!("all spawned tasks finished, exiting..");
Ok(())
};
Ok((port, future))
Ok((bound_addr, future))
}

// Resolve the dataflow name.
Expand Down
3 changes: 1 addition & 2 deletions examples/multiple-daemons/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ async fn main() -> eyre::Result<()> {
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
DORA_COORDINATOR_PORT_DEFAULT,
);
let (coordinator_port, coordinator) =
let (coordinator_addr, coordinator) =
dora_coordinator::start(coordinator_bind, ReceiverStream::new(coordinator_events_rx))
.await?;
let coordinator_addr = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), coordinator_port);
let daemon_a = run_daemon(coordinator_addr.to_string(), "A".into());
let daemon_b = run_daemon(coordinator_addr.to_string(), "B".into());

Expand Down

0 comments on commit 1ba763c

Please sign in to comment.