$darkmode
#include <registrar.hpp>
Public Member Functions | |
| void | register_handler (const std::string &route, cloe::Handler h) override |
| void | refresh_buffer () |
| StaticRegistrar (Server *s) | |
| StaticRegistrar (Server *s, const std::string &prefix, Middleware m) | |
Public Member Functions inherited from oak::StaticRegistrar | |
| StaticRegistrar (Server *s) | |
| StaticRegistrar (Server *s, const std::string &prefix, Middleware m) | |
| void | set_prefix (const std::string &prefix) |
| void | set_logger (Logger logger) |
| const std::vector< std::string > & | endpoints () const |
Public Member Functions inherited from oak::Registrar | |
| Registrar (const Registrar *r, const std::string &prefix, Middleware m) | |
| Registrar | with (const std::string &prefix, Middleware m) const |
| Registrar | with_prefix (const std::string &prefix) const |
| Registrar | with_middleware (Middleware m) const |
| std::string | prefix () const |
| Middleware | middleware () const |
Protected Member Functions | |
| void | refresh_route (const std::string &key) |
Protected Member Functions inherited from oak::StaticRegistrar | |
| void | log (const std::string &endpoint) |
Protected Member Functions inherited from oak::Registrar | |
| Registrar (const std::string &prefix, Middleware m) | |
Protected Attributes | |
| std::shared_mutex | access_ |
| Muxer< cloe::Response > | buffer_ |
| Muxer< cloe::Handler > | handlers_ |
Protected Attributes inherited from oak::StaticRegistrar | |
| Server * | server_ |
| Logger | logger_ |
| std::vector< std::string > | endpoints_ |
Protected Attributes inherited from oak::Registrar | |
| Registrar * | proxy_ {nullptr} |
| std::string | prefix_ |
| Middleware | middleware_ |
BufferRegistrar provides a performant registrar implementation that is safe for dynamically change data content handlers.
The great problem that the locked registrar has is performance. In general, one anyway only wants to receive data from different endpoints that is coherent. By creating a buffer we pay the overhead of creating a response pre-emptively for each endpoint with the advantage that this response can be returned even while the data from which the response came is changing. There is still a portion of time when the registrar is locked, but this is limited to the time it takes to refresh the buffer.
The major downside of the BufferRegistrar is that responses cannot incur any side-effects and may not use the request data.
The contract requires that refresh_buffer be called whenever updated data should be made available.
| void oak::BufferRegistrar::refresh_buffer | ( | ) |
Refresh the entire buffer by calling every single registered handler once.
During the refresh, no endpoints that belong to the Registrar will be accessed.
|
protected |
Refresh the buffer for the given route.
This should only occur with a write lock enabled or if the route is not yet available to the server.
|
overridevirtual |
Do not register handlers that want to make use of Request.
Reimplemented from oak::StaticRegistrar.