topology: add for_each_node

To eventually replace token_metadata::get_endpoint_to_host_id_map_for_reading

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2023-04-11 15:54:10 +03:00
parent e635aa30d6
commit 7b76369ffc
2 changed files with 10 additions and 0 deletions

View File

@@ -495,6 +495,14 @@ std::weak_ordering topology::compare_endpoints(const inet_address& address, cons
return d1 <=> d2;
}
void topology::for_each_node(std::function<void(const node*)> func) const {
for (const auto& np : _nodes) {
if (np) {
func(np.get());
}
}
}
} // namespace locator
namespace std {

View File

@@ -250,6 +250,8 @@ public:
*/
void sort_by_proximity(inet_address address, inet_address_vector_replica_set& addresses) const;
void for_each_node(std::function<void(const node*)> func) const;
private:
// default constructor for cloning purposes
topology() noexcept;