forked from etcd-cpp-apiv3/etcd-cpp-apiv3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransaction.hpp
60 lines (47 loc) · 1.71 KB
/
Transaction.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef V3_SRC_TRANSACTION_HPP_
#define V3_SRC_TRANSACTION_HPP_
#include <string>
#include <memory>
namespace etcdserverpb {
class TxnRequest;
}
namespace etcdv3 {
enum class CompareResult {
EQUAL = 0,
GREATER = 1,
LESS = 2,
NOT_EQUAL = 3,
};
enum class CompareTarget {
VERSION = 0,
CREATE = 1,
MOD = 2,
VALUE = 3,
LEASE = 4,
};
class Transaction {
public:
Transaction();
Transaction(std::string const&);
virtual ~Transaction();
// Set a new key for different comparisons and /put/get/delete requests.
void reset_key(std::string const& newkey);
void init_compare(CompareResult, CompareTarget);
void init_compare(std::string const &old_value, CompareResult, CompareTarget);
void init_compare(int64_t old_value, CompareResult, CompareTarget);
void setup_basic_failure_operation(std::string const &key);
void setup_set_failure_operation(std::string const &key, std::string const &value, int64_t leaseid);
void setup_basic_create_sequence(std::string const &key, std::string const &value, int64_t leaseid);
void setup_compare_and_swap_sequence(std::string const &valueToSwap, int64_t leaseid);
void setup_delete_sequence(std::string const &key, std::string const &range_end, bool recursive);
void setup_delete_failure_operation(std::string const &key, std::string const &range_end, bool recursive);
void setup_compare_and_delete_operation(std::string const& key);
// update without `get` and no `prev_kv` returned
void setup_put(std::string const &key, std::string const &value);
void setup_delete(std::string const &key);
std::shared_ptr<etcdserverpb::TxnRequest> txn_request;
private:
std::string key;
};
}
#endif