diff --git a/grpc/src/client/channel.rs b/grpc/src/client/channel.rs index edbd55131..b817fc2de 100644 --- a/grpc/src/client/channel.rs +++ b/grpc/src/client/channel.rs @@ -25,21 +25,17 @@ use core::panic; use std::{ any::Any, - collections::HashMap, error::Error, - fmt::Display, mem, - ops::Add, str::FromStr, - sync::{Arc, Mutex, Weak}, + sync::{Arc, Mutex}, time::{Duration, Instant}, vec, }; -use tokio::sync::{mpsc, oneshot, watch, Notify}; +use tokio::sync::{mpsc, watch, Notify}; use serde_json::json; -use tonic::async_trait; use url::Url; // NOTE: http::Uri requires non-empty authority portion of URI use crate::attributes::Attributes; @@ -48,25 +44,20 @@ use crate::service::{Request, Response, Service}; use crate::{client::ConnectivityState, rt::Runtime}; use crate::{credentials::Credentials, rt::default_runtime}; +use super::name_resolution::{self, global_registry, Address, ResolverUpdate}; use super::service_config::ServiceConfig; use super::transport::{TransportRegistry, GLOBAL_TRANSPORT_REGISTRY}; use super::{ load_balancing::{ - self, pick_first, ExternalSubchannel, LbPolicy, LbPolicyBuilder, LbPolicyOptions, - LbPolicyRegistry, LbState, ParsedJsonLbConfig, PickResult, Picker, Subchannel, - SubchannelState, WorkScheduler, GLOBAL_LB_REGISTRY, + self, pick_first, ExternalSubchannel, LbPolicy, LbPolicyBuilder, LbPolicyOptions, LbState, + ParsedJsonLbConfig, PickResult, Picker, Subchannel, SubchannelState, WorkScheduler, + GLOBAL_LB_REGISTRY, }, subchannel::{ InternalSubchannel, InternalSubchannelPool, NopBackoff, SubchannelKey, SubchannelStateWatcher, }, }; -use super::{ - name_resolution::{ - self, global_registry, Address, ResolverBuilder, ResolverOptions, ResolverUpdate, - }, - subchannel, -}; #[non_exhaustive] pub struct ChannelOptions { diff --git a/grpc/src/client/load_balancing/child_manager.rs b/grpc/src/client/load_balancing/child_manager.rs index 9501bccb1..1c1cba8df 100644 --- a/grpc/src/client/load_balancing/child_manager.rs +++ b/grpc/src/client/load_balancing/child_manager.rs @@ -360,29 +360,22 @@ impl WorkScheduler for ChildWorkScheduler { #[cfg(test)] mod test { use crate::client::load_balancing::child_manager::{ - Child, ChildManager, ChildUpdate, ChildWorkScheduler, ResolverUpdateSharder, + ChildManager, ChildUpdate, ResolverUpdateSharder, }; use crate::client::load_balancing::test_utils::{ - self, StubPolicy, StubPolicyFuncs, TestChannelController, TestEvent, TestSubchannel, - TestWorkScheduler, + self, StubPolicyFuncs, TestChannelController, TestEvent, }; use crate::client::load_balancing::{ - ChannelController, LbPolicy, LbPolicyBuilder, LbPolicyOptions, LbState, ParsedJsonLbConfig, - Pick, PickResult, Picker, QueuingPicker, Subchannel, SubchannelState, GLOBAL_LB_REGISTRY, + ChannelController, LbPolicy, LbPolicyBuilder, LbState, QueuingPicker, Subchannel, + SubchannelState, GLOBAL_LB_REGISTRY, }; use crate::client::name_resolution::{Address, Endpoint, ResolverUpdate}; - use crate::client::service_config::{LbConfig, ServiceConfig}; use crate::client::ConnectivityState; - use crate::rt::{default_runtime, Runtime}; - use crate::service::Request; - use serde::{Deserialize, Serialize}; - use std::collections::{HashMap, HashSet}; + use crate::rt::default_runtime; use std::error::Error; use std::panic; use std::sync::Arc; - use std::sync::Mutex; use tokio::sync::mpsc; - use tonic::metadata::MetadataMap; // TODO: This needs to be moved to a common place that can be shared between // round_robin and this test. This EndpointSharder maps endpoints to diff --git a/grpc/src/client/load_balancing/mod.rs b/grpc/src/client/load_balancing/mod.rs index b4d61e0ce..01f9dea41 100644 --- a/grpc/src/client/load_balancing/mod.rs +++ b/grpc/src/client/load_balancing/mod.rs @@ -23,27 +23,20 @@ */ use core::panic; -use serde::de; use std::{ any::Any, - collections::HashMap, error::Error, fmt::{Debug, Display}, hash::{Hash, Hasher}, - ops::{Add, Sub}, ptr::addr_eq, - sync::{ - atomic::{AtomicI64, Ordering::Relaxed}, - Arc, Mutex, Weak, - }, + sync::{Arc, Mutex, Weak}, }; -use tokio::sync::{mpsc::Sender, Notify}; use tonic::{metadata::MetadataMap, Status}; use crate::{ client::channel::WorkQueueTx, rt::Runtime, - service::{Request, Response, Service}, + service::{Request, Response}, }; use crate::client::{ @@ -60,7 +53,7 @@ pub mod test_utils; pub(crate) mod registry; use super::{service_config::LbConfig, subchannel::SubchannelStateWatcher}; -pub(crate) use registry::{LbPolicyRegistry, GLOBAL_LB_REGISTRY}; +pub(crate) use registry::GLOBAL_LB_REGISTRY; /// A collection of data configured on the channel that is constructing this /// LbPolicy. diff --git a/grpc/src/client/load_balancing/pick_first.rs b/grpc/src/client/load_balancing/pick_first.rs index 6ac901709..2f9cbd9f8 100644 --- a/grpc/src/client/load_balancing/pick_first.rs +++ b/grpc/src/client/load_balancing/pick_first.rs @@ -1,8 +1,4 @@ -use std::{ - error::Error, - sync::{Arc, Mutex}, - time::Duration, -}; +use std::{error::Error, sync::Arc, time::Duration}; use tonic::metadata::MetadataMap; @@ -10,7 +6,7 @@ use crate::{ client::{ load_balancing::{LbPolicy, LbPolicyBuilder, LbState}, name_resolution::{Address, ResolverUpdate}, - subchannel, ConnectivityState, + ConnectivityState, }, rt::Runtime, service::Request, diff --git a/grpc/src/client/load_balancing/test_utils.rs b/grpc/src/client/load_balancing/test_utils.rs index a7fb623fb..0069fc929 100644 --- a/grpc/src/client/load_balancing/test_utils.rs +++ b/grpc/src/client/load_balancing/test_utils.rs @@ -23,25 +23,16 @@ */ use crate::client::load_balancing::{ - ChannelController, ExternalSubchannel, ForwardingSubchannel, LbPolicy, LbPolicyBuilder, - LbPolicyOptions, LbState, ParsedJsonLbConfig, Pick, PickResult, Picker, Subchannel, - SubchannelState, WorkScheduler, GLOBAL_LB_REGISTRY, + ChannelController, ForwardingSubchannel, LbPolicy, LbPolicyBuilder, LbPolicyOptions, LbState, + ParsedJsonLbConfig, Subchannel, SubchannelState, WorkScheduler, }; use crate::client::name_resolution::{Address, ResolverUpdate}; use crate::client::service_config::LbConfig; -use crate::client::ConnectivityState; -use crate::service::{Message, Request, Response, Service}; -use serde::{Deserialize, Serialize}; -use std::any::Any; -use std::collections::HashMap; +use crate::service::{Message, Request}; use std::error::Error; -use std::hash::{Hash, Hasher}; -use std::sync::Mutex; -use std::{fmt::Debug, ops::Add, sync::Arc}; -use tokio::sync::mpsc::Sender; +use std::hash::Hash; +use std::{fmt::Debug, sync::Arc}; use tokio::sync::{mpsc, Notify}; -use tokio::task::AbortHandle; -use tonic::metadata::MetadataMap; #[derive(Debug)] pub(crate) struct EmptyMessage {} diff --git a/grpc/src/client/name_resolution/mod.rs b/grpc/src/client/name_resolution/mod.rs index bc2c9ef42..28f6ba91f 100644 --- a/grpc/src/client/name_resolution/mod.rs +++ b/grpc/src/client/name_resolution/mod.rs @@ -33,7 +33,7 @@ use super::service_config::ServiceConfig; use crate::{attributes::Attributes, byte_str::ByteStr, rt::Runtime}; use std::{ fmt::{Display, Formatter}, - hash::{Hash, Hasher}, + hash::Hash, str::FromStr, sync::Arc, }; diff --git a/grpc/src/client/subchannel.rs b/grpc/src/client/subchannel.rs index 4b5c314fc..114c277e7 100644 --- a/grpc/src/client/subchannel.rs +++ b/grpc/src/client/subchannel.rs @@ -1,16 +1,12 @@ use super::{ channel::{InternalChannelController, WorkQueueTx}, - load_balancing::{self, ExternalSubchannel, Picker, Subchannel, SubchannelState}, + load_balancing::{ExternalSubchannel, SubchannelState}, name_resolution::Address, - transport::{self, Transport, TransportRegistry}, + transport::Transport, ConnectivityState, }; use crate::{ - client::{ - channel::WorkQueueItem, - subchannel, - transport::{ConnectedTransport, TransportOptions}, - }, + client::{channel::WorkQueueItem, transport::TransportOptions}, rt::{BoxedTaskHandle, Runtime}, service::{Request, Response, Service}, }; @@ -20,10 +16,9 @@ use std::{ collections::BTreeMap, error::Error, fmt::{Debug, Display}, - ops::Sub, sync::{Arc, Mutex, RwLock, Weak}, }; -use tokio::sync::{mpsc, oneshot, watch, Notify}; +use tokio::sync::{mpsc, oneshot}; use tonic::async_trait; type SharedService = Arc; diff --git a/grpc/src/inmemory/mod.rs b/grpc/src/inmemory/mod.rs index b9dae99e0..cf3f4ae8b 100644 --- a/grpc/src/inmemory/mod.rs +++ b/grpc/src/inmemory/mod.rs @@ -1,6 +1,6 @@ +use std::collections::HashMap; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::{Arc, LazyLock, Mutex}; -use std::{collections::HashMap, ops::Add}; use crate::{ client::{ @@ -14,7 +14,7 @@ use crate::{ server, service::{Request, Response, Service}, }; -use tokio::sync::{mpsc, oneshot, Mutex as AsyncMutex, Notify}; +use tokio::sync::{mpsc, oneshot, Mutex as AsyncMutex}; use tonic::async_trait; pub struct Listener { diff --git a/grpc/src/lib.rs b/grpc/src/lib.rs index 512adbc8f..0ee9831f8 100644 --- a/grpc/src/lib.rs +++ b/grpc/src/lib.rs @@ -29,7 +29,7 @@ //! APIs are unstable. Proceed at your own risk. //! //! [gRPC]: https://grpc.io -#![allow(dead_code, unused_variables, unused_imports)] +#![allow(dead_code, unused_variables)] pub mod client; pub mod credentials;