MySQL 9.0.0
Source Code Documentation
ClusterAwareDecorator Class Reference

Cluster (GR or AR)-aware decorator for MySQL Sessions. More...

Public Member Functions

 ClusterAwareDecorator (ClusterMetadata &metadata, const std::string &cluster_initial_username, const std::string &cluster_initial_password, const std::string &cluster_initial_hostname, unsigned long cluster_initial_port, const std::string &cluster_initial_socket, unsigned long connection_timeout, std::set< MySQLErrorc > failure_codes={MySQLErrorc::kSuperReadOnly, MySQLErrorc::kLostConnection})
 
template<class R >
failover_on_failure (std::function< R()> wrapped_func)
 Cluster (GR or AR) aware failover. More...
 
virtual ~ClusterAwareDecorator ()=default
 

Protected Member Functions

void connect (MySQLSession &session, const std::string &host, const unsigned port)
 

Protected Attributes

ClusterMetadatametadata_
 
const std::string & cluster_initial_username_
 
const std::string & cluster_initial_password_
 
const std::string & cluster_initial_hostname_
 
unsigned long cluster_initial_port_
 
const std::string & cluster_initial_socket_
 
unsigned long connection_timeout_
 
std::set< MySQLErrorcfailure_codes_
 

Detailed Description

Cluster (GR or AR)-aware decorator for MySQL Sessions.

Constructor & Destructor Documentation

◆ ClusterAwareDecorator()

ClusterAwareDecorator::ClusterAwareDecorator ( ClusterMetadata metadata,
const std::string &  cluster_initial_username,
const std::string &  cluster_initial_password,
const std::string &  cluster_initial_hostname,
unsigned long  cluster_initial_port,
const std::string &  cluster_initial_socket,
unsigned long  connection_timeout,
std::set< MySQLErrorc failure_codes = {MySQLErrorc::kSuperReadOnlyMySQLErrorc::kLostConnection} 
)
inline

◆ ~ClusterAwareDecorator()

virtual ClusterAwareDecorator::~ClusterAwareDecorator ( )
virtualdefault

Member Function Documentation

◆ connect()

void ClusterAwareDecorator::connect ( MySQLSession session,
const std::string &  host,
const unsigned  port 
)
protected

◆ failover_on_failure()

template<class R >
R ClusterAwareDecorator::failover_on_failure ( std::function< R()>  wrapped_func)

Cluster (GR or AR) aware failover.

Parameters
wrapped_funcfunction will be called

assumes:

  • actively connected mysql_ session
  • all nodes in the group have the same user/pass combination
  • wrapped_func throws MySQLSession::Error with .code in .failure_codes

Member Data Documentation

◆ cluster_initial_hostname_

const std::string& ClusterAwareDecorator::cluster_initial_hostname_
protected

◆ cluster_initial_password_

const std::string& ClusterAwareDecorator::cluster_initial_password_
protected

◆ cluster_initial_port_

unsigned long ClusterAwareDecorator::cluster_initial_port_
protected

◆ cluster_initial_socket_

const std::string& ClusterAwareDecorator::cluster_initial_socket_
protected

◆ cluster_initial_username_

const std::string& ClusterAwareDecorator::cluster_initial_username_
protected

◆ connection_timeout_

unsigned long ClusterAwareDecorator::connection_timeout_
protected

◆ failure_codes_

std::set<MySQLErrorc> ClusterAwareDecorator::failure_codes_
protected

◆ metadata_

ClusterMetadata& ClusterAwareDecorator::metadata_
protected

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