linkahead/configuration.h

namespace linkahead
namespace configuration

Variables

const std::string logger_name = "linkahead::configuration"
class ConfigurationManager
#include <configuration.h>

Reads the configuration file and keeps the configuration. Singleton.

Currently, this class can only read a single configuration file. No merging or overwriting is supported.

Public Functions

ConfigurationManager(ConfigurationManager const&) = delete
void operator=(ConfigurationManager const&) = delete

Public Static Functions

static ConfigurationManager &GetInstance()
static inline auto Reset() noexcept -> int

See mReset.

static inline auto Clear() noexcept -> int

See mClear.

static inline auto LoadSingleJSONConfiguration(const path &json_file) -> void

See mLoadSingleJSONConfiguration.

static inline auto GetConnectionConfiguration(const std::string &name) -> std::unique_ptr<ConnectionConfiguration>

See mGetConnectionConfiguration.

static inline auto GetDefaultConnectionConfiguration() -> std::unique_ptr<ConnectionConfiguration>

Return the ConnectionConfiguration for the default connection.

static inline auto GetDefaultConnectionName() -> std::string

See mGetDefaultConnectionName.

static inline auto GetArena() -> Arena*

Private Functions

inline ConfigurationManager() noexcept
auto InitializeDefaults() -> int

Initialize this ConfigurationManager with the defaults.

Currently, this means, that the ConfigurationManager attempts to load the first existing file from the LIBLINKAHEAD_CONFIGURATION_FILES_PRECEDENCE list of file locations.

auto mReset() noexcept -> int

Reset this ConfigurationManager.

The current configuration is deleted and a new configuration is being loaded via InitializeDefaults.

auto mClear() noexcept -> int

Clear this ConfigurationManager.

Afterwards, this ConfigurationManager is uninitilized.

In contrast to mReset, this method only deletes the current configuration but does not load a new one via InitializeDefaults.

auto mLoadSingleJSONConfiguration(const path &json_file) -> void

Load a configuration from a json file.

auto mGetConnectionConfiguration(const std::string &name) const -> std::unique_ptr<ConnectionConfiguration>

Return the ConnectionConfiguration for the connection of the given name.

auto mGetDefaultConnectionName() const -> std::string

Return the ConnectionConfiguration for the default connection.

Private Members

Arena arena
JsonValue json_configuration

Private Static Attributes

static ConfigurationManager mInstance
class ConnectionConfiguration
#include <configuration.h>

Configuration of the LinkAhead connection.

Subclassed by linkahead::configuration::InsecureConnectionConfiguration, linkahead::configuration::TlsConnectionConfiguration

Public Functions

ConnectionConfiguration(std::string host, int port)
virtual ~ConnectionConfiguration() = default
virtual auto ToString() const -> std::string = 0
auto GetHost() const -> std::string
auto GetPort() const -> int
virtual auto GetChannelCredentials() const -> std::shared_ptr<ChannelCredentials> = 0

Private Members

std::string host
int port

Friends

friend auto operator<<(std::ostream &out, const ConnectionConfiguration &configuration) -> std::ostream&
class InsecureConnectionConfiguration : public linkahead::configuration::ConnectionConfiguration

Public Functions

InsecureConnectionConfiguration(const std::string &host, int port)
virtual auto GetChannelCredentials() const -> std::shared_ptr<ChannelCredentials> override
virtual auto ToString() const -> std::string override

Private Members

std::shared_ptr<ChannelCredentials> credentials
class TlsConnectionConfiguration : public linkahead::configuration::ConnectionConfiguration

Public Functions

TlsConnectionConfiguration(const std::string &host, int port)
TlsConnectionConfiguration(const std::string &host, int port, const Authenticator &authenticator)
TlsConnectionConfiguration(const std::string &host, int port, const CertificateProvider &certificate_provider)
TlsConnectionConfiguration(const std::string &host, int port, const CertificateProvider &certificate_provider, const Authenticator &authenticator)
virtual auto GetChannelCredentials() const -> std::shared_ptr<ChannelCredentials> override
virtual auto ToString() const -> std::string override

Private Members

std::shared_ptr<ChannelCredentials> credentials
std::string certificate_provider