service: address_map: add lookup function that expects address to exist
We will add code that expects id to ip mapping to exist. If it does not it is better to fail earlier during testing, so add a function that calls internal error in case there is no mapping.
This commit is contained in:
@@ -298,6 +298,15 @@ public:
|
||||
return entry._addr;
|
||||
}
|
||||
|
||||
// Same as find() above but expects mapping to exist
|
||||
gms::inet_address get(locator::host_id id) const {
|
||||
try {
|
||||
return find(id).value();
|
||||
} catch (std::bad_optional_access& err) {
|
||||
on_internal_error(rslog, fmt::format("No ip address for {} when one is expected", id));
|
||||
}
|
||||
}
|
||||
|
||||
// Find an id with a given mapping.
|
||||
//
|
||||
// If a mapping is expiring, the last access timestamp is updated automatically.
|
||||
|
||||
Reference in New Issue
Block a user