3 #include <zk/config.hpp>
13 #include "forwards.hpp"
29 static std::shared_ptr<connection> connect(string_view conn_string);
33 virtual void close() = 0;
35 virtual future<get_result>
get(string_view path) = 0;
37 virtual future<watch_result> watch(string_view path) = 0;
39 virtual future<get_children_result> get_children(string_view path) = 0;
41 virtual future<watch_children_result> watch_children(string_view path) = 0;
43 virtual future<exists_result> exists(string_view path) = 0;
45 virtual future<watch_exists_result> watch_exists(string_view path) = 0;
47 virtual future<create_result> create(string_view path,
53 virtual future<set_result> set(string_view path,
const buffer& data,
version check) = 0;
55 virtual future<void> erase(string_view path,
version check) = 0;
57 virtual future<get_acl_result> get_acl(string_view path)
const = 0;
59 virtual future<void> set_acl(string_view path,
const acl& rules,
acl_version check) = 0;
61 virtual future<multi_result> commit(
multi_op&& txn) = 0;
63 virtual future<void> load_fence() = 0;
77 mutable std::mutex _state_change_promises_protect;
78 std::vector<promise<zk::state>> _state_change_promises;
87 using host_list = std::vector<std::string>;
90 static constexpr std::chrono::milliseconds default_timeout = std::chrono::seconds(10);
141 const host_list&
hosts()
const {
return _hosts; }
142 host_list&
hosts() {
return _hosts; }
149 const std::string&
chroot()
const {
return _chroot; }
150 std::string&
chroot() {
return _chroot; }
169 std::chrono::milliseconds
timeout()
const {
return _timeout; }
170 std::chrono::milliseconds&
timeout() {
return _timeout; }
173 std::string _connection_schema;
176 bool _randomize_hosts;
178 std::chrono::milliseconds _timeout;
181 bool operator==(
const connection_params& lhs,
const connection_params& rhs);
182 bool operator!=(
const connection_params& lhs,
const connection_params& rhs);
184 std::string to_string(
const connection_params&);
185 std::ostream& operator<<(std::ostream&,
const connection_params&);
std::chrono::milliseconds timeout() const
The session timeout between this client and the server.
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.
bool read_only() const
Allow connections to read-only servers? The default (false) is to disallow.
connection_params() noexcept
Create an instance with default values.
Represents a version of the ACL of a ZNode.
const std::string & connection_schema() const
Determines the underlying zk::connection implementation to use.
create_mode
When used in client::set, this value determines how the znode is created on the server.
const host_list & hosts() const
Addresses for the ensemble to connect to.
Used to specify parameters for a connection.
const std::string & chroot() const
Specifying a value for chroot as something aside from "" or "/" will run the client commands while in...
Controls the import of future and promise types.
virtual future< zk::state > watch_state()
Watch for a state change.
Controls the import of the string_view type.
An access control list is a wrapper around acl_rule instances.
bool randomize_hosts() const
Connect to a host at random (as opposed to attempting connections in order)? The default is to random...
Controls the buffer type.
virtual void on_session_event(zk::state new_state)
Call this from derived classes when a session event happens.
Represents a version of the data.
ZKPP_BUFFER_TYPE buffer
The buffer type.