37 lines
921 B
C++
37 lines
921 B
C++
#ifndef __ASYNC_WATCHACTION_HPP__
|
|
#define __ASYNC_WATCHACTION_HPP__
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
|
|
#include <grpc++/grpc++.h>
|
|
#include "proto/rpc.grpc.pb.h"
|
|
#include "etcd/v3/Action.hpp"
|
|
#include "etcd/v3/AsyncWatchResponse.hpp"
|
|
#include "etcd/Response.hpp"
|
|
|
|
using grpc::ClientAsyncReaderWriter;
|
|
using etcdserverpb::WatchRequest;
|
|
using etcdserverpb::WatchResponse;
|
|
|
|
namespace etcdv3
|
|
{
|
|
class AsyncWatchAction : public etcdv3::Action
|
|
{
|
|
public:
|
|
AsyncWatchAction(etcdv3::ActionParameters && params);
|
|
AsyncWatchResponse ParseResponse();
|
|
void waitForResponse();
|
|
void waitForResponse(std::function<void(etcd::Response)> callback);
|
|
void CancelWatch();
|
|
bool Cancelled() const;
|
|
private:
|
|
int64_t watch_id = -1;
|
|
WatchResponse reply;
|
|
std::unique_ptr<ClientAsyncReaderWriter<WatchRequest,WatchResponse>> stream;
|
|
std::atomic_bool isCancelled;
|
|
};
|
|
}
|
|
|
|
#endif
|