Couchbase Transactions C++ Client  1.0.0
Transactions client for couchbase
Public Member Functions | List of all members
couchbase::cluster Class Reference

Connects to a couchbase cluster, exposes cluster operations and bucket accessors. More...

#include <cluster.hxx>

Public Member Functions

 cluster (std::string cluster_address, std::string user_name, std::string password, const cluster_options &opts=cluster_options())
 Create a new cluster and connect to it. More...
 
 cluster (const cluster &cluster)
 Copy cluster. More...
 
 ~cluster ()
 Destroy a cluster. More...
 
CB_NODISCARD std::list< std::string > buckets ()
 List buckets in this cluster. More...
 
CB_NODISCARD std::shared_ptr< class bucketbucket (const std::string &name)
 Open a connection to a bucket. More...
 
CB_NODISCARD const std::string cluster_address () const
 return the cluster address More...
 
CB_NODISCARD size_t max_instances () const
 return maximum number of libcouchbase instances this cluster can use More...
 
CB_NODISCARD size_t instances () const
 return current number of libcouchbase instances the cluster has created. More...
 
CB_NODISCARD size_t available_instances () const
 return the current number of libcouchbase instances that are not being used. More...
 
CB_NODISCARD std::chrono::microseconds default_kv_timeout () const
 Default kv timeout. More...
 
CB_NODISCARD bool operator== (const couchbase::cluster &other) const
 compare two clusters for equality
 

Detailed Description

Connects to a couchbase cluster, exposes cluster operations and bucket accessors.

Examples:
examples/game_server.cxx.

Constructor & Destructor Documentation

◆ cluster() [1/2]

couchbase::cluster::cluster ( std::string  cluster_address,
std::string  user_name,
std::string  password,
const cluster_options opts = cluster_options() 
)
explicit

Create a new cluster and connect to it.

For now we are only connecting with a username and password, but this will be expanded to include ssl, with or without cert verification, soon

Parameters
cluster_addressAddress of the cluster, say couchbase://1.2.3.4
user_nameUser name to use for this connection.
passwordPassword for this user.
optsOptions for this cluster.

◆ cluster() [2/2]

couchbase::cluster::cluster ( const cluster cluster)

Copy cluster.

Creates a copy of the cluster, and connects.

Parameters
clusterThe cluster to copy.

◆ ~cluster()

couchbase::cluster::~cluster ( )

Destroy a cluster.

Calls shutdown if necessary, and deletes the underlying connection to the cluster.

Member Function Documentation

◆ available_instances()

CB_NODISCARD size_t couchbase::cluster::available_instances ( ) const

return the current number of libcouchbase instances that are not being used.

Returns
current available instances.

◆ bucket()

CB_NODISCARD std::shared_ptr<class bucket> couchbase::cluster::bucket ( const std::string &  name)

Open a connection to a bucket.

This returns a shared pointer to a bucket.

Parameters
nameName of the bucket to connect to.
Returns
shared pointer to the bucket.
Examples:
examples/game_server.cxx.

◆ buckets()

CB_NODISCARD std::list<std::string> couchbase::cluster::buckets ( )

List buckets in this cluster.

Returns a list of the names of all the buckets in this cluster.

Returns
list of strings containing all the buckets in this cluster.

◆ cluster_address()

CB_NODISCARD const std::string couchbase::cluster::cluster_address ( ) const
inline

return the cluster address

Helpful for debugging/logging. Perhaps this will go away in favor of an operator<< which is a bit more useful.

Returns
A constant string containing the cluster address used for this cluster.

◆ default_kv_timeout()

CB_NODISCARD std::chrono::microseconds couchbase::cluster::default_kv_timeout ( ) const

Default kv timeout.

Returns
The default kv timeout.

◆ instances()

CB_NODISCARD size_t couchbase::cluster::instances ( ) const

return current number of libcouchbase instances the cluster has created.

Returns
total number of instances the cluster is maintaining.

◆ max_instances()

CB_NODISCARD size_t couchbase::cluster::max_instances ( ) const

return maximum number of libcouchbase instances this cluster can use

The cluster maintains a pool of instances, lazily created, which it uses to communicate with the server. Each instance will maintain a number of socket connections. Any cluster calls that need an instance will use one, making it unavailable until the call is done with it. See cluster_options to set this value.

Returns
maximum number of libcouchbase instances the cluster can use.

The documentation for this class was generated from the following file: