Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions grpc/src/client/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
17 changes: 5 additions & 12 deletions grpc/src/client/load_balancing/child_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,29 +360,22 @@
#[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
Expand Down Expand Up @@ -444,7 +437,7 @@
let (tx_events, rx_events) = mpsc::unbounded_channel::<TestEvent>();
let tcc = Box::new(TestChannelController { tx_events });
let builder: Arc<dyn LbPolicyBuilder> = GLOBAL_LB_REGISTRY.get_policy(test_name).unwrap();
let endpoint_sharder = EndpointSharder { builder: builder };

Check warning on line 440 in grpc/src/client/load_balancing/child_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant field names in struct initialization
let child_manager = ChildManager::new(Box::new(endpoint_sharder), default_runtime());
(rx_events, Box::new(child_manager), tcc)
}
Expand Down Expand Up @@ -535,7 +528,7 @@
picker: Arc::new(QueuingPicker {}),
});
}),
..Default::default()

Check warning on line 531 in grpc/src/client/load_balancing/child_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

struct update has no effect, all the fields in the struct have already been specified
}
}

Expand Down
13 changes: 3 additions & 10 deletions grpc/src/client/load_balancing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,19 @@
*/

use core::panic;
use serde::de;
use std::{
any::Any,
collections::HashMap,
error::Error,
fmt::{Debug, Display},
hash::{Hash, Hasher},
ops::{Add, Sub},
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::{
Expand All @@ -59,7 +52,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.
Expand Down
8 changes: 2 additions & 6 deletions grpc/src/client/load_balancing/pick_first.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
use std::{
error::Error,
sync::{Arc, Mutex},
time::Duration,
};
use std::{error::Error, sync::Arc, time::Duration};

use tonic::metadata::MetadataMap;

use crate::{
client::{
load_balancing::{LbPolicy, LbPolicyBuilder, LbState},
name_resolution::{Address, ResolverUpdate},
subchannel, ConnectivityState,
ConnectivityState,
},
rt::Runtime,
service::Request,
Expand Down
19 changes: 5 additions & 14 deletions grpc/src/client/load_balancing/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion grpc/src/client/name_resolution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
13 changes: 4 additions & 9 deletions grpc/src/client/subchannel.rs
Original file line number Diff line number Diff line change
@@ -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},
};
Expand All @@ -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<dyn Service>;
Expand Down
4 changes: 2 additions & 2 deletions grpc/src/inmemory/mod.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion grpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading