Class IECSClient

Class Documentation

class Microsoft::Applications::Experimentation::ECS::IECSClient

The IECSClient class is the interface to an ECS client.

Public Functions

virtual void Initialize(const ECSClientConfiguration &config) = 0

Initializes the IECSClient with the specified configuration.

Parameters

config – The configuration as an instance of the ECSClientConfiguration structure.

virtual bool AddListener(IECSClientCallback *listener) = 0

Adds a listener to the ECS client - to be notified of configuration changes.

Parameters

listener – The listener to add to the ECS client.

Returns

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

virtual bool RemoveListener(IECSClientCallback *listener) = 0

Removes the listener to stop receiving notifications from the ECS client.

Parameters

listener – The listener to remove from the ECSClient.

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, taking a pointer to an ILogger interface, and a string that contains the agent name.

Parameters
  • pLoger – The logger to be registered with the ECS client

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

Returns

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

virtual bool SetUserId(const std::string &userId) = 0

Sets a user ID used as the request parameter for retrieving configurations from the ECS server.

The client can optionally pass this in the request so that the configuration can be allocated on a per-user basic. The allocation persists for the user ID, therefore it is good for the allocation to follow the user account.

Parameters

userId – A string that contains the login user ID to pass in the request.

Returns

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

virtual bool SetDeviceId(const std::string &deviceId) = 0

Sets a device ID used as the request parameter for retrieving configurations from the ECS server.

Parameters

deviceId – A string that contains the device ID.

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 ECS server

<param name=”requestParams”A map that contains the request parameters.

Returns

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

virtual bool Start() = 0

Starts the ECSClient - to retrieve configurations from the ECS server.

Returns

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

virtual bool Stop() = 0

Stops the ECSClient from retrieving configurations from the ECS server.

Returns

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

virtual bool Suspend() = 0

Suspends the ECSClient from retrieving configuration updates from the ECS server.

Returns

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

virtual bool Resume(bool fetchConfig = false) = 0

Resumes the ECSClient to retrieve configuration updates from the ECS server.

Returns

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

virtual std::string GetETag() = 0

Gets the ETag of the currently active ECS configuration.

Returns

A string that contains the ETag.

virtual std::string GetConfigs() = 0

Gets the ETag of the currently active ECS 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, for 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 bool TryGetSetting(const std::string &agentName, const std::string &settingPath, std::string &value) = 0

Tries to get the setting for the specified agent, from the specified configuration path

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

  • settingPath – A string that contains the configuration path.

  • value – Receives the setting if it is found. Is unchanged if not found.

Returns

True if the setting was successfully found.

virtual bool TryGetBoolSetting(const std::string &agentName, const std::string &settingPath, bool &value) = 0

Tries to get the setting for the specified agent, from the specified configuration path

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

  • settingPath – A string that contains the configuration path.

  • value – Receives the setting if it is found. Is unchanged if not found.

Returns

True if the setting was successfully found.

virtual bool TryGetIntSetting(const std::string &agentName, const std::string &settingPath, int &value) = 0

Tries to get the setting for the specified agent, from the specified configuration path

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

  • settingPath – A string that contains the configuration path.

  • value – Receives the setting if it is found. Is unchanged if not found.

Returns

True if the setting was successfully found.

virtual bool TryGetLongSetting(const std::string &agentName, const std::string &settingPath, long &value) = 0

Tries to get the setting for the specified agent, from the specified configuration path

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

  • settingPath – A string that contains the configuration path.

  • value – Receives the setting if it is found. Is unchanged if not found.

Returns

True if the setting was successfully found.

virtual bool TryGetDoubleSetting(const std::string &agentName, const std::string &settingPath, double &value) = 0

Tries to get the setting for the specified agent, from the specified configuration path

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

  • settingPath – A string that contains the configuration path.

  • value – Receives the setting if it is found. Is unchanged if not found.

Returns

True if the setting was successfully found.

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

Gets the setting for the specified agent, from the specified configuration path, taking a 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 can be found.

Returns

A string that contains the setting. The default value is returned if no configuration setting can be found.

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

Gets the setting for the specified agent, from the specified configuration path, taking a 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 can be found.

Returns

A boolean value that contains the setting. The default value is returned if no configuration setting can be found.

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

Gets the setting for the specified agent, from the specified configuration path, taking a 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 can be found.

Returns

An integer that contains the setting. The default value is returned if no configuration setting can be found.

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

Gets the setting for the specified agent, from the specified configuration path, taking a 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 can be found.

Returns

A double that contains the setting. The default value is returned if no configuration setting can be found.

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

Gets a collection of settings for the specified agent, from the specified configuration 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 the settings as strings.

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

Gets a collection of settings for the specified agent, from the specified configuration path.

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

  • settingPath – A string that contains the configuration path.

Returns

A vector that contains the settings as integers.

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

Gets a collection of settings for the specified agent, from the specified configuration path.

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

  • settingPath – A string that contains the configuration path.

Returns

A vector that contains the settings as doubles.

virtual void SetRetryTimeFactor(int time) = 0

Sets the Time used for retring.

Public Static Functions

static IECSClient *CreateInstance()

Creates a new instance of an IECSClient.

static void DestroyInstance(IECSClient **ppECSClient)

Destroys the specified IECSClient instance.