Class IAFDClient

Class Documentation

class Microsoft::Applications::Experimentation::AFD::IAFDClient

The IAFDClient class represents the interface to the IAFD client.

Public Functions

virtual void Initialize(const AFDClientConfiguration &config) = 0

Initializes an AFD client with the specified configuration.

Parameters

config – The AFD client configuration.

virtual bool AddListener(IAFDClientCallback *listener) = 0

Adds a listener.

Parameters

listener – A pointer to the listener.

virtual bool RemoveListener(IAFDClientCallback *listener) = 0

Removes a listener.

Parameters

listener – A pointer to an IAFDClientCallback listener.

Returns

A boolean value that indicates success (true) or failure (false).

virtual bool RegisterLogger(::Microsoft::Applications::Events::ILogger *pLoger, const std::string &agentName) = 0

Registers a logger to auto-tag events sent by the logger with AFD configuration information (like Etag).

Parameters
  • pLoger – The logger to register with the AFD client.

  • agentName – A string that contains the name of the agent whose experiment configIds will be auto-tagged to events sent by the logger.

Returns

A boolean value that indicates success (true) or failure (false).

virtual bool SetRequestParameters(const std::map<std::string, std::string> &requestParams) = 0

Sets a list of custom parameters for the request to use to retrieve configurations from the AFD server.

Parameters

requestParams – A list of parameters for the request.

Returns

A boolean value that indicates success (true) or failure (false).

virtual bool SetRequestHeaders(const std::map<std::string, std::string> &headerParams) = 0

Sets a list of request headers for the request to use to retrieve configurations from the AFD server.

Parameters

headerParams – A standard map that contains headers for the request.

Returns

A boolean value that indicates success (true) or failure (false).

virtual bool Start() = 0

Starts the AFDClient to retrieve configurations from the AFD server.

Returns

A boolean value that indicates success (true) or failure (false).

virtual bool Stop() = 0

Prevents the AFDClient from retrieving configurations from the AFD server.

Returns

A boolean value that indicates success (true) or failure (false).

virtual bool Suspend() = 0

Suspends the AFDClient to prevent it from retrieving configuration updates from the AFD server.

Returns

A boolean value that indicates success (true) or failure (false).

virtual bool Resume(bool fetchConfig = true) = 0

Resumes the AFDClient so it continues to retrieve configuration updates from the AFD server.

Returns

A boolean value that indicates success (true) or failure (false).

virtual std::vector<std::string> GetFlights() = 0

Gets the flights of the currently active AFD configuration.

Returns

A vector that contains strings that contain the names of the flights.

virtual std::vector<std::string> GetFeatures() = 0

Gets the features of the currently active AFD configuration.

Returns

A standard vector that contains strings that contain the names of the features.

virtual std::map<std::string, std::string> GetConfigs() = 0

get the configs of the current active AFD configuration

Returns

vector of feature string

virtual std::string GetETag() = 0

Gets the ETag of the currently active AFD configuration.

Returns

A string that contains the ETag.

virtual std::vector<std::string> GetKeys(const std::string &agentName, const std::string &keysPath) = 0

Gets the keys under the specified configuration path of the specified agent.

Parameters
  • agentName – A string that contains the name of the agent.

  • keysPath – A string that contains the configuration path.

Returns

list of configuration keys

virtual std::string GetSetting(const std::string &agentName, const std::string &settingPath, const std::string &defaultValue) = 0

Gets the IAFDClient setting, using the specified agent name, setting path, and default string value.

Parameters
  • agentName – A string that contains the name of the agent.

  • settingPath – A string that contains the configuration path.

  • defaultValue – A string that contains the default value to return if no configuration setting is found.

Returns

A string that contains the setting. This method returns the specified default if no configuration setting is found.

virtual bool GetSetting(const std::string &agentName, const std::string &settingPath, const bool defaultValue) = 0

Gets the IAFDClient setting, using the specified agent name, setting path, and default boolean value.

Parameters
  • agentName – A string that contains the name of the agent.

  • settingPath – A string that contains the configuration path.

  • defaultValue – A boolean that contains the default value to return if no configuration setting is found.

Returns

A boolean that contains the setting. This method returns the specified default if no configuration setting is found.

virtual int GetSetting(const std::string &agentName, const std::string &settingPath, const int defaultValue) = 0

Gets the IAFDClient setting, using the specified agent name, setting path, and default integer value.

Parameters
  • agentName – A string that contains the name of the agent.

  • settingPath – A string that contains the configuration path.

  • defaultValue – An integer that contains the default value to return if no configuration setting is found.

Returns

An integer that contains the setting. This method returns the specified default if no configuration setting is found.

virtual double GetSetting(const std::string &agentName, const std::string &settingPath, const double defaultValue) = 0

Gets the IAFDClient setting, using the specified agent name, setting path, and default double value.

Parameters
  • agentName – A string that contains the name of the agent.

  • settingPath – A string that contains the configuration path.

  • defaultValue – A double that contains the default value to return if no configuration setting is found.

Returns

A double that contains the setting. This method returns the specified default if no configuration setting is found.

virtual std::vector<std::string> GetSettings(const std::string &agentName, const std::string &settingPath) = 0

Gets the IAFDClient setting, using the specified agent name and setting path.

Parameters
  • agentName – A string that contains the name of the agent.

  • settingPath – A string that contains the configuration path.

Returns

A standard vector that contains strings that contain the list of settings.

virtual std::vector<int> GetSettingsAsInts(const std::string &agentName, const std::string &settingPath) = 0

Gets the IAFDClient settings and integers, using the specified agent name and setting path.

Parameters
  • agentName – A string that contains the name of the agent.

  • settingPath – A string that contains the configuration path.

Returns

A standard vector that contains integers that contain the list of settings.

virtual std::vector<double> GetSettingsAsDbls(const std::string &agentName, const std::string &settingPath) = 0

Gets the IAFDClient settings and doubles, using the specified agent name and setting path.

Parameters
  • agentName – A string that contains the name of the agent.

  • settingPath – A string that contains the configuration path.

Returns

A standard vector that contains doubles that contain the list of settings.

virtual std::string GetAFDConfiguration() = 0

Gets the IAFDClient configuration json as string.

Returns

A string that contains the ETag.

virtual void SetRetryTimeFactor(int time) = 0

Sets the Time used for retring.

Public Static Functions

static IAFDClient *CreateInstance()

Creates a new instance of an AFDClient.

static void DestroyInstance(IAFDClient **ppAFDClient)

Destroys the specified AFDClient instance.