adds initial rcs implementation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use api::client::Client;
|
||||
use api::client::telemetry::{TelemetryHandle, TelemetryRegistry};
|
||||
use futures::TryFutureExt;
|
||||
use futures::future::join_all;
|
||||
use futures::future::{Either, join_all, select};
|
||||
use futures::{TryFutureExt, pin_mut};
|
||||
use log::{error, trace};
|
||||
use nautilus_common::on_drop::on_drop;
|
||||
use nautilus_common::telemetry::{CommsState, SwitchBank, Telemetry, TelemetryMessage};
|
||||
@@ -12,7 +12,7 @@ use std::sync::Arc;
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::sync::{RwLock, RwLockWriteGuard};
|
||||
use tokio::task::yield_now;
|
||||
use tokio::{join, pin, select, try_join};
|
||||
use tokio::{join, select, try_join};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
pub struct TelemetryHandler<'a> {
|
||||
@@ -52,7 +52,18 @@ impl<'a> TelemetryHandler<'a> {
|
||||
.build()?;
|
||||
|
||||
runtime.block_on(async {
|
||||
let mut context = TelemetryContext::new(&self).await;
|
||||
// Allow cancellation while waiting for this to initialize
|
||||
let mut context = {
|
||||
let context = TelemetryContext::new(&self);
|
||||
pin_mut!(context);
|
||||
let cancellation_future = self.cancel.cancelled();
|
||||
pin_mut!(cancellation_future);
|
||||
let init_or_cancel = select(context, cancellation_future).await;
|
||||
match init_or_cancel {
|
||||
Either::Left((success, _)) => success,
|
||||
Either::Right(_) => return Ok(()),
|
||||
}
|
||||
};
|
||||
|
||||
let mut buffer = [0u8; 512];
|
||||
|
||||
@@ -75,7 +86,7 @@ impl<'a> TelemetryHandler<'a> {
|
||||
// Update the value in the lock
|
||||
*lock = addr;
|
||||
};
|
||||
pin!(flight_addr_update);
|
||||
tokio::pin!(flight_addr_update);
|
||||
|
||||
// We can do these two operations concurrently
|
||||
join!(
|
||||
|
||||
Reference in New Issue
Block a user