Skip to content

Commit 7a5b5bf

Browse files
authored
chore(grpc): remove many unused imports and re-enable linter (#2441)
1 parent 8921a2d commit 7a5b5bf

File tree

9 files changed

+29
-70
lines changed

9 files changed

+29
-70
lines changed

grpc/src/client/channel.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,17 @@
2525
use core::panic;
2626
use std::{
2727
any::Any,
28-
collections::HashMap,
2928
error::Error,
30-
fmt::Display,
3129
mem,
32-
ops::Add,
3330
str::FromStr,
34-
sync::{Arc, Mutex, Weak},
31+
sync::{Arc, Mutex},
3532
time::{Duration, Instant},
3633
vec,
3734
};
3835

39-
use tokio::sync::{mpsc, oneshot, watch, Notify};
36+
use tokio::sync::{mpsc, watch, Notify};
4037

4138
use serde_json::json;
42-
use tonic::async_trait;
4339
use url::Url; // NOTE: http::Uri requires non-empty authority portion of URI
4440

4541
use crate::attributes::Attributes;
@@ -48,25 +44,20 @@ use crate::service::{Request, Response, Service};
4844
use crate::{client::ConnectivityState, rt::Runtime};
4945
use crate::{credentials::Credentials, rt::default_runtime};
5046

47+
use super::name_resolution::{self, global_registry, Address, ResolverUpdate};
5148
use super::service_config::ServiceConfig;
5249
use super::transport::{TransportRegistry, GLOBAL_TRANSPORT_REGISTRY};
5350
use super::{
5451
load_balancing::{
55-
self, pick_first, ExternalSubchannel, LbPolicy, LbPolicyBuilder, LbPolicyOptions,
56-
LbPolicyRegistry, LbState, ParsedJsonLbConfig, PickResult, Picker, Subchannel,
57-
SubchannelState, WorkScheduler, GLOBAL_LB_REGISTRY,
52+
self, pick_first, ExternalSubchannel, LbPolicy, LbPolicyBuilder, LbPolicyOptions, LbState,
53+
ParsedJsonLbConfig, PickResult, Picker, Subchannel, SubchannelState, WorkScheduler,
54+
GLOBAL_LB_REGISTRY,
5855
},
5956
subchannel::{
6057
InternalSubchannel, InternalSubchannelPool, NopBackoff, SubchannelKey,
6158
SubchannelStateWatcher,
6259
},
6360
};
64-
use super::{
65-
name_resolution::{
66-
self, global_registry, Address, ResolverBuilder, ResolverOptions, ResolverUpdate,
67-
},
68-
subchannel,
69-
};
7061

7162
#[non_exhaustive]
7263
pub struct ChannelOptions {

grpc/src/client/load_balancing/child_manager.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,29 +360,22 @@ impl WorkScheduler for ChildWorkScheduler {
360360
#[cfg(test)]
361361
mod test {
362362
use crate::client::load_balancing::child_manager::{
363-
Child, ChildManager, ChildUpdate, ChildWorkScheduler, ResolverUpdateSharder,
363+
ChildManager, ChildUpdate, ResolverUpdateSharder,
364364
};
365365
use crate::client::load_balancing::test_utils::{
366-
self, StubPolicy, StubPolicyFuncs, TestChannelController, TestEvent, TestSubchannel,
367-
TestWorkScheduler,
366+
self, StubPolicyFuncs, TestChannelController, TestEvent,
368367
};
369368
use crate::client::load_balancing::{
370-
ChannelController, LbPolicy, LbPolicyBuilder, LbPolicyOptions, LbState, ParsedJsonLbConfig,
371-
Pick, PickResult, Picker, QueuingPicker, Subchannel, SubchannelState, GLOBAL_LB_REGISTRY,
369+
ChannelController, LbPolicy, LbPolicyBuilder, LbState, QueuingPicker, Subchannel,
370+
SubchannelState, GLOBAL_LB_REGISTRY,
372371
};
373372
use crate::client::name_resolution::{Address, Endpoint, ResolverUpdate};
374-
use crate::client::service_config::{LbConfig, ServiceConfig};
375373
use crate::client::ConnectivityState;
376-
use crate::rt::{default_runtime, Runtime};
377-
use crate::service::Request;
378-
use serde::{Deserialize, Serialize};
379-
use std::collections::{HashMap, HashSet};
374+
use crate::rt::default_runtime;
380375
use std::error::Error;
381376
use std::panic;
382377
use std::sync::Arc;
383-
use std::sync::Mutex;
384378
use tokio::sync::mpsc;
385-
use tonic::metadata::MetadataMap;
386379

387380
// TODO: This needs to be moved to a common place that can be shared between
388381
// round_robin and this test. This EndpointSharder maps endpoints to

grpc/src/client/load_balancing/mod.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,20 @@
2323
*/
2424

2525
use core::panic;
26-
use serde::de;
2726
use std::{
2827
any::Any,
29-
collections::HashMap,
3028
error::Error,
3129
fmt::{Debug, Display},
3230
hash::{Hash, Hasher},
33-
ops::{Add, Sub},
3431
ptr::addr_eq,
35-
sync::{
36-
atomic::{AtomicI64, Ordering::Relaxed},
37-
Arc, Mutex, Weak,
38-
},
32+
sync::{Arc, Mutex, Weak},
3933
};
40-
use tokio::sync::{mpsc::Sender, Notify};
4134
use tonic::{metadata::MetadataMap, Status};
4235

4336
use crate::{
4437
client::channel::WorkQueueTx,
4538
rt::Runtime,
46-
service::{Request, Response, Service},
39+
service::{Request, Response},
4740
};
4841

4942
use crate::client::{
@@ -60,7 +53,7 @@ pub mod test_utils;
6053

6154
pub(crate) mod registry;
6255
use super::{service_config::LbConfig, subchannel::SubchannelStateWatcher};
63-
pub(crate) use registry::{LbPolicyRegistry, GLOBAL_LB_REGISTRY};
56+
pub(crate) use registry::GLOBAL_LB_REGISTRY;
6457

6558
/// A collection of data configured on the channel that is constructing this
6659
/// LbPolicy.

grpc/src/client/load_balancing/pick_first.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
use std::{
2-
error::Error,
3-
sync::{Arc, Mutex},
4-
time::Duration,
5-
};
1+
use std::{error::Error, sync::Arc, time::Duration};
62

73
use tonic::metadata::MetadataMap;
84

95
use crate::{
106
client::{
117
load_balancing::{LbPolicy, LbPolicyBuilder, LbState},
128
name_resolution::{Address, ResolverUpdate},
13-
subchannel, ConnectivityState,
9+
ConnectivityState,
1410
},
1511
rt::Runtime,
1612
service::Request,

grpc/src/client/load_balancing/test_utils.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,16 @@
2323
*/
2424

2525
use crate::client::load_balancing::{
26-
ChannelController, ExternalSubchannel, ForwardingSubchannel, LbPolicy, LbPolicyBuilder,
27-
LbPolicyOptions, LbState, ParsedJsonLbConfig, Pick, PickResult, Picker, Subchannel,
28-
SubchannelState, WorkScheduler, GLOBAL_LB_REGISTRY,
26+
ChannelController, ForwardingSubchannel, LbPolicy, LbPolicyBuilder, LbPolicyOptions, LbState,
27+
ParsedJsonLbConfig, Subchannel, SubchannelState, WorkScheduler,
2928
};
3029
use crate::client::name_resolution::{Address, ResolverUpdate};
3130
use crate::client::service_config::LbConfig;
32-
use crate::client::ConnectivityState;
33-
use crate::service::{Message, Request, Response, Service};
34-
use serde::{Deserialize, Serialize};
35-
use std::any::Any;
36-
use std::collections::HashMap;
31+
use crate::service::{Message, Request};
3732
use std::error::Error;
38-
use std::hash::{Hash, Hasher};
39-
use std::sync::Mutex;
40-
use std::{fmt::Debug, ops::Add, sync::Arc};
41-
use tokio::sync::mpsc::Sender;
33+
use std::hash::Hash;
34+
use std::{fmt::Debug, sync::Arc};
4235
use tokio::sync::{mpsc, Notify};
43-
use tokio::task::AbortHandle;
44-
use tonic::metadata::MetadataMap;
4536

4637
#[derive(Debug)]
4738
pub(crate) struct EmptyMessage {}

grpc/src/client/name_resolution/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use super::service_config::ServiceConfig;
3333
use crate::{attributes::Attributes, byte_str::ByteStr, rt::Runtime};
3434
use std::{
3535
fmt::{Display, Formatter},
36-
hash::{Hash, Hasher},
36+
hash::Hash,
3737
str::FromStr,
3838
sync::Arc,
3939
};

grpc/src/client/subchannel.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
use super::{
22
channel::{InternalChannelController, WorkQueueTx},
3-
load_balancing::{self, ExternalSubchannel, Picker, Subchannel, SubchannelState},
3+
load_balancing::{ExternalSubchannel, SubchannelState},
44
name_resolution::Address,
5-
transport::{self, Transport, TransportRegistry},
5+
transport::Transport,
66
ConnectivityState,
77
};
88
use crate::{
9-
client::{
10-
channel::WorkQueueItem,
11-
subchannel,
12-
transport::{ConnectedTransport, TransportOptions},
13-
},
9+
client::{channel::WorkQueueItem, transport::TransportOptions},
1410
rt::{BoxedTaskHandle, Runtime},
1511
service::{Request, Response, Service},
1612
};
@@ -20,10 +16,9 @@ use std::{
2016
collections::BTreeMap,
2117
error::Error,
2218
fmt::{Debug, Display},
23-
ops::Sub,
2419
sync::{Arc, Mutex, RwLock, Weak},
2520
};
26-
use tokio::sync::{mpsc, oneshot, watch, Notify};
21+
use tokio::sync::{mpsc, oneshot};
2722
use tonic::async_trait;
2823

2924
type SharedService = Arc<dyn Service>;

grpc/src/inmemory/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use std::collections::HashMap;
12
use std::sync::atomic::{AtomicU32, Ordering};
23
use std::sync::{Arc, LazyLock, Mutex};
3-
use std::{collections::HashMap, ops::Add};
44

55
use crate::{
66
client::{
@@ -14,7 +14,7 @@ use crate::{
1414
server,
1515
service::{Request, Response, Service},
1616
};
17-
use tokio::sync::{mpsc, oneshot, Mutex as AsyncMutex, Notify};
17+
use tokio::sync::{mpsc, oneshot, Mutex as AsyncMutex};
1818
use tonic::async_trait;
1919

2020
pub struct Listener {

grpc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//! APIs are unstable. Proceed at your own risk.
3030
//!
3131
//! [gRPC]: https://grpc.io
32-
#![allow(dead_code, unused_variables, unused_imports)]
32+
#![allow(dead_code, unused_variables)]
3333

3434
pub mod client;
3535
pub mod credentials;

0 commit comments

Comments
 (0)