3 #include <zk/config.hpp>
13 #include "forwards.hpp"
31 static std::shared_ptr<connection> connect(string_view conn_string);
35 virtual void close() = 0;
37 virtual future<get_result>
get(string_view path) = 0;
39 virtual future<watch_result> watch(string_view path) = 0;
41 virtual future<get_children_result> get_children(string_view path) = 0;
43 virtual future<watch_children_result> watch_children(string_view path) = 0;
45 virtual future<exists_result> exists(string_view path) = 0;
47 virtual future<watch_exists_result> watch_exists(string_view path) = 0;
49 virtual future<create_result> create(string_view path,
55 virtual future<set_result> set(string_view path,
const buffer& data,
version check) = 0;
57 virtual future<void> erase(string_view path,
version check) = 0;
59 virtual future<get_acl_result> get_acl(string_view path)
const = 0;
61 virtual future<void> set_acl(string_view path,
const acl& rules,
acl_version check) = 0;
63 virtual future<multi_result> commit(
multi_op&& txn) = 0;
65 virtual future<void> load_fence() = 0;
78 mutable std::mutex _state_change_promises_protect;
79 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);
142 const host_list&
hosts()
const {
return _hosts; }
143 host_list&
hosts() {
return _hosts; }
151 const std::string&
chroot()
const {
return _chroot; }
152 std::string&
chroot() {
return _chroot; }
175 std::chrono::milliseconds
timeout()
const {
return _timeout; }
176 std::chrono::milliseconds&
timeout() {
return _timeout; }
180 std::string _connection_schema;
183 bool _randomize_hosts;
185 std::chrono::milliseconds _timeout;
188 bool operator==(
const connection_params& lhs,
const connection_params& rhs);
189 bool operator!=(
const connection_params& lhs,
const connection_params& rhs);
191 std::string to_string(
const connection_params&);
192 std::ostream& operator<<(std::ostream&,
const connection_params&);
std::chrono::milliseconds timeout() const
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.
connection_params() noexcept
Create an instance with default values.
Represents a version of the ACL of an entry.
const std::string & connection_schema() const
create_mode
When used in client::set, this value determines how the entry is created on the server.
const host_list & hosts() const
Used to specify parameters for a connection.
const std::string & chroot() const
A collection of operations that will be performed atomically.
Controls the import of future and promise types.
virtual future< zk::state > watch_state()
Watch for a state change.
Imports the string_view type as std::string_view.
An access control list is a wrapper around acl_rule instances.
bool randomize_hosts() const
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.
An actual connection to the server.