SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
MngrActive.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_MngrActive_h
8 #define swcdb_manager_Protocol_handlers_MngrActive_h
9 
11 
12 
13 namespace SWC { namespace Comm { namespace Protocol {
14 namespace Mngr { namespace Handler {
15 
16 
17 void mngr_active(const ConnHandlerPtr& conn, const Event::Ptr& ev) {
18  Manager::MngrStatus::Ptr h = nullptr;
19  try {
20  const uint8_t *ptr = ev->data.base;
21  size_t remain = ev->data.size;
22 
23  Params::MngrActiveReq params;
24  params.decode(&ptr, &remain);
25 
27  ? Env::Mngr::role()->active_mngr(params.cid)
29 
30  } catch(...) {
32  }
33 
34  conn->send_response(
35  Buffers::make(ev, Params::MngrActiveRsp(h ? h->endpoints : EndPoints()))
36  );
37 }
38 
39 
40 
41 }}}}}
42 
43 #endif // swcdb_manager_Protocol_handlers_MngrActive_h
SWC::Manager::MngrStatus::Ptr
std::shared_ptr< MngrStatus > Ptr
Definition: MngrStatus.h:21
SWC::Comm::Protocol::Mngr::Params::MngrActiveReq
Definition: MngrActive.h:19
MngrActive.h
SWC::Manager::MngrRole::active_mngr
MngrStatus::Ptr active_mngr(cid_t cid)
Definition: MngrRole.cc:85
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Mngr::Params::MngrActiveReq::cid
cid_t cid
Definition: MngrActive.h:31
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Core::Vector< EndPoint >
SWC::Comm::Protocol::Mngr::Params::MngrActiveReq::role
uint8_t role
Definition: MngrActive.h:30
SWC::Comm::Buffers::make
static SWC_CAN_INLINE Ptr make(uint32_t reserve=0)
Definition: Buffers.h:27
SWC::Manager::MngrRole::active_mngr_role
MngrStatus::Ptr active_mngr_role(uint8_t role)
Definition: MngrRole.cc:98
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::Params::MngrActiveRsp
Definition: MngrActive.h:45
SWC::Comm::Protocol::Mngr::Handler::mngr_active
void mngr_active(const ConnHandlerPtr &conn, const Event::Ptr &ev)
Definition: MngrActive.h:17
SWC_LOG_CURRENT_EXCEPTION
#define SWC_LOG_CURRENT_EXCEPTION(_s_)
Definition: Exception.h:144
SWC::DB::Types::MngrRole::COLUMNS
const uint8_t COLUMNS
Definition: MngrRole.h:14