|
|
| BackendRegistry ()=default |
| | Construct a registry with the default time-to-live.
|
| | BackendRegistry (Clock::duration timeToLive) |
| | Construct a registry with an explicit time-to-live.
|
| bool | insertOrRefresh (BackendWrapper backend, Clock::time_point now=Clock::now()) |
| | Insert a backend, or refresh the entry already registered under the same name, and stamp it as last heard from at now.
|
| std::size_t | expire (Clock::time_point now=Clock::now()) |
| | Drop every entry last refreshed longer ago than the registry's time-to-live.
|
| const BackendWrapper * | find (std::string_view backendName) const |
| | Look up a backend by name.
|
| bool | contains (std::string_view backendName) const |
| | Check whether a backend is registered under a given name.
|
| std::size_t | size () const noexcept |
| | Get the number of registered backends.
|
| bool | empty () const noexcept |
| | Check whether the registry holds no backends.
|
| Clock::duration | getTimeToLive () const noexcept |
| | Get the registry's entry time-to-live.
|
| template<typename Fn> |
| void | forEachBackend (Fn &&fn) const |
| | Apply a function to every registered backend, in ascending backend-name order.
|
Owns the backends a process knows about, keyed by backend name.
Entries are inserted or refreshed with insertOrRefresh(), each stamped with the time it was last heard from, and dropped by expire() once they are older than the registry's time-to-live – so a worker that dies stops receiving task assignments instead of lingering forever. Lookup goes through find(), which returns nullptr for an unknown name rather than default-constructing an entry the way a raw map's operator[] does.
Iteration order is by ascending backend name, which is what makes chooseBackend() reproducible.
Definition at line 52 of file BackendRegistry.h.
| bool mqss::qrmci::BackendRegistry::insertOrRefresh |
( |
BackendWrapper | backend, |
|
|
Clock::time_point | now = Clock::now() ) |
Insert a backend, or refresh the entry already registered under the same name, and stamp it as last heard from at now.
Rejected rather than applied if an entry is already registered under the same name with a different, non-empty dispatch queue – the same ID publishing under two different queues is a routing conflict a task could silently be sent to the wrong worker over, not something a later status update should be allowed to overwrite. The existing entry, and its time-to-live, are left untouched either way.
- Parameters
-
| backend | The backend to register. |
| now | The time to stamp the entry with. |
- Returns
- True if
backend was inserted or refreshed the existing entry; false if it was rejected as a dispatch-queue conflict.