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