zookeeper-cpp
ZooKeeper Client for C++
|
Interacting with ZooKeeper as a client. More...
Classes | |
class | zk::acl_rule |
An individual rule in an acl. More... | |
class | zk::acl |
An access control list is a wrapper around acl_rule instances. More... | |
class | zk::acls |
Commonly-used ACLs. More... | |
class | zk::client |
A ZooKeeper client connection. More... | |
class | zk::connection |
An actual connection to the server. More... | |
class | zk::connection_params |
Used to specify parameters for a connection . More... | |
class | zk::connection_zk |
class | zk::error |
Base error type for all errors raised by this library. More... | |
class | zk::transport_error |
Base types for errors that occurred while transporting data across a network. More... | |
class | zk::connection_loss |
Connection to the server has been lost before the attempted operation was verified as completed. More... | |
class | zk::marshalling_error |
An error occurred while marshalling data. More... | |
class | zk::not_implemented |
Operation was attempted that was not implemented. More... | |
class | zk::invalid_arguments |
Arguments to an operation were invalid. More... | |
class | zk::authentication_failed |
The server rejected the connection due to invalid authentication information. More... | |
class | zk::invalid_ensemble_state |
Base exception for cases where the ensemble is in an invalid state to perform a given action. More... | |
class | zk::new_configuration_no_quorum |
Raised when attempting an ensemble reconfiguration, but the proposed new ensemble would not be able to form quorum. More... | |
class | zk::reconfiguration_in_progress |
An attempt was made to reconfigure the ensemble, but there is already a reconfiguration in progress. More... | |
class | zk::reconfiguration_disabled |
The ensemble does not support reconfiguration. More... | |
class | zk::invalid_connection_state |
Base type for errors generated because the connection is misconfigured. More... | |
class | zk::session_expired |
The client session has been ended by the server. More... | |
class | zk::not_authorized |
An attempt was made to read or write to a ZNode when the connection does not have permission to do. More... | |
class | zk::closed |
The connection is closed. More... | |
class | zk::ephemeral_on_local_session |
An attempt was made to create an ephemeral entry, but the connection has a local session. More... | |
class | zk::read_only_connection |
A write operation was attempted on a read-only connection. More... | |
class | zk::check_failed |
Base exception for cases where a write operation was rolled back due to a failed check. More... | |
class | zk::no_entry |
Thrown from read operations when attempting to read a ZNode that does not exist. More... | |
class | zk::entry_exists |
Thrown when attempting to create a ZNode, but one already exists at the specified path. More... | |
class | zk::not_empty |
Thrown when attempting to erase a ZNode that has children. More... | |
class | zk::version_mismatch |
Thrown from modification operations when a version check is specified and the value in the database does not match the expected. More... | |
class | zk::no_children_for_ephemerals |
Ephemeral ZNodes cannot have children. More... | |
class | zk::transaction_failed |
Thrown from client::commit when a transaction cannot be committed to the system. More... | |
class | zk::op |
Represents a single operation of a multi_op. More... | |
class | zk::multi_op |
A collection of operations that will be performed atomically. More... | |
class | zk::multi_result |
The result of a successful client::commit operation. More... | |
class | zk::get_result |
The result type of client::get . More... | |
class | zk::get_children_result |
The result type of client::get_children . More... | |
class | zk::exists_result |
The result type of client::exists. More... | |
class | zk::create_result |
The result type of client::create. More... | |
class | zk::set_result |
The result type of client::set. More... | |
class | zk::get_acl_result |
The result type of client::get_acl. More... | |
class | zk::event |
Data delivered when a watched event triggers. More... | |
class | zk::watch_result |
The result type of client::watch. More... | |
class | zk::watch_children_result |
The result type of client::watch_children. More... | |
class | zk::watch_exists_result |
The result type of client::watch_exists. More... | |
struct | zk::strong_id< TReal, TId > |
Base type for creating strong ID types. More... | |
struct | zk::basic_version< TReal > |
Base type for version types. More... | |
struct | zk::version |
Represents a version of the data. More... | |
struct | zk::acl_version |
Represents a version of the ACL of an entry. More... | |
struct | zk::child_version |
Represents a version of the children of an entry. More... | |
struct | zk::transaction_id |
Represents the ZooKeeper transaction ID in which an event happened to an entry. More... | |
struct | zk::stat |
Statistics about a ZooKeeper entry, similar to the UNIX stat structure. More... | |
Macros | |
#define | ZKPP_BUFFER_USE_STD_STRING 0 |
#define | ZKPP_BUFFER_USE_CUSTOM 0 |
Set this to 1 to use a custom definitions for buffer . More... | |
#define | ZKPP_BUFFER_INCLUDE <vector> |
The header file to use to find the buffer type. More... | |
#define | ZKPP_BUFFER_TYPE std::vector<char> |
The type name to use for the buffer type. More... | |
#define | ZKPP_BUFFER_USE_STD_VECTOR 1 |
Set this to 1 to use std::vector<char> for the implementation of zk::buffer. More... | |
#define | ZKPP_VERSION_MAJOR 0 |
#define | ZKPP_VERSION_MINOR 2 |
#define | ZKPP_VERSION_PATCH 3 |
#define | ZKPP_DEBUG 0 |
Was ZooKeeper C++ compiled in debug mode? This value must be the same between when the SO was built and when you are compiling. More... | |
#define | ZKPP_FUTURE_USE_STD_EXPERIMENTAL 0 |
Set this to 1 to use std::experimental::future and std::experimental::promise as the backing types for zk::future and zk::promise . More... | |
#define | ZKPP_FUTURE_USE_CUSTOM 0 |
Set this to 1 to use custom definitions of zk::future and zk::promise . More... | |
#define | ZKPP_FUTURE_TEMPLATE std::future |
The template to use for zk::future . More... | |
#define | ZKPP_PROMISE_TEMPLATE std::promise |
The template to use for zk::promise . More... | |
#define | ZKPP_FUTURE_INCLUDE <future> |
The file to include to get the implementation for future and promise . More... | |
#define | ZKPP_FUTURE_USE_STD 1 |
Set this to 1 to use std::future and std::promise as the backing types for zk::future and zk::promise . More... | |
Typedefs | |
using | zk::buffer = ZKPP_BUFFER_TYPE |
The buffer type. More... | |
template<typename T > | |
using | zk::ptr = T * |
A simple, unowned pointer. More... | |
template<typename T > | |
using | zk::future = ZKPP_FUTURE_TEMPLATE< T > |
template<typename T > | |
using | zk::promise = ZKPP_PROMISE_TEMPLATE< T > |
template<typename T > | |
using | zk::optional = std::optional< T > |
using | zk::nullopt_t = std::nullopt_t |
using | zk::string_view = std::string_view |
Functions | |
constexpr permission | zk::operator| (permission a, permission b) |
Set union operation of permission. More... | |
constexpr permission | zk::operator& (permission a, permission b) |
Set intersection operation of permission. More... | |
constexpr permission | zk::operator~ (permission a) |
Set inverse operation of permission. More... | |
constexpr bool | zk::allows (permission self, permission perform) |
Check that self allows it perform all operations. More... | |
std::ostream & | zk::operator<< (std::ostream &os, const permission &self) |
std::string | zk::to_string (const permission &self) |
std::size_t | zk::hash (const acl_rule &rule) |
Compute a hash for the given rule. More... | |
bool | zk::operator== (const acl_rule &lhs, const acl_rule &rhs) |
bool | zk::operator!= (const acl_rule &lhs, const acl_rule &rhs) |
bool | zk::operator< (const acl_rule &lhs, const acl_rule &rhs) |
bool | zk::operator<= (const acl_rule &lhs, const acl_rule &rhs) |
bool | zk::operator> (const acl_rule &lhs, const acl_rule &rhs) |
bool | zk::operator>= (const acl_rule &lhs, const acl_rule &rhs) |
std::ostream & | zk::operator<< (std::ostream &os, const acl_rule &self) |
std::string | zk::to_string (const acl_rule &self) |
bool | zk::operator== (const acl &lhs, const acl &rhs) |
bool | zk::operator!= (const acl &lhs, const acl &rhs) |
std::ostream & | zk::operator<< (std::ostream &os, const acl &self) |
std::string | zk::to_string (const acl &self) |
bool | zk::operator== (const connection_params &lhs, const connection_params &rhs) |
bool | zk::operator!= (const connection_params &lhs, const connection_params &rhs) |
std::string | zk::to_string (const connection_params &x) |
std::ostream & | zk::operator<< (std::ostream &os, const connection_params &x) |
constexpr bool | zk::is_transport_error (error_code code) |
Check if the provided code is an exception code for a transport_error type of exception. More... | |
constexpr bool | zk::is_invalid_arguments (error_code code) |
Check if the provided code is an exception code for a invalid_arguments type of exception. More... | |
constexpr bool | zk::is_invalid_ensemble_state (error_code code) |
Check if the provided code is an exception code for a invalid_ensemble_state type of exception. More... | |
constexpr bool | zk::is_invalid_connection_state (error_code code) |
Check if the provided code is an exception code for a invalid_connection_state type of exception. More... | |
constexpr bool | zk::is_check_failed (error_code code) |
Check if the provided code is an exception code for a check_failed type of exception. More... | |
std::ostream & | zk::operator<< (std::ostream &os, const error_code &code) |
std::string | zk::to_string (const error_code &code) |
void | zk::throw_error (error_code code) |
Throw an exception for the given code. More... | |
std::exception_ptr | zk::get_exception_ptr_of (error_code code) |
Get an std::exception_ptr containing an exception with the proper type for the given code. More... | |
const std::error_category & | zk::error_category () |
Get the std::error_category capable of describing ZooKeeper-provided error codes. More... | |
std::ostream & | zk::operator<< (std::ostream &os, const op_type &self) |
std::string | zk::to_string (const op_type &self) |
std::ostream & | zk::operator<< (std::ostream &os, const op &self) |
std::string | zk::to_string (const op &self) |
std::ostream & | zk::operator<< (std::ostream &os, const multi_op &self) |
std::string | zk::to_string (const multi_op &) |
std::ostream & | zk::operator<< (std::ostream &os, const multi_result::part &self) |
std::ostream & | zk::operator<< (std::ostream &os, const multi_result &self) |
std::string | zk::to_string (const multi_result::part &self) |
std::string | zk::to_string (const multi_result &self) |
template<typename FUnary , typename... T> | |
auto | zk::map (FUnary &&transform, const optional< T > &...x) -> optional< decltype(transform(x.value()...))> |
Apply transform with the arguments in x iff all of them have a value. Otherwise, nullopt will be returned. More... | |
template<typename T > | |
optional< T > | zk::some (T x) |
std::ostream & | zk::operator<< (std::ostream &os, const get_result &self) |
std::string | zk::to_string (const get_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const get_children_result &self) |
std::string | zk::to_string (const get_children_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const exists_result &self) |
std::string | zk::to_string (const exists_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const create_result &self) |
std::string | zk::to_string (const create_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const set_result &self) |
std::string | zk::to_string (const set_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const get_acl_result &self) |
std::string | zk::to_string (const get_acl_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const event &self) |
std::string | zk::to_string (const event &self) |
std::ostream & | zk::operator<< (std::ostream &os, const watch_result &self) |
std::string | zk::to_string (const watch_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const watch_children_result &self) |
std::string | zk::to_string (const watch_children_result &self) |
std::ostream & | zk::operator<< (std::ostream &os, const watch_exists_result &self) |
std::string | zk::to_string (const watch_exists_result &self) |
template<typename TReal , typename TId > | |
constexpr bool | zk::operator== (const strong_id< TReal, TId > &a, const strong_id< TReal, TId > &b) |
template<typename TReal , typename TId > | |
constexpr bool | zk::operator!= (const strong_id< TReal, TId > &a, const strong_id< TReal, TId > &b) |
template<typename TReal , typename TId > | |
constexpr bool | zk::operator< (const strong_id< TReal, TId > &a, const strong_id< TReal, TId > &b) |
template<typename TReal , typename TId > | |
constexpr bool | zk::operator<= (const strong_id< TReal, TId > &a, const strong_id< TReal, TId > &b) |
template<typename TReal , typename TId > | |
constexpr bool | zk::operator> (const strong_id< TReal, TId > &a, const strong_id< TReal, TId > &b) |
template<typename TReal , typename TId > | |
constexpr bool | zk::operator>= (const strong_id< TReal, TId > &a, const strong_id< TReal, TId > &b) |
template<typename TReal , typename TId > | |
std::size_t | zk::hash (const strong_id< TReal, TId > &x) |
Compute the std::hash of the given x. More... | |
std::ostream & | zk::operator<< (std::ostream &os, const version &self) |
std::string | zk::to_string (const version &self) |
std::ostream & | zk::operator<< (std::ostream &os, const acl_version &self) |
std::string | zk::to_string (const acl_version &self) |
std::ostream & | zk::operator<< (std::ostream &os, const child_version &self) |
std::string | zk::to_string (const child_version &self) |
std::ostream & | zk::operator<< (std::ostream &os, const transaction_id &self) |
std::string | zk::to_string (const transaction_id &self) |
std::ostream & | zk::operator<< (std::ostream &os, const stat &self) |
std::string | zk::to_string (const stat &self) |
constexpr create_mode | zk::operator| (create_mode a, create_mode b) |
Set union operation of create_mode. More... | |
constexpr create_mode | zk::operator& (create_mode a, create_mode b) |
Set intersection operation of create_mode. More... | |
constexpr create_mode | zk::operator~ (create_mode a) |
Set inverse operation of create_mode. More... | |
constexpr bool | zk::is_set (create_mode self, create_mode flags) |
Check that self has flags set. More... | |
std::ostream & | zk::operator<< (std::ostream &os, const create_mode &mode) |
std::string | zk::to_string (const create_mode &self) |
std::ostream & | zk::operator<< (std::ostream &os, const event_type &self) |
std::string | zk::to_string (const event_type &self) |
std::ostream & | zk::operator<< (std::ostream &os, const state &self) |
std::string | zk::to_string (const state &state) |
Get the string representation of the provided state. More... | |
Interacting with ZooKeeper as a client.
#define ZKPP_BUFFER_INCLUDE <vector> |
The header file to use to find the buffer
type.
This value is set automatically if using built-in configuration options (such as ZKPP_BUFFER_USE_STD_VECTOR) and must be set manually if using ZKPP_BUFFER_USE_CUSTOM.
Definition at line 45 of file buffer.hpp.
#define ZKPP_BUFFER_TYPE std::vector<char> |
The type name to use for the buffer
type.
This value is set automatically if using built-in configuration options (such as ZKPP_BUFFER_USE_STD_VECTOR) and must be set manually if using ZKPP_BUFFER_USE_CUSTOM.
Definition at line 46 of file buffer.hpp.
#define ZKPP_BUFFER_USE_CUSTOM 0 |
Set this to 1 to use a custom definitions for buffer
.
If this is set, you must also set ZKPP_BUFFER_INCLUDE and ZKPP_BUFFER_TYPE.
Definition at line 31 of file buffer.hpp.
#define ZKPP_BUFFER_USE_STD_VECTOR 1 |
Set this to 1 to use std::vector<char>
for the implementation of zk::buffer.
This is the default behavior.
Definition at line 40 of file buffer.hpp.
#define ZKPP_DEBUG 0 |
Was ZooKeeper C++ compiled in debug mode? This value must be the same between when the SO was built and when you are compiling.
In general, this is not useful outside of library maintainers.
#if ZKPP_DEBUG
, not #ifdef ZKPP_DEBUG
. Definition at line 23 of file config.hpp.
#define ZKPP_FUTURE_INCLUDE <future> |
The file to include to get the implementation for future
and promise
.
If you define ZKPP_FUTURE_TEMPLATE
and ZKPP_PROMISE_TEMPLATE
, you must also define this.
Definition at line 52 of file future.hpp.
#define ZKPP_FUTURE_TEMPLATE std::future |
The template to use for zk::future
.
By default, this is std::future
.
Definition at line 53 of file future.hpp.
#define ZKPP_FUTURE_USE_CUSTOM 0 |
Set this to 1 to use custom definitions of zk::future
and zk::promise
.
If this is set, you must also set ZKPP_FUTURE_TEMPLATE
, ZKPP_PROMISE_TEMPLATE
, and ZKPP_FUTURE_INCLUDE
.
Definition at line 36 of file future.hpp.
#define ZKPP_FUTURE_USE_STD 1 |
Set this to 1 to use std::future
and std::promise
as the backing types for zk::future
and zk::promise
.
This is the default behavior.
Definition at line 47 of file future.hpp.
#define ZKPP_FUTURE_USE_STD_EXPERIMENTAL 0 |
Set this to 1 to use std::experimental::future
and std::experimental::promise
as the backing types for zk::future
and zk::promise
.
Definition at line 18 of file future.hpp.
#define ZKPP_PROMISE_TEMPLATE std::promise |
The template to use for zk::promise
.
This should be highly related to ZKPP_FUTURE_TEMPLATE
Definition at line 54 of file future.hpp.
using zk::buffer = typedef ZKPP_BUFFER_TYPE |
The buffer
type.
By default, this is an std::vector<char>
, but this can be altered by compile-time flags such as ZKPP_BUFFER_USE_CUSTOM. The requirements for a custom buffer are minimal – the type must fit this criteria:
expression | type | description |
---|---|---|
buffer::value_type | char | Buffers must be made of single-byte elements |
buffer::size_type | std::size_t | |
buffer(ib, ie) | buffer | Constructs a buffer with the range [ib , ie ) |
buffer(buffer&&) | buffer | Move constructible. |
size() | size_type | Get the length of the buffer |
data() | const value_type* | Get a pointer to the beginning of the contents |
Definition at line 79 of file buffer.hpp.
using zk::ptr = typedef T* |
A simple, unowned pointer.
It operates exactly like using *
, but removes the question of *
associativity and is easier to read when const
qualifiers are involved.
Definition at line 37 of file config.hpp.
|
strong |
When used in client::set
, this value determines how the entry is created on the server.
These values can be ORed together to create combinations.
Enumerator | |
---|---|
normal |
Standard behavior of an entry – the opposite of doing any of the options. |
ephemeral |
The entry will be deleted when the client session expires. |
sequential |
The name of the entry will be appended with a monotonically increasing number. The actual path name of a sequential entry will be the given path plus a suffix |
container |
Container entries are special purpose entries useful for recipes such as leader, lock, etc. When the last child of a container is deleted, the container becomes a candidate to be deleted by the server at some point in the future. Given this property, you should be prepared to get no_entry when creating children inside of this container entry. |
|
strong |
Code for all error types thrown by the client library.
Enumerator | |
---|---|
ok |
Never thrown. |
connection_loss |
Code for connection_loss. |
marshalling_error |
Code for marshalling_error. |
not_implemented |
Code for not_implemented. |
invalid_arguments |
Code for invalid_arguments. |
new_configuration_no_quorum |
Code for new_configuration_no_quorum. |
reconfiguration_in_progress |
Code for reconfiguration_in_progress. |
no_entry |
Code for no_entry. |
not_authorized |
Code for not_authorized. |
version_mismatch |
Code for version_mismatch. |
no_children_for_ephemerals |
Code for no_children_for_ephemerals. |
entry_exists |
Code for entry_exists. |
not_empty |
Code for not_empty. |
session_expired |
Code for session_expired. |
authentication_failed |
Code for authentication_failed. |
closed |
Code for closed. |
read_only_connection |
Code for read_only_connection. |
ephemeral_on_local_session |
Code for ephemeral_on_local_session. |
reconfiguration_disabled |
Code for reconfiguration_disabled. |
transaction_failed |
Code for transaction_failed. |
|
strong |
Enumeration of types of events that may occur.
|
strong |
|
strong |
Describes the ability of a user to perform a certain action.
Permissions can be mixed together like integers with | and
&
.
|
strong |
Enumeration of states the client may be at when a watch triggers.
It represents the state of the connection at the time the event was generated.
ZOO_NOTCONNECTED_STATE
equivalent. This state happens in cases where the client disconnects on purpose (either on initial connection or just after ensemble reconfiguration). However, the ability to see this state is limited to times when you call zk_state
at just the right moment. This state leads to a bit of confusion with closed
and expired_session
, so it is not in the list. Instead, these cases are presented as just connecting
, as the client is attempting to reconnect to the cluster. constexpr bool zk::allows | ( | permission | self, |
permission | perform | ||
) |
Check that self allows it perform all operations.
For example, allows(permission::read | permission::write, permission::read)
will be true
, as read|write
is allowed to read
.
const std::error_category & zk::error_category | ( | ) |
std::exception_ptr zk::get_exception_ptr_of | ( | error_code | code | ) |
std::size_t zk::hash | ( | const acl_rule & | self | ) |
|
inline |
|
inline |
Check if the provided code is an exception code for a check_failed type of exception.
|
inline |
Check if the provided code is an exception code for a invalid_arguments type of exception.
|
inline |
Check if the provided code is an exception code for a invalid_connection_state type of exception.
|
inline |
Check if the provided code is an exception code for a invalid_ensemble_state type of exception.
constexpr bool zk::is_set | ( | create_mode | self, |
create_mode | flags | ||
) |
|
inline |
Check if the provided code is an exception code for a transport_error type of exception.
auto zk::map | ( | FUnary && | transform, |
const optional< T > &... | x | ||
) | -> optional<decltype(transform(x.value()...))> |
Apply transform with the arguments in x iff all of them have a value. Otherwise, nullopt
will be returned.
Definition at line 25 of file optional.hpp.
constexpr permission zk::operator& | ( | permission | a, |
permission | b | ||
) |
constexpr create_mode zk::operator& | ( | create_mode | a, |
create_mode | b | ||
) |
constexpr permission zk::operator| | ( | permission | a, |
permission | b | ||
) |
constexpr create_mode zk::operator| | ( | create_mode | a, |
create_mode | b | ||
) |
constexpr permission zk::operator~ | ( | permission | a | ) |
constexpr create_mode zk::operator~ | ( | create_mode | a | ) |
void zk::throw_error | ( | error_code | code | ) |