3 #include "connection.hpp"
25 _conn(std::move(conn))
37 auto conn = connection::connect(conn_params);
38 auto state_change_fut = conn->watch_state();
42 p.set_value(
client(std::move(conn)));
43 return p.get_future();
51 [state_change_fut = std::move(state_change_fut), conn = std::move(conn)] ()
mutable ->
client
53 state s(state_change_fut.get());
57 throw std::runtime_error(std::string(
"Unexpected state: ") + to_string(s));
65 p.set_exception(std::current_exception());
66 return p.get_future();
70 client::~client() noexcept = default;
79 return _conn->get(path);
84 return _conn->watch(path);
89 return _conn->get_children(path);
94 return _conn->watch_children(path);
99 return _conn->exists(path);
104 return _conn->watch_exists(path);
113 return _conn->create(path, data, rules, mode);
126 return _conn->set(path, data, check);
131 return _conn->get_acl(path);
136 return _conn->set_acl(path, rules, check);
141 return _conn->erase(path, check);
146 return _conn->load_fence();
151 return _conn->commit(std::move(txn));
static connection_params parse(string_view conn_string)
Create an instance from a connection string.
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 entry at the given path.
client(const connection_params ¶ms)
Create a client connected to the cluster specified by params.
Represents a version of the ACL of an entry.
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 ent...
future< exists_result > exists(string_view path) const
Return the stat of the entry of the given path or nullopt if it does not exist.
future< create_result > create(string_view path, const buffer &data, const acl &rules, create_mode mode=create_mode::normal)
create_mode
When used in client::set, this value determines how the entry is created on the server.
static future< client > connect(string_view conn_string)
void close()
Close the underlying connection.
Used to specify parameters for a connection.
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...
A collection of operations that will be performed atomically.
future< get_acl_result > get_acl(string_view path) const
Return the ACL and stat of the entry 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 e...
future< void > set_acl(string_view path, const acl &rules, acl_version check=acl_version::any())
Set the ACL for the entry of the given path if such an entry exists and the given version check match...
future< set_result > set(string_view path, const buffer &data, version check=version::any())
Set the data for the entry of the given path if such an entry exists and the given version matches th...
future< get_result > get(string_view path) const
Return the data and the stat of the entry of the given path.
future< get_children_result > get_children(string_view path) const
Return the list of the children of the entry of the given path.
Represents a version of the data.
ZKPP_BUFFER_TYPE buffer
The buffer type.
A ZooKeeper client connection.
An actual connection to the server.