SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
ColumnMng.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_broker_Protocol_handlers_ColumnMng_h
8 #define swcdb_broker_Protocol_handlers_ColumnMng_h
9 
10 
12 
13 
14 namespace SWC { namespace Comm { namespace Protocol {
15 namespace Bkr { namespace Handler {
16 
17 
18 
19 struct ColumnMng {
20 
24 
26  ColumnMng(const ConnHandlerPtr& a_conn, const Event::Ptr& a_ev,
27  const DB::Schema::Ptr& a_schema) noexcept
28  : conn(a_conn), ev(a_ev), schema(a_schema) {
29  }
30 
31  ~ColumnMng() noexcept { }
32 
35  return Env::Clients::get();
36  }
37 
39  bool valid() {
40  return !ev->expired() && conn->is_open() && Env::Bkr::is_accepting();
41  }
42 
44  void callback(const client::ConnQueue::ReqBase::Ptr&, int err) {
45  if(!ev->expired() && conn->is_open()) {
48  err ? conn->send_error(err, "", ev) : conn->response_ok(ev);
49  }
51  ? Env::Clients::get()->schemas.remove(schema->col_name)
52  : Env::Clients::get()->schemas.remove(schema->cid);
54  }
55 
56 };
57 
58 
59 void column_mng(const ConnHandlerPtr& conn, const Event::Ptr& ev) {
60  try {
61  const uint8_t *ptr = ev->data.base;
62  size_t remain = ev->data.size;
63 
65  params.decode(&ptr, &remain);
66 
68  params, ev->header.timeout_ms, conn, ev, params.schema);
69 
70  } catch(...) {
73  conn->send_error(e.code() , "", ev);
75  }
76 }
77 
78 
79 }}}}}
80 
81 #endif // swcdb_broker_Protocol_handlers_ColumnMng_h
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::DB::SchemaPrimitives::NO_CID
static constexpr const cid_t NO_CID
Definition: Schema.h:25
SWC::Error::SERVER_SHUTTING_DOWN
@ SERVER_SHUTTING_DOWN
Definition: Error.h:84
SWC::Env::Clients::get
static SWC_CAN_INLINE client::Clients::Ptr & get() noexcept
Definition: Clients.h:299
SWC::DB::Schema::Ptr
std::shared_ptr< Schema > Ptr
Definition: Schema.h:185
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::Comm::Protocol::Bkr::Handler::ColumnMng::conn
ConnHandlerPtr conn
Definition: ColumnMng.h:21
ColumnMng.h
SWC::Comm::Protocol::Bkr::Handler::ColumnMng::schema
DB::Schema::Ptr schema
Definition: ColumnMng.h:23
SWC::client::Clients::Ptr
ClientsPtr Ptr
Definition: Clients.h:58
SWC::Comm::Protocol::Bkr::Handler::ColumnMng::ev
Event::Ptr ev
Definition: ColumnMng.h:22
SWC::Env::Bkr::is_accepting
static SWC_CAN_INLINE bool is_accepting() noexcept
Definition: BrokerEnv.h:37
SWC::Comm::Protocol::Bkr::Handler::ColumnMng::~ColumnMng
~ColumnMng() noexcept
Definition: ColumnMng.h:31
SWC::Comm::Protocol::Mngr::Params::ColumnMng::schema
DB::Schema::Ptr schema
Definition: ColumnMng.h:50
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::Protocol::Mngr::Req::ColumnMng::request
static SWC_CAN_INLINE void request(const Params::ColumnMng &params, const uint32_t timeout, DataArgsT &&... args)
Definition: ColumnMng.h:36
SWC::Comm::Protocol::Bkr::Handler::ColumnMng::valid
SWC_CAN_INLINE bool valid()
Definition: ColumnMng.h:39
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::Bkr::Handler::ColumnMng::callback
SWC_CAN_INLINE void callback(const client::ConnQueue::ReqBase::Ptr &, int err)
Definition: ColumnMng.h:44
SWC::Comm::Protocol::Bkr::Handler::ColumnMng::ColumnMng
SWC_CAN_INLINE ColumnMng(const ConnHandlerPtr &a_conn, const Event::Ptr &a_ev, const DB::Schema::Ptr &a_schema) noexcept
Definition: ColumnMng.h:26
SWC::Error::CLIENT_STOPPING
@ CLIENT_STOPPING
Definition: Error.h:127
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::Protocol::Mngr::Params::ColumnMng
Definition: ColumnMng.h:18
SWC::Comm::Protocol::Bkr::Handler::ColumnMng::get_clients
SWC_CAN_INLINE SWC::client::Clients::Ptr & get_clients() noexcept
Definition: ColumnMng.h:34
SWC::Comm::Serializable::decode
void decode(const uint8_t **bufp, size_t *remainp)
Definition: Serializable.h:59
SWC::Comm::Protocol::Bkr::Handler::ColumnMng
Definition: ColumnMng.h:19
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Comm::Protocol::Bkr::Handler::column_mng
void column_mng(const ConnHandlerPtr &conn, const Event::Ptr &ev)
Definition: ColumnMng.h:59
SWC::Comm::client::ConnQueueReqBase::Ptr
std::shared_ptr< ConnQueueReqBase > Ptr
Definition: ClientConnQueue.h:25
SWC::Env::Bkr::processed
static SWC_CAN_INLINE void processed() noexcept
Definition: BrokerEnv.h:55
SWC::Error::Exception
Definition: Exception.h:21