MySQL 8.4.2
Source Code Documentation
mysql_harness::DynamicConfig Class Reference

Respresents the current Router configuration. More...

#include <dynamic_config.h>

Classes

struct  SectionConfig
 

Public Types

enum class  ValueType { ConfiguredValue , DefaultForCluster , DefaultForClusterSet }
 Type of the options stored in the dynamic configuration object. More...
 
using OptionName = std::string
 
using OptionValue = std::variant< std::monostate, int64_t, bool, double, std::string >
 
using SectionId = std::pair< std::string, std::string >
 
using SectionOptions = std::map< OptionName, OptionValue >
 
using JsonAllocator = rapidjson::CrtAllocator
 
using JsonDocument = rapidjson::GenericDocument< rapidjson::UTF8<>, JsonAllocator >
 

Public Member Functions

void set_option_configured (const SectionId &section_id, std::string_view option_name, const OptionValue &value)
 Sets a given option in a given section to a specific value. More...
 
void set_option_default (const SectionId &section_id, std::string_view option_name, const OptionValue &default_value_cluster, const OptionValue &default_value_clusterset)
 Sets a default for an option in a given section to a specific value. More...
 
void set_option_default (const SectionId &section_id, std::string_view option_name, const OptionValue &default_value)
 Sets a default for an option in a given section to a specific value. More...
 
JsonDocument get_json (const ValueType value_type) const
 Return the current configuration options and their values stored in the dynamic configuration object. More...
 
std::string get_json_as_string (const ValueType value_type) const
 Return the current configuration options and their values stored in the dynamic configuration object as a string. More...
 
void clear ()
 Clear the DynamicConfig object (remove all registered sections with their option values and defaults). More...
 

Static Public Member Functions

static DynamicConfiginstance ()
 Returns a singleton object of DynamicConfig class. More...
 

Private Types

using Config = std::map< SectionId, SectionConfig >
 

Private Member Functions

 DynamicConfig ()=default
 
 DynamicConfig (const DynamicConfig &)=delete
 
DynamicConfigoperator= (const DynamicConfig &)=delete
 
void set_option (const ValueType value_type, const SectionId &section_id, std::string_view option_name, const OptionValue &value)
 
Configget_config (const ValueType value_type)
 
Config const & get_config (const ValueType value_type) const
 

Private Attributes

Config configured_
 
Config defaults_cluster_
 
Config defaults_clusterset_
 

Detailed Description

Respresents the current Router configuration.

It is initialized at start with the defaults and configuration from the configuration file(s).

Member Typedef Documentation

◆ Config

◆ JsonAllocator

using mysql_harness::DynamicConfig::JsonAllocator = rapidjson::CrtAllocator

◆ JsonDocument

using mysql_harness::DynamicConfig::JsonDocument = rapidjson::GenericDocument<rapidjson::UTF8<>, JsonAllocator>

◆ OptionName

◆ OptionValue

using mysql_harness::DynamicConfig::OptionValue = std::variant<std::monostate, int64_t, bool, double, std::string>

◆ SectionId

using mysql_harness::DynamicConfig::SectionId = std::pair<std::string, std::string>

◆ SectionOptions

Member Enumeration Documentation

◆ ValueType

Type of the options stored in the dynamic configuration object.

Enumerator
ConfiguredValue 
DefaultForCluster 
DefaultForClusterSet 

Constructor & Destructor Documentation

◆ DynamicConfig() [1/2]

mysql_harness::DynamicConfig::DynamicConfig ( )
privatedefault

◆ DynamicConfig() [2/2]

mysql_harness::DynamicConfig::DynamicConfig ( const DynamicConfig )
privatedelete

Member Function Documentation

◆ clear()

void mysql_harness::DynamicConfig::clear ( )

Clear the DynamicConfig object (remove all registered sections with their option values and defaults).

◆ get_config() [1/2]

DynamicConfig::Config & mysql_harness::DynamicConfig::get_config ( const ValueType  value_type)
private

◆ get_config() [2/2]

DynamicConfig::Config const & mysql_harness::DynamicConfig::get_config ( const ValueType  value_type) const
private

◆ get_json()

JsonDocument mysql_harness::DynamicConfig::get_json ( const ValueType  value_type) const

Return the current configuration options and their values stored in the dynamic configuration object.

Parameters
value_typetype of the options to be returned
Returns
JSON Document containing all the options of a selected type.

◆ get_json_as_string()

std::string mysql_harness::DynamicConfig::get_json_as_string ( const ValueType  value_type) const

Return the current configuration options and their values stored in the dynamic configuration object as a string.

Parameters
value_typetype of the options to be returned
Returns
JSON string containing all the options of a selected type.

◆ instance()

DynamicConfig & mysql_harness::DynamicConfig::instance ( )
static

Returns a singleton object of DynamicConfig class.

◆ operator=()

DynamicConfig & mysql_harness::DynamicConfig::operator= ( const DynamicConfig )
privatedelete

◆ set_option()

void mysql_harness::DynamicConfig::set_option ( const ValueType  value_type,
const SectionId section_id,
std::string_view  option_name,
const OptionValue value 
)
private

◆ set_option_configured()

void mysql_harness::DynamicConfig::set_option_configured ( const SectionId section_id,
std::string_view  option_name,
const OptionValue value 
)

Sets a given option in a given section to a specific value.

Parameters
section_ididentifier of a section for this operation
option_namename of the option inside a section for this operation
valuevalue to be set

◆ set_option_default() [1/2]

void mysql_harness::DynamicConfig::set_option_default ( const SectionId section_id,
std::string_view  option_name,
const OptionValue default_value 
)

Sets a default for an option in a given section to a specific value.

Overload for more common case when cluster and clusterset values are the same.

Parameters
section_ididentifier of a section for this operation
option_namename of the option inside a section for this operation
default_valuedefault value for both srtandalne cluster and clusterset setup to be set

◆ set_option_default() [2/2]

void mysql_harness::DynamicConfig::set_option_default ( const SectionId section_id,
std::string_view  option_name,
const OptionValue default_value_cluster,
const OptionValue default_value_clusterset 
)

Sets a default for an option in a given section to a specific value.

Parameters
section_ididentifier of a section for this operation
option_namename of the option inside a section for this operation
default_value_clusterdefault value for srtandalne cluster setup to be set
default_value_clustersetdefault value for the clusterset setup to be set

Member Data Documentation

◆ configured_

Config mysql_harness::DynamicConfig::configured_
private

◆ defaults_cluster_

Config mysql_harness::DynamicConfig::defaults_cluster_
private

◆ defaults_clusterset_

Config mysql_harness::DynamicConfig::defaults_clusterset_
private

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