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

ready-cache: Allow iteration over ready services #700

Merged
merged 1 commit into from
Oct 17, 2022
Merged
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
10 changes: 10 additions & 0 deletions tower/src/ready_cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ where
self.ready.get_index_mut(idx).map(|(k, v)| (k, &mut v.0))
}

/// Returns an iterator over the ready keys and services.
pub fn iter_ready(&self) -> impl Iterator<Item = (&K, &S)> {
self.ready.iter().map(|(k, s)| (k, &s.0))
}

/// Returns a mutable iterator over the ready keys and services.
pub fn iter_ready_mut(&mut self) -> impl Iterator<Item = (&K, &mut S)> {
self.ready.iter_mut().map(|(k, s)| (k, &mut s.0))
}

/// Evicts an item from the cache.
///
/// Returns true if a service was marked for eviction.
Expand Down