diff options
Diffstat (limited to 'include/erebos/service.h')
-rw-r--r-- | include/erebos/service.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/erebos/service.h b/include/erebos/service.h new file mode 100644 index 0000000..7e037f8 --- /dev/null +++ b/include/erebos/service.h @@ -0,0 +1,44 @@ +#pragma once + +#include <erebos/state.h> +#include <erebos/uuid.h> + +#include <memory> + +namespace erebos { + +class Server; + +class Service +{ +public: + Service(); + virtual ~Service(); + + using Config = monostate; + + class Context + { + public: + struct Priv; + Context(Priv *); + Priv & priv(); + + const class Ref & ref() const; + const class Peer & peer() const; + + const Stored<LocalState> & local() const; + void local(const LocalState &); + + void afterCommit(function<void()>); + void runAfterCommitHooks() const; + + private: + std::unique_ptr<Priv> p; + }; + + virtual UUID uuid() const = 0; + virtual void handle(Context &) = 0; +}; + +} |