Skip to content

Commit

Permalink
remove useless liftetime paramenter in LoadBalance::InstancePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
ethe committed Oct 26, 2022
1 parent e8fa22a commit 22d06cc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
6 changes: 3 additions & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ path = "src/hello/grpc_server.rs"
[[bin]]
name = "hello-thrift-server"
path = "src/hello/thrift_server.rs"
# [[bin]]
# name = "hello-thrift-client"
# path = "src/hello/thrift_client.rs"
[[bin]]
name = "hello-thrift-client"
path = "src/hello/thrift_client.rs"

[dependencies]
anyhow.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion examples/src/hello/grpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ lazy_static! {

#[volo::main]
async fn main() {
let req = volo_gen::proto_gen::hello::HelloRequest { name: "Volo".to_string() };
let req = volo_gen::proto_gen::hello::HelloRequest {
name: "Volo".to_string(),
};
let resp = CLIENT.clone().hello(req).await;
match resp {
Ok(info) => println!("{:?}", info),
Expand Down
1 change: 0 additions & 1 deletion volo-grpc/src/layer/loadbalance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ where
LoadBalanceError: Into<S::Error>,
S::Error: Debug,
T: Send + 'static,
for<'future, 'iter> LB::GetFut<'future, 'iter>: Send, /* add this temporarily via https://github.com/rust-lang/rust/issues/100013 */
{
type Response = S::Response;

Expand Down
2 changes: 0 additions & 2 deletions volo/src/loadbalance/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ where

impl<Cx, Req, D, LB, S> Service<Cx, Req> for LoadBalanceService<D, LB, S>
where
<Cx as Context>::Config: std::marker::Sync,
Cx: 'static + Context + Send + Sync,
D: Discover,
LB: LoadBalance<D>,
S: Service<Cx, Req> + 'static + Send,
LoadBalanceError: Into<S::Error>,
S::Error: Debug + Retryable,
Req: Clone + Send + Sync + 'static,
for<'future, 'iter> LB::GetFut<'future, 'iter>: Send, /* add this temporarily via https://github.com/rust-lang/rust/issues/100013 */
{
type Response = S::Response;

Expand Down
14 changes: 7 additions & 7 deletions volo/src/loadbalance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ where
D: Discover,
{
/// `InstanceIter` is an iterator of [`crate::discovery::Instance`].
type InstanceIter<'iter>: Iterator<Item = Address> + Send + 'iter;
type InstanceIter: Iterator<Item = Address> + Send;

/// `GetFut` is the return type of `get_picker`.
type GetFut<'future, 'iter>: Future<Output = Result<Self::InstanceIter<'iter>, LoadBalanceError>>
type GetFut<'future>: Future<Output = Result<Self::InstanceIter, LoadBalanceError>>
+ Send
+ 'future
where
'iter: 'future;
Self: 'future;

/// `get_picker` allows to get an instance iterator of a specified endpoint from self or
/// service discovery.
fn get_picker<'future, 'iter>(
&'iter self,
fn get_picker<'future>(
&'future self,
endpoint: &'future Endpoint,
discover: &'future D,
) -> Self::GetFut<'future, 'iter>
) -> Self::GetFut<'future>
where
'iter: 'future;
Self: 'future;
/// `rebalance` is the callback method be used in service discovering subscription.
fn rebalance(&self, changes: Change<D::Key>);
}
Expand Down
16 changes: 8 additions & 8 deletions volo/src/loadbalance/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@ impl<D> LoadBalance<D> for WeightedRandomBalance<D::Key>
where
D: Discover,
{
type InstanceIter<'iter> = InstancePicker;
type InstanceIter = InstancePicker;

type GetFut<'future, 'iter> =
impl Future<Output = Result<Self::InstanceIter<'iter>, LoadBalanceError>> + Send + 'future
type GetFut<'future> =
impl Future<Output = Result<Self::InstanceIter, LoadBalanceError>> + Send + 'future
where
'iter: 'future;
Self: 'future;

fn get_picker<'future, 'iter>(
&'iter self,
fn get_picker<'future>(
&'future self,
endpoint: &'future Endpoint,
discover: &'future D,
) -> Self::GetFut<'future, 'iter>
) -> Self::GetFut<'future>
where
'iter: 'future,
Self: 'future,
{
async {
let key = discover.key(endpoint);
Expand Down

0 comments on commit 22d06cc

Please sign in to comment.