3 #include "connection.hpp" 16 client::client(string_view conn_string) :
20 client::client(std::shared_ptr<connection> conn) noexcept :
21 _conn(std::move(conn))
28 auto conn = connection::connect(conn_string);
29 auto state_change_fut = conn->watch_state();
33 p.set_value(
client(std::move(conn)));
34 return p.get_future();
42 [state_change_fut = std::move(state_change_fut), conn = std::move(conn)] ()
mutable ->
client 44 state s(state_change_fut.get());
48 throw std::runtime_error(std::string(
"Unexpected state: ") + to_string(s));
56 p.set_exception(std::current_exception());
57 return p.get_future();
61 client::~client() noexcept =
default;
70 return _conn->get(path);
75 return _conn->watch(path);
80 return _conn->get_children(path);
85 return _conn->watch_children(path);
90 return _conn->exists(path);
95 return _conn->watch_exists(path);
104 return _conn->create(path, data, rules, mode);
117 return _conn->set(path, data, check);
122 return _conn->get_acl(path);
127 return _conn->set_acl(path, rules, check);
132 return _conn->erase(path, check);
137 return _conn->load_fence();
142 return _conn->commit(std::move(txn));
state
Enumeration of states the client may be at when a watch triggers.
future< multi_result > commit(multi_op txn)
Commit the transaction specified by txn.
future< void > erase(string_view path, version check=version::any())
Erase the node with the given path.
Represents a version of the ACL of a ZNode.
future< watch_result > watch(string_view path) const
Similar to get, but if the call is successful (no error is returned), a watch will be left on the nod...
future< exists_result > exists(string_view path) const
Return the stat of the node of the given path or nullopt if no such node exists.
future< create_result > create(string_view path, const buffer &data, const acl &rules, create_mode mode=create_mode::normal)
Create a node with the given path.
create_mode
When used in client::set, this value determines how the znode is created on the server.
static future< client > connect(string_view conn_string)
Create a client connected to the cluster specified by conn_string.
static const acl & open_unsafe()
This is a completely open ACL.
future< void > load_fence() const
Ensure that all subsequent reads observe the data at the transaction on the server at or past real-ti...
The client is in the connected state – it is connected to a server in the ensemble (one of the serve...
future< get_acl_result > get_acl(string_view path) const
Return the ACL and stat of the node of the given path.
future< watch_children_result > watch_children(string_view path) const
Similar to get_children, but if the call is successful (no error is returned), a watch will be left o...
An access control list is a wrapper around acl_rule instances.
future< watch_exists_result > watch_exists(string_view path) const
Similar to watch, but if the call is successful (no error is returned), a watch will be left on the n...
future< void > set_acl(string_view path, const acl &rules, acl_version check=acl_version::any())
Set the ACL for the node of the given path if such a node exists and the given version check matches ...
future< set_result > set(string_view path, const buffer &data, version check=version::any())
Set the data for the node of the given path if such a node exists and the given version matches the v...
future< get_result > get(string_view path) const
Return the data and the stat of the node of the given path.
future< get_children_result > get_children(string_view path) const
Return the list of the children of the node of the given path.
Represents a version of the data.
ZKPP_BUFFER_TYPE buffer
The buffer type.
A ZooKeeper client connection.