SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
MngrState.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
7 #ifndef swcdb_manager_Protocol_handlers_MngrState_h
8 #define swcdb_manager_Protocol_handlers_MngrState_h
9 
10 
11 namespace SWC { namespace Comm { namespace Protocol {
12 namespace Mngr { namespace Handler {
13 
14 
15 struct MngrState {
18 
21  const Comm::Event::Ptr& a_ev) noexcept
22  : conn(a_conn), ev(a_ev) {
23  }
24 
26  MngrState(MngrState&& other) noexcept
27  : conn(std::move(other.conn)), ev(std::move(other.ev)) {
28  }
29 
30  MngrState(const MngrState&) = delete;
32  MngrState& operator=(const MngrState&) = delete;
33 
34  ~MngrState() noexcept { }
35 
36  void operator()() {
37  if(ev->expired())
38  return;
39 
40  try {
41  const uint8_t *ptr = ev->data.base;
42  size_t remain = ev->data.size;
43 
44  Params::MngrState req_params;
45  req_params.decode(&ptr, &remain);
46 
48  req_params.states, req_params.token,
49  nullptr // std::make_shared<ResponseCallback>(conn, ev)
50  );
51 
53  conn->endpoint_remote_hash(), req_params.mngr_host);
54 
55  conn->response_ok(ev);
56 
57  } catch(...) {
60  conn->send_error(e.code(), "", ev);
61  }
62  }
63 
64 };
65 
66 
67 }}}}}
68 
69 #endif // swcdb_manager_Protocol_handlers_MngrState_h
SWC::Comm::Protocol::Mngr::Handler::MngrState::conn
Comm::ConnHandlerPtr conn
Definition: MngrState.h:16
SWC::Error::Exception::code
constexpr SWC_CAN_INLINE int code() const noexcept
Definition: Exception.h:51
SWC_LOG_OSTREAM
#define SWC_LOG_OSTREAM
Definition: Logger.h:44
SWC::Comm::Protocol::Mngr::Handler::MngrState::~MngrState
~MngrState() noexcept
Definition: MngrState.h:34
SWC::Manager::MngrRole::update_manager_addr
void update_manager_addr(uint64_t hash, const Comm::EndPoint &mngr_host)
Definition: MngrRole.cc:267
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::Comm::Protocol::Mngr::Handler::MngrState::ev
Comm::Event::Ptr ev
Definition: MngrState.h:17
SWC::Comm::Protocol::Mngr::Handler::MngrState::MngrState
MngrState(const MngrState &)=delete
SWC::Comm::Protocol::Mngr::Params::MngrState::mngr_host
EndPoint mngr_host
Definition: MngrState.h:42
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::Protocol::Mngr::Params::MngrState
Definition: MngrState.h:15
SWC::Comm::Protocol::Mngr::Handler::MngrState::operator()
void operator()()
Definition: MngrState.h:36
SWC::Comm::Protocol::Mngr::Handler::MngrState
Definition: MngrState.h:15
SWC_CURRENT_EXCEPTION
#define SWC_CURRENT_EXCEPTION(_msg_)
Definition: Exception.h:119
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Mngr::Params::MngrState::states
Manager::MngrsStatus states
Definition: MngrState.h:40
SWC::Manager::MngrRole::fill_states
void fill_states(const MngrsStatus &states, uint64_t token, const Comm::ResponseCallback::Ptr &cb)
Definition: MngrRole.cc:142
SWC::Comm::Protocol::Mngr::Handler::MngrState::operator=
MngrState & operator=(const MngrState &)=delete
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::Comm::Protocol::Mngr::Handler::MngrState::operator=
MngrState & operator=(MngrState &&)=delete
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::Serializable::decode
void decode(const uint8_t **bufp, size_t *remainp)
Definition: Serializable.h:59
SWC::Env::Mngr::role
static SWC_CAN_INLINE Manager::MngrRole * role() noexcept
Definition: MngrEnv.h:64
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Comm::Protocol::Mngr::Handler::MngrState::MngrState
SWC_CAN_INLINE MngrState(const Comm::ConnHandlerPtr &a_conn, const Comm::Event::Ptr &a_ev) noexcept
Definition: MngrState.h:20
SWC::Comm::Protocol::Mngr::Handler::MngrState::MngrState
SWC_CAN_INLINE MngrState(MngrState &&other) noexcept
Definition: MngrState.h:26
SWC::Comm::Protocol::Mngr::Params::MngrState::token
uint64_t token
Definition: MngrState.h:41
SWC::Error::Exception
Definition: Exception.h:21