SWC-DB  v0.5.9 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeQueryUpdate.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 #ifndef swcdb_db_protocol_rgr_req_RangeQueryUpdate_h
7 #define swcdb_db_protocol_rgr_req_RangeQueryUpdate_h
8 
9 
14 
15 
16 namespace SWC { namespace Comm { namespace Protocol {
17 namespace Rgr { namespace Req {
18 
19 
20 template<typename DataT>
22  public:
23 
24  typedef std::shared_ptr<RangeQueryUpdate> Ptr;
25  DataT data;
26 
27  template<typename... DataArgsT>
29  static Ptr make(
30  const Params::RangeQueryUpdateReq& params,
31  StaticBuffer& snd_buf,
32  const uint32_t timeout,
33  DataArgsT&&... args) {
34  return Ptr(new RangeQueryUpdate(
35  Buffers::make(params, snd_buf, 0, RANGE_QUERY_UPDATE, timeout),
36  args...
37  ));
38  }
39 
40  template<typename... DataArgsT>
42  static Ptr make(
43  const Params::RangeQueryUpdateReq& params,
44  const DynamicBuffer& buffer,
45  const uint32_t timeout,
46  DataArgsT&&... args) {
47  StaticBuffer snd_buf(buffer.base, buffer.fill(), false);
48  return make(params, snd_buf, timeout, args...);
49  }
50 
52  static void request(const Ptr& req, const EndPoints& endpoints) {
53  req->data.get_clients()->get_rgr_queue(endpoints)->put(req);
54  }
55 
56  template<typename... DataArgsT>
58  static void request(
59  const Params::RangeQueryUpdateReq& params,
60  StaticBuffer& snd_buf,
61  const uint32_t timeout,
62  const EndPoints& endpoints,
63  DataArgsT&&... args) {
64  request(make(params, snd_buf, timeout, args...), endpoints);
65  }
66 
67  template<typename... DataArgsT>
69  static void request(
70  const Params::RangeQueryUpdateReq& params,
71  const DynamicBuffer& buffer,
72  const uint32_t timeout,
73  const EndPoints& endpoints,
74  DataArgsT&&... args) {
75  request(make(params, buffer, timeout, args...), endpoints);
76  }
77 
78  virtual ~RangeQueryUpdate() noexcept { }
79 
80  bool valid() override {
81  return data.valid();
82  }
83 
84  void handle_no_conn() override {
85  data.callback(
86  req(),
88  );
89  }
90 
91  void handle(ConnHandlerPtr, const Event::Ptr& ev) override {
92  data.callback(
93  req(),
94  Params::RangeQueryUpdateRsp(ev->error, ev->data.base, ev->data.size)
95  );
96  }
97 
98  protected:
99 
100  template<typename... DataArgsT>
102  RangeQueryUpdate(Buffers::Ptr&& a_cbp, DataArgsT&&... args)
103  : client::ConnQueue::ReqBase(std::move(a_cbp)),
104  data(args...) {
105  }
106 
107 };
108 
109 
110 
126 typedef Common::Req::function<
127  std::function<void(
128  void*,
131  )>
133 
134 
135 
136 
137 }}}}}
138 
139 
140 #endif // swcdb_db_protocol_rgr_req_RangeQueryUpdate_h
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::~RangeQueryUpdate
virtual ~RangeQueryUpdate() noexcept
Definition: RangeQueryUpdate.h:78
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::make
static SWC_CAN_INLINE Ptr make(const Params::RangeQueryUpdateReq &params, StaticBuffer &snd_buf, const uint32_t timeout, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:29
SWC::Comm::client::ConnQueueReqBase::req
SWC_CAN_INLINE Ptr req() noexcept
Definition: ClientConnQueue.h:39
SWC::Comm::Buffers::Ptr
std::shared_ptr< Buffers > Ptr
Definition: Buffers.h:23
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::handle
void handle(ConnHandlerPtr, const Event::Ptr &ev) override
Definition: RangeQueryUpdate.h:91
SWC::client::Query::ReqBase
Comm::client::ConnQueue::ReqBase ReqBase
Definition: Profiling.h:21
SWC::Comm::client::ConnQueueReqBase
Definition: ClientConnQueue.h:22
SWC::Comm::Protocol::Rgr::Req::Functional_RangeQueryUpdate
Common::Req::function< std::function< void(void *, const client::ConnQueue::ReqBase::Ptr &, const Params::RangeQueryUpdateRsp &)>> Functional_RangeQueryUpdate
Definition: RangeQueryUpdate.h:132
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::make
static SWC_CAN_INLINE Ptr make(const Params::RangeQueryUpdateReq &params, const DynamicBuffer &buffer, const uint32_t timeout, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:42
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::handle_no_conn
void handle_no_conn() override
Definition: RangeQueryUpdate.h:84
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::Ptr
std::shared_ptr< RangeQueryUpdate > Ptr
Definition: RangeQueryUpdate.h:24
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::RangeQueryUpdate
SWC_CAN_INLINE RangeQueryUpdate(Buffers::Ptr &&a_cbp, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:102
SWC::Comm::Protocol::Rgr::Params::RangeQueryUpdateRsp
Definition: RangeQueryUpdate.h:48
handler_data.h
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
RangeQueryUpdate.h
SWC::Core::Buffer::base
value_type * base
Definition: Buffer.h:128
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::valid
bool valid() override
Definition: RangeQueryUpdate.h:80
SWC::Core::BufferDyn< StaticBuffer >
SWC::Core::Buffer
Definition: Buffer.h:18
ClientConnQueue.h
Commands.h
SWC::Error::COMM_NOT_CONNECTED
@ COMM_NOT_CONNECTED
Definition: Error.h:64
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Core::Vector< EndPoint >
SWC::Comm::Protocol::Common::Req::function
Definition: handler_data.h:19
SWC::Core::BufferDyn::fill
constexpr SWC_CAN_INLINE size_t fill() const noexcept
Definition: Buffer.h:181
SWC::Comm::Buffers::make
static SWC_CAN_INLINE Ptr make(uint32_t reserve=0)
Definition: Buffers.h:27
SWC::Comm::Protocol::Rgr::RANGE_QUERY_UPDATE
@ RANGE_QUERY_UPDATE
Definition: Commands.h:34
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate
Definition: RangeQueryUpdate.h:21
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::request
static SWC_CAN_INLINE void request(const Ptr &req, const EndPoints &endpoints)
Definition: RangeQueryUpdate.h:52
SWC::Comm::Protocol::Rgr::Params::RangeQueryUpdateReq
Definition: RangeQueryUpdate.h:18
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::request
static SWC_CAN_INLINE void request(const Params::RangeQueryUpdateReq &params, const DynamicBuffer &buffer, const uint32_t timeout, const EndPoints &endpoints, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:69
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:29
SWC::Comm::client::ConnQueueReqBase::Ptr
std::shared_ptr< ConnQueueReqBase > Ptr
Definition: ClientConnQueue.h:25
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::request
static SWC_CAN_INLINE void request(const Params::RangeQueryUpdateReq &params, StaticBuffer &snd_buf, const uint32_t timeout, const EndPoints &endpoints, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:58
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::data
DataT data
Definition: RangeQueryUpdate.h:25