ServerConfig

class kanzi::connect::ServerConfig

Kanzi Connect Server configuration file handling.

Public Types

typedef vector<ConnectionAdapterSharedPtr> ConnectionAdapterContainer
typedef shared_ptr<ConnectionAdapter> ConnectionAdapterSharedPtr
typedef vector<HTTPProtocolSharedPtr> HTTPProtocolContainer
typedef shared_ptr<HTTPProtocol> HTTPProtocolSharedPtr
typedef vector<ServiceSharedPtr> ServiceContainer
typedef shared_ptr<Service> ServiceSharedPtr

Public Functions

ServerConfig()

C++ Constructor.

~ServerConfig()

Destructor.

string buildReferredFileName(const string &filename)

Builds a complete filename with path of a referred file.

Return

filename with path information added.

Parameters
  • filename: as defined on configuration

const unordered_map<string, string> &getCivetOptions() const

Retrieves the civet options specified inside the <httpserver> element.

Return

unordered_map where key: option name, value: option value

ConnectionAdapterSharedPtr getConnectionAdapter(const string &type)

Retrieves a connection adapter based on its type.

Return

pointer to connection adapter or empty pointer.

Parameters
  • type: type of the connection adapter. E.g. “connect.bearer.tcp”, “connect.bearer.ssl” or similar.

const ConnectionAdapterContainer &getConnectionAdapters() const

Retrieve list of connection adapters to configure.

Return

vector of items defining connection adapters.

CustomConfiguration *getCustomConfiguration(string path)

Get the custom configuration specified by path.

Return

Pointer to the configuration or nullptr if not found (does not release ownership of configuration to caller)

Parameters
  • path: Identifies which configuration to return (hierarchies separated by ‘.’)

vector<string> getDependentServicesRecursive(const string &name) const

Retrieve list of services that depend from this service.

The returned dependencies are not in any specific order

Return

list of service identifiers of services who depend from named service.

Parameters
  • name: service to inspect

Diagnostics &getDiagnostics()

Retrieve diagnostics information.

Return

diagnostics configuration.

FlowControl &getFlowControl()

Retrieve server-wide flow control information for remote service operation.

Return

flow control settings.

HTTPProtocolSharedPtr getHTTPProtocol(const string &type)

Retrieves a HTTP Protocol object based on requested type.

Return

pointer to HTTPProtocol object or empty pointer.

Parameters
  • type: of the protocol to retrieve. E.g. “http”, “https”

const HTTPProtocolContainer &getHTTPProtocols() const

Retrieve list of HTTP Protocol configurations.

Return

vector containing http configurations.

Identity &getIdentity()

Retrieve server-wide identity information.

Return

reference to identity information

Log &getLog()

Retrieve server-wide log information.

Return

reference to log information.

Persistence &getPersistence()

Retrieve server-wide persistence information.

Return

reference to persistence information

Policy &getPolicyConfig()

Retrieve server-wide policy information.

Return

reference to policy information.

PublishedConfigurations &getPublishedConfigurations()

Retrieve the published configurations information.

Return

Published configurations

Security &getSecurityConfig()

Retrieve server-wide security information.

Return

reference to server-wide security definitions.

ServiceSharedPtr getService(const string &name) const

Retrieve service by name or by library name.

Return

shared pointer to service

Parameters
  • name: the name for the service

ServiceSharedPtr getServiceByLibraryName(const string &libraryname) const

Retrieve service by library name.

Return

shared pointer to service

Parameters
  • libraryname: name of the library that identifies the service. Shall there be multiple service instances made from one library this returns the first.

vector<string> getServiceDependenciesRecursive(const string &name) const

Retrieve service dependencies in recursive manner.

The returned dependencies are not in any specific order.

Return

vector of service identifiers that are dependant of the passed in service.

Parameters
  • name: the name of the service whom dependencies are to be retrieved

const ServiceContainer &getServices() const

Retrieve list of service configurations.

Return

vector of items containing service defitions

const AttributeList &getServicesAttributes() const

Retrieve list of services attributes.

Return

list of attributes.

WebSocket &getWebSocketConfig()

Retrieve server-wide websocket information.

Return

reference to websocket information.

bool isValid()

IS configuration read from a valid file.

Return

true if configuration read from a file.

bool loadFromBuffer(const string &buffer)

Loads the structure from provided buffer.

Return

true if successfully loaded.

Parameters
  • buffer: xml buffer

bool loadFromFile(const string &filename)

Loads the structure from file provided.

Return

true if successfully loaded.

Parameters
  • filename: full path to file to load

bool loadFromFileset(FileSet &fileset)

Loades the structure from passed fileset.

Return

true if successfully initialized.

Parameters
  • fileset: fileset containing the configuration information

string readReferredFile(const string &filename)

Reads a file that is referred from the server configuration file.

This method will adjust the path to be relative to the server configuration files location.

Return

file contents.

Parameters
  • filename: the filename to be read.

class AttributeList

List of configuration specific attributes.

Public Functions

void add(const string &name, const string &value, const string type = "")

Inserts attribute to attribute list.

Parameters
  • name: the name of the attribute

  • value: value for the attribute

  • type: optional type information for the attribute.

void clear()

Clears the list.

bool contains(const string &name) const

Does this list contain a named attribute?

Return

true if contains, false otherwise.

Parameters
  • the: name

size_t count() const

Amount of attributes held.

Return

amount

bool getBool(const string &name, const bool defaultValue) const

Retrieve boolean type attribute.

Return

Attribute value

Parameters
  • name: the name of the attribute

  • defaultValue: the default value (optional) to return if not found.

int getInt(const string &name, int defaultValue = 0) const

Retrieve integer type attribute.

Return

integer attribute value

Parameters
  • name: the name of the attribute

  • defaultValue: the default value (optional) to return if not found.

double getReal(const string &name, const double defaultValue = 0.0) const

Retrieve floating point type attribute.

Return

Attribute value

Parameters
  • name: the name of the attribute

  • defaultValue: the default value (optional) to return if not found.

string getString(const string &name, string defaultValue = "") const

Retrieve string type attribute.

Return

string attribute value

Parameters
  • name: the name of the attribute

  • defaultValue: the default value (optional) to return if not found.

string getType(const string &name, const string defaultValue = "") const

Retrieve the optional type of the given attribute.

Return

optinal type for the attribute.

Parameters
  • name: the name of the attribute

vector<string> keys() const

All attribute names.

Return

list of attribute names.

void setBool(const string &name, const bool value)

Set the attribute value to be specific.

Parameters
  • name: of the attribute to set

  • value: value of the attribute

void setInt(const string &name, int value)

Sets the attribute value.

Parameters
  • name: the name of the attribute

  • value: new value for the attribute.

void setReal(const string &name, const double value)

Set the attribute value to be specific.

Parameters
  • name: of the attribute to set

  • value: value of the attribute

void setString(const string &name, string value)

Set the attribute value to be specific.

Parameters
  • name: of the attribute to set

  • value: value of the attribute

class AttributeProviderBase

Base class for other domain-classes that provide attributes.

Subclassed by ServerConfig::ConnectionAdapter, ServerConfig::CustomConfiguration, ServerConfig::Diagnostics, ServerConfig::FlowControl, ServerConfig::HTTPProtocol, ServerConfig::Identity, ServerConfig::Log, ServerConfig::Persistence, ServerConfig::Policy, ServerConfig::PublishedConfigurations::ConfigurationGroup, ServerConfig::Security, ServerConfig::Service, ServerConfig::WebSocket

Public Functions

~AttributeProviderBase() = default
AttributeList &getAttributes()

Retrieve attributes.

Return

attribute list.

const AttributeList &getAttributes() const

Retrieve attributes.

Return

attribute list.

class ConnectionAdapter : public ServerConfig::AttributeProviderBase

Connection adapter encapsulation.

Public Functions

ConnectionAdapter(const string &library, const string &type)

C++ constructor.

Parameters
  • type: the protocol type.

const string &getLibrary() const

Retrieve the library.

Return

library name

Security &getSecurity()

Retrieve adapter related security information.

Return

security information.

const string &getType() const

Retrieve the type.

Return

type

class CustomConfiguration : public ServerConfig::AttributeProviderBase

Class to contain information about all custom configurations in server config.

Public Functions

CustomConfiguration(const tinyxml2::XMLElement *element)

Constructor.

Parameters
  • element: Contains the XML definition for this configuration

~CustomConfiguration() override = default

dtor

CustomConfiguration *getConfiguration(string &path)

Get the configuration specified by path.

Return

Pointer to the configuration or nullptr if not found (does not release ownership of configuration to caller)

Parameters
  • path: Identifies which configuration to return (hierarchies separated by ‘.’)

class Diagnostics : public ServerConfig::AttributeProviderBase

Diagnostics configuration.

Public Functions

Diagnostics()

ctor

~Diagnostics() override = default

dtor

Public Static Attributes

const string AMOUNT_LOG_LINES_TO_KEEP

Amount of log lines to keep.

constexpr int DEFAULT_LATENCY_MEAS_INTERVAL_ms = 1000 * 2

Latency measurement interval default value.

constexpr int DEFAULT_LOG_LINES_TO_KEEP = 50

Amount of log lines to keep.

constexpr int DEFAULT_REMOTE_DIAGNOSTICS_COLLECTION_FACTOR = 2

How often to connection remote diagnostics information.

const string ENABLE_DETAILED_LOG_KEY

Detailed logging enabled.

const string ENABLE_DIAGNOSTICS_KEY

Whether or not enable diagnostics overall.

const string ENABLE_REMOTE_DIAGNOSTICS_COLLECTION

Whether or not to enable remote diagnostics collection.

const string LATENCY_MEAS_INTERVAL_KEY

How often to measure latency.

const string REMOTE_DIAGNOSTICS_COLLECTION_FACTOR_KEY

How often to collect remote diagnostics information.

class FlowControl : public ServerConfig::AttributeProviderBase

Flow control configuration encapsulation.

Public Functions

FlowControl()

ctor

~FlowControl() override = default

dtor

Public Static Attributes

const string CREDIT_RETURN_INTERVAL_KEY

Attribute name for creditreturninterval attribute.

const string CREDITS_KEY

Attribute name for credits attribute.

constexpr int DEFAULT_CREDIT_RETURN_INTERVAL = 5
constexpr int DEFAULT_CREDITS = 15

Default value for write interval.

class HTTPProtocol : public ServerConfig::AttributeProviderBase

HTTP Setting encapsulation.

Public Functions

HTTPProtocol(const string &type)

C++ constructor.

Parameters
  • type: the type protocol (http/https)

Security &getSecurity()

Retrieve server-wide security information.

Return

reference to server-wide security definitions.

const string &getType() const

Retrieve the type.

Return

type string, http|https

class Identity : public ServerConfig::AttributeProviderBase

Server identity related attributes.

Public Functions

Identity()

ctor

~Identity() override = default

dtor

Public Static Attributes

const string DEFAULT_SERVER_NAME

Default name for the server.

const string SERVER_NAME_KEY

Attribute name for the server name attribute.

class Log : public ServerConfig::AttributeProviderBase

Log configuration.

Public Functions

Log()

C++ constructor - initialize object.

class Persistence : public ServerConfig::AttributeProviderBase

Class comment.

Public Functions

Persistence()

ctor

~Persistence() override = default

dtor

Public Static Attributes

constexpr int DEFAULT_WRITE_INTERVAL_S = 15

Default value for write interval.

const string WRITE_INTERVAL_KEY

Attribute name for write interval.

class Policy : public ServerConfig::AttributeProviderBase

Policy configuration.

Public Functions

Policy()

C++ constructor - initialize object.

class PublishedConfigurations

Configurations published through the Configuration service.

See

kanzi::connect::ConfigurationService

Public Functions

PublishedConfigurations() = default

ctor

~PublishedConfigurations() = default

dtor

vector<ConfigurationGroup> &getGroups()

Get the configuration groups.

Return

Vector containing the groups

Public Static Attributes

constexpr const char *const ELEMENT_NAME = "published_configurations"
class ConfigurationGroup : public ServerConfig::AttributeProviderBase

Group of configurations for specific service/domain.

Public Functions

ConfigurationGroup(const string &name)

Constructor.

Parameters
  • name: Name of the configuration group

ConfigurationGroup(const ConfigurationGroup &other) = default

Copy constructor.

ConfigurationGroup(ConfigurationGroup &&other) = default

Move constructor.

~ConfigurationGroup() = default

dtor

const string &getName() const

Get the configuration group name.

Return

The name

ConfigurationGroup &operator=(const ConfigurationGroup &other) = default

Copy assignment.

ConfigurationGroup &operator=(ConfigurationGroup &&other) = default

Move assignment.

class Security : public ServerConfig::AttributeProviderBase

Security configuration.

Public Functions

Security()

C++ constructor - initialize object.

bool isEmpty()

Is there any security definitions.

Return

true if security definitions exists.

class Service : public ServerConfig::AttributeProviderBase

Service configuration.

Public Functions

Service(const string &library, const string &name, const string mandatory = "")

C++ constructor.

initialize object

Parameters
  • library: the library for the service.

  • name: the name for the service

  • mandatory: if contains true|1 then this service is marked as mandatory.

bool depends(const string &service)

Does this service depend on some other service.

Return

true if depends.

Parameters
  • service: the service

vector<string> getDependencies()

Retrieve service dependencies as list of strings.

Return

vector of dependency definitions.

const string &getLibrary() const

Retrieve the library.

Return

library name

bool getMandatory() const

Retrieve the mandatory status, i.e.

whether everyting should fail if accessing this service fails

Return

true if this service is marked as mandatory.

const string &getName() const

Retrieve the configured name.

Return

name

Security &getSecurity()

Retrieve security information related to a service.

class WebSocket : public ServerConfig::AttributeProviderBase

WebSocket configuration.

Public Functions

WebSocket()

C++ constructor - initialize object.