Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support partial watching in discover subscription #155

Merged
merged 3 commits into from Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion volo-grpc/src/layer/loadbalance/mod.rs
Expand Up @@ -58,7 +58,7 @@ where
service,
};

if let Some(mut channel) = service.discover.watch() {
if let Some(mut channel) = service.discover.watch(None) {
tokio::spawn(async move {
loop {
match channel.recv().await {
Expand Down
6 changes: 3 additions & 3 deletions volo/src/discovery/mod.rs
Expand Up @@ -40,7 +40,7 @@ pub trait Discover: Send + Sync + 'static {
fn key(&self, endpoint: &Endpoint) -> Self::Key;
/// `watch` should return a [`async_broadcast::Receiver`] which can be used to subscribe
/// [`Change`].
fn watch(&self) -> Option<Receiver<Change<Self::Key>>>;
fn watch(&self, keys: Option<&[Self::Key]>) -> Option<Receiver<Change<Self::Key>>>;
}

/// Change indicates the change of the service discover.
Expand Down Expand Up @@ -158,7 +158,7 @@ impl Discover for StaticDiscover {

fn key(&self, _: &Endpoint) -> Self::Key {}

fn watch(&self) -> Option<Receiver<Change<Self::Key>>> {
fn watch(&self, _keys: Option<&[Self::Key]>) -> Option<Receiver<Change<Self::Key>>> {
None
}
}
Expand All @@ -180,7 +180,7 @@ impl Discover for DummyDiscover {

fn key(&self, _: &Endpoint) {}

fn watch(&self) -> Option<Receiver<Change<Self::Key>>> {
fn watch(&self, _keys: Option<&[Self::Key]>) -> Option<Receiver<Change<Self::Key>>> {
None
}
}
Expand Down
2 changes: 1 addition & 1 deletion volo/src/loadbalance/layer.rs
Expand Up @@ -29,7 +29,7 @@ where
retry,
};

if let Some(mut channel) = service.discover.watch() {
if let Some(mut channel) = service.discover.watch(None) {
tokio::spawn(async move {
loop {
match channel.recv().await {
Expand Down