Update Action class
This commit is contained in:
parent
c2af35f20b
commit
6dad838545
Binary file not shown.
|
|
@ -34,16 +34,8 @@ namespace etcdv3
|
||||||
class Action
|
class Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Status status;
|
Action(etcdv3::ActionParameters params);
|
||||||
ClientContext context;
|
Action(){};
|
||||||
CompletionQueue cq_;
|
|
||||||
void waitForResponse();
|
|
||||||
};
|
|
||||||
|
|
||||||
class Actionv2
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Actionv2(etcdv3::ActionParameters params);
|
|
||||||
Status status;
|
Status status;
|
||||||
ClientContext context;
|
ClientContext context;
|
||||||
CompletionQueue cq_;
|
CompletionQueue cq_;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using etcdserverpb::KV;
|
||||||
|
|
||||||
namespace etcdv3
|
namespace etcdv3
|
||||||
{
|
{
|
||||||
class AsyncCompareAndDeleteAction : public etcdv3::Actionv2
|
class AsyncCompareAndDeleteAction : public etcdv3::Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncCompareAndDeleteAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type);
|
AsyncCompareAndDeleteAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using etcdserverpb::KV;
|
||||||
|
|
||||||
namespace etcdv3
|
namespace etcdv3
|
||||||
{
|
{
|
||||||
class AsyncCompareAndSwapAction : public etcdv3::Actionv2
|
class AsyncCompareAndSwapAction : public etcdv3::Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncCompareAndSwapAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type);
|
AsyncCompareAndSwapAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using etcdserverpb::KV;
|
||||||
|
|
||||||
namespace etcdv3
|
namespace etcdv3
|
||||||
{
|
{
|
||||||
class AsyncDeleteAction : public etcdv3::Actionv2
|
class AsyncDeleteAction : public etcdv3::Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncDeleteAction(etcdv3::ActionParameters param);
|
AsyncDeleteAction(etcdv3::ActionParameters param);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using etcdserverpb::KV;
|
||||||
|
|
||||||
namespace etcdv3
|
namespace etcdv3
|
||||||
{
|
{
|
||||||
class AsyncGetAction : public etcdv3::Actionv2
|
class AsyncGetAction : public etcdv3::Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncGetAction(etcdv3::ActionParameters param);
|
AsyncGetAction(etcdv3::ActionParameters param);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using etcdserverpb::KV;
|
||||||
|
|
||||||
namespace etcdv3
|
namespace etcdv3
|
||||||
{
|
{
|
||||||
class AsyncSetAction : public etcdv3::Actionv2
|
class AsyncSetAction : public etcdv3::Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncSetAction(etcdv3::ActionParameters param, bool isCreate=false);
|
AsyncSetAction(etcdv3::ActionParameters param, bool isCreate=false);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using etcdserverpb::KV;
|
||||||
|
|
||||||
namespace etcdv3
|
namespace etcdv3
|
||||||
{
|
{
|
||||||
class AsyncUpdateAction : public etcdv3::Actionv2
|
class AsyncUpdateAction : public etcdv3::Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncUpdateAction(etcdv3::ActionParameters param);
|
AsyncUpdateAction(etcdv3::ActionParameters param);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ using etcdserverpb::WatchResponse;
|
||||||
|
|
||||||
namespace etcdv3
|
namespace etcdv3
|
||||||
{
|
{
|
||||||
class AsyncWatchAction : public etcdv3::Actionv2
|
class AsyncWatchAction : public etcdv3::Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncWatchAction(etcdv3::ActionParameters param);
|
AsyncWatchAction(etcdv3::ActionParameters param);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
#include "v3/include/Action.hpp"
|
#include "v3/include/Action.hpp"
|
||||||
|
|
||||||
|
etcdv3::Action::Action(etcdv3::ActionParameters params)
|
||||||
|
{
|
||||||
|
parameters = params;
|
||||||
|
}
|
||||||
|
|
||||||
void etcdv3::Action::waitForResponse()
|
void etcdv3::Action::waitForResponse()
|
||||||
{
|
{
|
||||||
void* got_tag;
|
void* got_tag;
|
||||||
|
|
@ -8,17 +13,3 @@ void etcdv3::Action::waitForResponse()
|
||||||
cq_.Next(&got_tag, &ok);
|
cq_.Next(&got_tag, &ok);
|
||||||
GPR_ASSERT(got_tag == (void*)this);
|
GPR_ASSERT(got_tag == (void*)this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void etcdv3::Actionv2::waitForResponse()
|
|
||||||
{
|
|
||||||
void* got_tag;
|
|
||||||
bool ok = false;
|
|
||||||
|
|
||||||
cq_.Next(&got_tag, &ok);
|
|
||||||
GPR_ASSERT(got_tag == (void*)this);
|
|
||||||
}
|
|
||||||
|
|
||||||
etcdv3::Actionv2::Actionv2(etcdv3::ActionParameters params)
|
|
||||||
{
|
|
||||||
parameters = params;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using etcdserverpb::ResponseOp;
|
||||||
using etcdserverpb::TxnRequest;
|
using etcdserverpb::TxnRequest;
|
||||||
|
|
||||||
etcdv3::AsyncCompareAndDeleteAction::AsyncCompareAndDeleteAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type)
|
etcdv3::AsyncCompareAndDeleteAction::AsyncCompareAndDeleteAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type)
|
||||||
:etcdv3::Actionv2(param)
|
:etcdv3::Action(param)
|
||||||
{
|
{
|
||||||
etcdv3::Transaction transaction(parameters.key);
|
etcdv3::Transaction transaction(parameters.key);
|
||||||
if(type == etcdv3::Atomicity_Type::PREV_VALUE)
|
if(type == etcdv3::Atomicity_Type::PREV_VALUE)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using etcdserverpb::ResponseOp;
|
||||||
using etcdserverpb::TxnRequest;
|
using etcdserverpb::TxnRequest;
|
||||||
|
|
||||||
etcdv3::AsyncCompareAndSwapAction::AsyncCompareAndSwapAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type)
|
etcdv3::AsyncCompareAndSwapAction::AsyncCompareAndSwapAction(etcdv3::ActionParameters param, etcdv3::Atomicity_Type type)
|
||||||
: etcdv3::Actionv2(param)
|
: etcdv3::Action(param)
|
||||||
{
|
{
|
||||||
etcdv3::Transaction transaction(parameters.key);
|
etcdv3::Transaction transaction(parameters.key);
|
||||||
if(type == etcdv3::Atomicity_Type::PREV_VALUE)
|
if(type == etcdv3::Atomicity_Type::PREV_VALUE)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
using etcdserverpb::Compare;
|
using etcdserverpb::Compare;
|
||||||
|
|
||||||
etcdv3::AsyncDeleteAction::AsyncDeleteAction(ActionParameters param)
|
etcdv3::AsyncDeleteAction::AsyncDeleteAction(ActionParameters param)
|
||||||
: etcdv3::Actionv2(param)
|
: etcdv3::Action(param)
|
||||||
{
|
{
|
||||||
etcdv3::Transaction transaction(parameters.key);
|
etcdv3::Transaction transaction(parameters.key);
|
||||||
transaction.init_compare(Compare::CompareResult::Compare_CompareResult_GREATER,
|
transaction.init_compare(Compare::CompareResult::Compare_CompareResult_GREATER,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using etcdserverpb::RangeRequest;
|
using etcdserverpb::RangeRequest;
|
||||||
|
|
||||||
etcdv3::AsyncGetAction::AsyncGetAction(etcdv3::ActionParameters param)
|
etcdv3::AsyncGetAction::AsyncGetAction(etcdv3::ActionParameters param)
|
||||||
: etcdv3::Actionv2(param)
|
: etcdv3::Action(param)
|
||||||
{
|
{
|
||||||
RangeRequest get_request;
|
RangeRequest get_request;
|
||||||
get_request.set_key(parameters.key);
|
get_request.set_key(parameters.key);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using etcdserverpb::ResponseOp;
|
||||||
using etcdserverpb::TxnRequest;
|
using etcdserverpb::TxnRequest;
|
||||||
|
|
||||||
etcdv3::AsyncSetAction::AsyncSetAction(etcdv3::ActionParameters param, bool create)
|
etcdv3::AsyncSetAction::AsyncSetAction(etcdv3::ActionParameters param, bool create)
|
||||||
: etcdv3::Actionv2(param)
|
: etcdv3::Action(param)
|
||||||
{
|
{
|
||||||
etcdv3::Transaction transaction(parameters.key);
|
etcdv3::Transaction transaction(parameters.key);
|
||||||
isCreate = create;
|
isCreate = create;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using etcdserverpb::ResponseOp;
|
||||||
using etcdserverpb::TxnRequest;
|
using etcdserverpb::TxnRequest;
|
||||||
|
|
||||||
etcdv3::AsyncUpdateAction::AsyncUpdateAction(etcdv3::ActionParameters param)
|
etcdv3::AsyncUpdateAction::AsyncUpdateAction(etcdv3::ActionParameters param)
|
||||||
: etcdv3::Actionv2(param)
|
: etcdv3::Action(param)
|
||||||
{
|
{
|
||||||
etcdv3::Transaction transaction(parameters.key);
|
etcdv3::Transaction transaction(parameters.key);
|
||||||
transaction.init_compare(Compare::CompareResult::Compare_CompareResult_GREATER,
|
transaction.init_compare(Compare::CompareResult::Compare_CompareResult_GREATER,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ using etcdserverpb::RangeResponse;
|
||||||
using etcdserverpb::WatchCreateRequest;
|
using etcdserverpb::WatchCreateRequest;
|
||||||
|
|
||||||
etcdv3::AsyncWatchAction::AsyncWatchAction(etcdv3::ActionParameters param)
|
etcdv3::AsyncWatchAction::AsyncWatchAction(etcdv3::ActionParameters param)
|
||||||
: etcdv3::Actionv2(param)
|
: etcdv3::Action(param)
|
||||||
{
|
{
|
||||||
stream = parameters.watch_stub->AsyncWatch(&context,&cq_,(void*)"create");
|
stream = parameters.watch_stub->AsyncWatch(&context,&cq_,(void*)"create");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue