config client

group config_client
class ConfigCache
#include <config_cache.h>

ConfigCache is used to cache the config files downloaded from the meta server.

It is used by the DiscoveryClient to cache the config files downloaded from the meta server.

Public Functions

turbo::Status init()

init is used to initialize the ConfigCache.

It must be called before using the ConfigCache.

Returns:

Status::OK if the ConfigCache was initialized successfully. Otherwise, an error status is returned.

turbo::Status add_config(const EA::discovery::ConfigInfo &config)

add_config is used to add a config to the ConfigCache.

Parameters:

config – [input] is the config to add to the ConfigCache.

Returns:

Status::OK if the config was added successfully. Otherwise, an error status is returned.

turbo::Status get_config(const std::string &name, const turbo::ModuleVersion &version, EA::discovery::ConfigInfo &config)

get_config is used to get a config that matches the name and version from the ConfigCache.

Parameters:
  • name – [input] is the name of the config to get.

  • version – [input] is the version of the config to get.

  • config – [output] is the config received from the ConfigCache.

Returns:

Status::OK if the config was received successfully. Otherwise, an error status is returned.

turbo::Status get_config(const std::string &name, EA::discovery::ConfigInfo &config)

get_config is used to get the latest version of a config from the ConfigCache.

Parameters:
  • name – [input] is the name of the config to get the latest version for.

  • config – is the config received from the ConfigCache.

Returns:

Status::OK if the config was received successfully. Otherwise, an error status is returned.

turbo::Status get_config_list(std::vector<std::string> &name)

get_config_list is used to get a list of config names from the ConfigCache.

Parameters:

name – [output] is the list of config names received from the ConfigCache.

Returns:

Status::OK if the config names were received successfully. Otherwise, an error status is returned.

turbo::Status get_config_version_list(const std::string &config_name, std::vector<turbo::ModuleVersion> &versions)

get_config_version_list is used to get a list of config versions from the ConfigCache.

Parameters:
  • config_name – [input] is the name of the config to get the versions for.

  • versions – [output] is the list of config versions received from the ConfigCache.

Returns:

Status::OK if the config versions were received successfully. Otherwise, an error status is returned.

turbo::Status remove_config(const std::string &config_name, const turbo::ModuleVersion &version)

remove_config is used to remove a config from the ConfigCache.

Parameters:
  • config_name – [input] is the name of the config to remove.

  • version – [input] is the version of the config to remove.

Returns:

Status::OK if the config names were received successfully. Otherwise, an error status is returned.

turbo::Status remove_config(const std::string &config_name, const std::vector<turbo::ModuleVersion> &version)

remove_config is used to remove a config from the ConfigCache.

Parameters:
  • config_name – [input] is the name of the config to remove.

  • version – [input] is the version of the config to remove.

Returns:

Status::OK if the config was removed successfully. Otherwise, an error status is returned.

turbo::Status remove_config_less_than(const std::string &config_name, const turbo::ModuleVersion &version)

remove_config_less_than is used to remove a config from the ConfigCache.

All versions less than the specified version will be removed.

Parameters:
  • config_name – [input] is the name of the config to remove all versions less than.

  • version – [input] is the version of the config to remove all versions less than.

Returns:

Status::OK if the config was removed successfully. Otherwise, an error status is returned.

turbo::Status remove_config(const std::string &config_name)

remove_config is used to remove a config from the ConfigCache with all versions.

Parameters:

config_name – [input] is the name of the config to remove.

Returns:

Status::OK if the config was removed successfully. Otherwise, an error status is returned.

struct ConfigCallbackData
#include <config_client.h>

ConfigCallbackData is used to pass data to the ConfigCallback.