Unverified Commit bce74588 authored by Graham King's avatar Graham King Committed by GitHub
Browse files

chore: Rust to 1.89 and edition 2024 (#2659)

parent 268d017e
...@@ -20,8 +20,8 @@ use std::sync::Arc; ...@@ -20,8 +20,8 @@ use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use async_trait::async_trait; use async_trait::async_trait;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
use super::{KeyValueBucket, KeyValueStore, StorageError, StorageOutcome}; use super::{KeyValueBucket, KeyValueStore, StorageError, StorageOutcome};
......
...@@ -17,7 +17,7 @@ use crate::config::HealthStatus; ...@@ -17,7 +17,7 @@ use crate::config::HealthStatus;
use crate::logging::make_request_span; use crate::logging::make_request_span;
use crate::metrics::MetricsRegistry; use crate::metrics::MetricsRegistry;
use crate::traits::DistributedRuntimeProvider; use crate::traits::DistributedRuntimeProvider;
use axum::{http::StatusCode, response::IntoResponse, routing::get, Router}; use axum::{Router, http::StatusCode, response::IntoResponse, routing::get};
use serde_json::json; use serde_json::json;
use std::sync::{Arc, OnceLock}; use std::sync::{Arc, OnceLock};
use std::time::Instant; use std::time::Instant;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use crate::{error, CancellationToken, ErrorContext, Result, Runtime}; use crate::{CancellationToken, ErrorContext, Result, Runtime, error};
use async_nats::jetstream::kv; use async_nats::jetstream::kv;
use derive_builder::Builder; use derive_builder::Builder;
...@@ -21,7 +21,7 @@ use derive_getters::Dissolve; ...@@ -21,7 +21,7 @@ use derive_getters::Dissolve;
use futures::StreamExt; use futures::StreamExt;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::{mpsc, RwLock}; use tokio::sync::{RwLock, mpsc};
use validator::Validate; use validator::Validate;
use etcd_client::{ use etcd_client::{
...@@ -29,7 +29,7 @@ use etcd_client::{ ...@@ -29,7 +29,7 @@ use etcd_client::{
TlsOptions, Txn, TxnOp, TxnOpResponse, WatchOptions, Watcher, TlsOptions, Txn, TxnOp, TxnOpResponse, WatchOptions, Watcher,
}; };
pub use etcd_client::{ConnectOptions, KeyValue, LeaseClient}; pub use etcd_client::{ConnectOptions, KeyValue, LeaseClient};
use tokio::time::{interval, Duration}; use tokio::time::{Duration, interval};
mod lease; mod lease;
mod path; mod path;
...@@ -605,7 +605,7 @@ impl KvCache { ...@@ -605,7 +605,7 @@ impl KvCache {
#[cfg(feature = "integration")] #[cfg(feature = "integration")]
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{distributed::DistributedConfig, DistributedRuntime}; use crate::{DistributedRuntime, distributed::DistributedConfig};
use super::*; use super::*;
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
//! - `NATS_AUTH_CREDENTIALS_FILE`: the path to the credentials file //! - `NATS_AUTH_CREDENTIALS_FILE`: the path to the credentials file
//! //!
//! Note: `NATS_AUTH_USERNAME` and `NATS_AUTH_PASSWORD` must be used together. //! Note: `NATS_AUTH_USERNAME` and `NATS_AUTH_PASSWORD` must be used together.
use crate::{metrics::MetricsRegistry, Result}; use crate::{Result, metrics::MetricsRegistry};
use async_nats::connection::State; use async_nats::connection::State;
use async_nats::{client, jetstream, Subscriber}; use async_nats::{Subscriber, client, jetstream};
use bytes::Bytes; use bytes::Bytes;
use derive_builder::Builder; use derive_builder::Builder;
use futures::{StreamExt, TryStreamExt}; use futures::{StreamExt, TryStreamExt};
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
//! equivalent of a connection pool per upstream service at the cost of needing an extra internal //! equivalent of a connection pool per upstream service at the cost of needing an extra internal
//! routing step per service endpoint. //! routing step per service endpoint.
use anyhow::{anyhow, Result}; use anyhow::{Result, anyhow};
use async_zmq::{Context, Dealer, Router, Sink, SinkExt, StreamExt}; use async_zmq::{Context, Dealer, Router, Sink, SinkExt, StreamExt};
use bytes::Bytes; use bytes::Bytes;
use derive_getters::Dissolve; use derive_getters::Dissolve;
...@@ -36,7 +36,7 @@ use futures::TryStreamExt; ...@@ -36,7 +36,7 @@ use futures::TryStreamExt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{collections::HashMap, os::fd::FromRawFd, sync::Arc, time::Duration, vec::IntoIter}; use std::{collections::HashMap, os::fd::FromRawFd, sync::Arc, time::Duration, vec::IntoIter};
use tokio::{ use tokio::{
sync::{mpsc, Mutex}, sync::{Mutex, mpsc},
task::{JoinError, JoinHandle}, task::{JoinError, JoinHandle},
}; };
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
......
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
// limitations under the License. // limitations under the License.
use crate::{ use crate::{
transports::etcd::{Client, WatchEvent},
DistributedRuntime, DistributedRuntime,
transports::etcd::{Client, WatchEvent},
}; };
use serde::{de::DeserializeOwned, Serialize}; use serde::{Serialize, de::DeserializeOwned};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::marker::PhantomData; use std::marker::PhantomData;
......
...@@ -283,7 +283,7 @@ impl<T: Returnable> Clone for Pool<T> { ...@@ -283,7 +283,7 @@ impl<T: Returnable> Clone for Pool<T> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use tokio::time::{timeout, Duration}; use tokio::time::{Duration, timeout};
// Implement Returnable for u32 just for testing // Implement Returnable for u32 just for testing
impl Returnable for u32 { impl Returnable for u32 {
......
...@@ -20,7 +20,7 @@ use std::{ ...@@ -20,7 +20,7 @@ use std::{
task::{Context, Poll}, task::{Context, Poll},
}; };
use tokio::time::{self, sleep_until, Duration, Instant, Sleep}; use tokio::time::{self, Duration, Instant, Sleep, sleep_until};
pub struct DeadlineStream<S> { pub struct DeadlineStream<S> {
stream: S, stream: S,
......
...@@ -197,14 +197,14 @@ impl CriticalTaskExecutionHandle { ...@@ -197,14 +197,14 @@ impl CriticalTaskExecutionHandle {
/// Note: Both errors and panics trigger parent cancellation immediately via the monitor task. /// Note: Both errors and panics trigger parent cancellation immediately via the monitor task.
pub async fn join(mut self) -> Result<()> { pub async fn join(mut self) -> Result<()> {
self.detached = true; self.detached = true;
let result = match self.result_receiver.take().unwrap().await {
match self.result_receiver.take().unwrap().await {
Ok(task_result) => task_result, Ok(task_result) => task_result,
Err(_) => { Err(_) => {
// This should rarely happen - means monitor task was dropped/cancelled // This should rarely happen - means monitor task was dropped/cancelled
Err(anyhow::anyhow!("Critical task monitor was cancelled")) Err(anyhow::anyhow!("Critical task monitor was cancelled"))
} }
}; }
result
} }
/// Detach the task. This allows the task to continue running after the handle is dropped. /// Detach the task. This allows the task to continue running after the handle is dropped.
...@@ -224,8 +224,8 @@ impl Drop for CriticalTaskExecutionHandle { ...@@ -224,8 +224,8 @@ impl Drop for CriticalTaskExecutionHandle {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::time::Duration; use std::time::Duration;
use tokio::time::timeout; use tokio::time::timeout;
......
...@@ -380,8 +380,8 @@ ...@@ -380,8 +380,8 @@
use std::future::Future; use std::future::Future;
use std::pin::Pin; use std::pin::Pin;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::{AtomicU64, Ordering};
use crate::metrics::MetricsRegistry; use crate::metrics::MetricsRegistry;
use anyhow::Result; use anyhow::Result;
...@@ -395,7 +395,7 @@ use tokio::sync::Semaphore; ...@@ -395,7 +395,7 @@ use tokio::sync::Semaphore;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
use tokio_util::task::TaskTracker as TokioTaskTracker; use tokio_util::task::TaskTracker as TokioTaskTracker;
use tracing::{debug, error, warn, Instrument}; use tracing::{Instrument, debug, error, warn};
use uuid::Uuid; use uuid::Uuid;
/// Error type for task execution results /// Error type for task execution results
...@@ -4713,11 +4713,13 @@ mod tests { ...@@ -4713,11 +4713,13 @@ mod tests {
// Now, trying to create a child should fail // Now, trying to create a child should fail
let result = parent_clone.child_tracker(); let result = parent_clone.child_tracker();
assert!(result.is_err()); assert!(result.is_err());
assert!(result assert!(
.err() result
.unwrap() .err()
.to_string() .unwrap()
.contains("closed parent tracker")); .to_string()
.contains("closed parent tracker")
);
} }
#[rstest] #[rstest]
...@@ -4740,11 +4742,13 @@ mod tests { ...@@ -4740,11 +4742,13 @@ mod tests {
// Now, trying to create a child with builder should fail // Now, trying to create a child with builder should fail
let result = parent_clone.child_tracker_builder().build(); let result = parent_clone.child_tracker_builder().build();
assert!(result.is_err()); assert!(result.is_err());
assert!(result assert!(
.err() result
.unwrap() .err()
.to_string() .unwrap()
.contains("closed parent tracker")); .to_string()
.contains("closed parent tracker")
);
} }
#[rstest] #[rstest]
...@@ -4909,9 +4913,11 @@ mod tests { ...@@ -4909,9 +4913,11 @@ mod tests {
// Test conversion to anyhow::Error // Test conversion to anyhow::Error
let anyhow_error = anyhow::Error::new(continuation_error); let anyhow_error = anyhow::Error::new(continuation_error);
assert!(anyhow_error assert!(
.to_string() anyhow_error
.contains("Task failed with continuation")); .to_string()
.contains("Task failed with continuation")
);
} }
#[test] #[test]
...@@ -5046,9 +5052,11 @@ mod tests { ...@@ -5046,9 +5052,11 @@ mod tests {
let anyhow_error = FailedWithContinuation::into_anyhow(source_error, restartable_task); let anyhow_error = FailedWithContinuation::into_anyhow(source_error, restartable_task);
assert!(anyhow_error.has_continuation()); assert!(anyhow_error.has_continuation());
assert!(anyhow_error assert!(
.to_string() anyhow_error
.contains("Task failed with continuation")); .to_string()
.contains("Task failed with continuation")
);
assert!(anyhow_error.to_string().contains("Computation failed")); assert!(anyhow_error.to_string().contains("Computation failed"));
} }
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
//! This module provides reusable patterns for watching etcd prefixes and maintaining //! This module provides reusable patterns for watching etcd prefixes and maintaining
//! HashMap-based state that automatically updates based on etcd events. //! HashMap-based state that automatically updates based on etcd events.
use crate::transports::etcd::{Client as EtcdClient, WatchEvent};
use crate::Result; use crate::Result;
use crate::transports::etcd::{Client as EtcdClient, WatchEvent};
use etcd_client::KeyValue; use etcd_client::KeyValue;
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use std::collections::HashMap; use std::collections::HashMap;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
// different types of workers to define their own load metrics and busy thresholds. // different types of workers to define their own load metrics and busy thresholds.
use crate::component::{Client, InstanceSource}; use crate::component::{Client, InstanceSource};
use crate::traits::events::EventSubscriber;
use crate::traits::DistributedRuntimeProvider; use crate::traits::DistributedRuntimeProvider;
use crate::traits::events::EventSubscriber;
use crate::utils::typed_prefix_watcher::{key_extractors, watch_prefix_with_extraction}; use crate::utils::typed_prefix_watcher::{key_extractors, watch_prefix_with_extraction};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
//! and release builds. In development, the default is [DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_DEBUG] and //! and release builds. In development, the default is [DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_DEBUG] and
//! in release, the default is [DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_RELEASE]. //! in release, the default is [DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_RELEASE].
use super::{error, CancellationToken, Result, Runtime, RuntimeConfig}; use super::{CancellationToken, Result, Runtime, RuntimeConfig, error};
use futures::Future; use futures::Future;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
...@@ -198,14 +198,13 @@ impl Worker { ...@@ -198,14 +198,13 @@ impl Worker {
})))) }))))
.expect("Failed to spawn application task"); .expect("Failed to spawn application task");
let task = INIT INIT
.get() .get()
.expect("Application task not initialized") .expect("Application task not initialized")
.lock() .lock()
.unwrap() .unwrap()
.take() .take()
.expect("Application initialized; but another thread is awaiting it; Worker.execute() can only be called once"); .expect("Application initialized; but another thread is awaiting it; Worker.execute() can only be called once")
task
} }
pub fn from_current() -> Result<Worker> { pub fn from_current() -> Result<Worker> {
......
...@@ -27,8 +27,8 @@ use dynamo_runtime::engine::{ ...@@ -27,8 +27,8 @@ use dynamo_runtime::engine::{
}; };
use dynamo_runtime::pipeline::{ use dynamo_runtime::pipeline::{
context::{Context, StreamContext},
Error, ManyOut, SingleIn, Error, ManyOut, SingleIn,
context::{Context, StreamContext},
}; };
pub type AsyncFn<T, U> = dyn Fn(T) -> Pin<Box<dyn Future<Output = U> + Send>> + Send + Sync; pub type AsyncFn<T, U> = dyn Fn(T) -> Pin<Box<dyn Future<Output = U> + Send>> + Send + Sync;
......
...@@ -25,8 +25,8 @@ use tokio::sync::mpsc; ...@@ -25,8 +25,8 @@ use tokio::sync::mpsc;
use dynamo_runtime::engine::{AsyncEngine, AsyncEngineContext, Data, ResponseStream}; use dynamo_runtime::engine::{AsyncEngine, AsyncEngineContext, Data, ResponseStream};
use dynamo_runtime::pipeline::{ use dynamo_runtime::pipeline::{
context::{Context, StreamContext},
Error, ManyOut, PipelineError, PipelineIO, SegmentSource, SingleIn, Error, ManyOut, PipelineError, PipelineIO, SegmentSource, SingleIn,
context::{Context, StreamContext},
}; };
#[allow(dead_code)] #[allow(dead_code)]
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use dynamo_runtime::{worker::Worker, Result, Runtime}; use dynamo_runtime::{Result, Runtime, worker::Worker};
async fn hello_world(_runtime: Runtime) -> Result<()> { async fn hello_world(_runtime: Runtime) -> Result<()> {
Ok(()) Ok(())
......
...@@ -15,17 +15,17 @@ ...@@ -15,17 +15,17 @@
#![allow(dead_code)] #![allow(dead_code)]
use futures::{stream, StreamExt}; use futures::{StreamExt, stream};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
use dynamo_runtime::engine::ResponseStream; use dynamo_runtime::engine::ResponseStream;
use dynamo_runtime::{ use dynamo_runtime::{
Error,
pipeline::{ pipeline::{
async_trait, AsyncEngine, Data, Event, ManyOut, Operator, ServiceBackend, ServiceEngine, AsyncEngine, Data, Event, ManyOut, Operator, ServiceBackend, ServiceEngine,
ServiceFrontend, SingleIn, *, ServiceFrontend, SingleIn, async_trait, *,
}, },
Error,
}; };
mod common; mod common;
...@@ -153,8 +153,8 @@ fn make_postprocessor() -> Arc<PipelineNode<ManyOut<Annotated<String>>, ManyOut< ...@@ -153,8 +153,8 @@ fn make_postprocessor() -> Arc<PipelineNode<ManyOut<Annotated<String>>, ManyOut<
// Node 0: // Node 0:
// [frontend] -------[pre processor]-----> [backend] // [frontend] -------[pre processor]-----> [backend]
// [frontend] <----- [post processor] ---- [backend] // [frontend] <----- [post processor] ---- [backend]
fn make_service( fn make_service()
) -> Result<ServiceEngine<SingleIn<String>, ManyOut<Annotated<String>>>, PipelineError> { -> Result<ServiceEngine<SingleIn<String>, ManyOut<Annotated<String>>>, PipelineError> {
// Frontend - Callable interface // Frontend - Callable interface
let frontend = ServiceFrontend::<SingleIn<String>, ManyOut<Annotated<String>>>::new(); let frontend = ServiceFrontend::<SingleIn<String>, ManyOut<Annotated<String>>>::new();
...@@ -253,14 +253,16 @@ async fn test_disaggregated_service() { ...@@ -253,14 +253,16 @@ async fn test_disaggregated_service() {
// } // }
// assert_eq!(counter, 20); // assert_eq!(counter, 20);
println!("Test blocked: SegmentSink::attach requires Arc<dyn AsyncEngine> but AsyncEngineStream cannot be Sync"); println!(
"Test blocked: SegmentSink::attach requires Arc<dyn AsyncEngine> but AsyncEngineStream cannot be Sync"
);
} }
// Node 0: // Node 0:
// [frontend] --> [pre processor] --> [operator] ----------------------> [backend] // [frontend] --> [pre processor] --> [operator] ----------------------> [backend]
// [frontend] <---------------------- [operator] <--[post processor] <-- [backend] // [frontend] <---------------------- [operator] <--[post processor] <-- [backend]
fn make_service_with_operator( fn make_service_with_operator()
) -> Result<ServiceEngine<SingleIn<String>, ManyOut<Annotated<String>>>, PipelineError> { -> Result<ServiceEngine<SingleIn<String>, ManyOut<Annotated<String>>>, PipelineError> {
// Frontend - Callable interface // Frontend - Callable interface
let frontend = ServiceFrontend::<SingleIn<String>, ManyOut<Annotated<String>>>::new(); let frontend = ServiceFrontend::<SingleIn<String>, ManyOut<Annotated<String>>>::new();
......
...@@ -30,18 +30,18 @@ mod integration { ...@@ -30,18 +30,18 @@ mod integration {
pub const DEFAULT_NAMESPACE: &str = "dynamo"; pub const DEFAULT_NAMESPACE: &str = "dynamo";
use dynamo_runtime::{ use dynamo_runtime::{
logging, DistributedRuntime, ErrorContext, Result, Runtime, Worker, logging,
pipeline::{ pipeline::{
async_trait, network::Ingress, AsyncEngine, AsyncEngineContextProvider, Error, ManyOut, AsyncEngine, AsyncEngineContextProvider, Error, ManyOut, PushRouter, ResponseStream,
PushRouter, ResponseStream, SingleIn, SingleIn, async_trait, network::Ingress,
}, },
protocols::annotated::Annotated, protocols::annotated::Annotated,
stream, DistributedRuntime, ErrorContext, Result, Runtime, Worker, stream,
}; };
use futures::StreamExt; use futures::StreamExt;
use std::{ use std::{
sync::atomic::{AtomicU64, Ordering},
sync::Arc, sync::Arc,
sync::atomic::{AtomicU64, Ordering},
time::Duration, time::Duration,
}; };
use tokio::time::Instant; use tokio::time::Instant;
......
[toolchain] [toolchain]
channel = "1.87.0" channel = "1.89.0"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment