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.

Parameters

filename – as defined on configuration

Returns

filename with path information added.

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

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

Returns

unordered_map where key: option name, value: option value

ConnectionAdapterSharedPtr getConnectionAdapter(const string &type)

Retrieves a connection adapter based on its type.

Parameters

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

Returns

pointer to connection adapter or empty pointer.

const ConnectionAdapterContainer &getConnectionAdapters() const

Retrieve list of connection adapters to configure.

Returns

vector of items defining connection adapters.

CustomConfiguration *getCustomConfiguration(string path)

Get the custom configuration specified by path.

Parameters

path – Identifies which configuration to return (hierarchies separated by ‘.’)

Returns

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

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

Parameters

name – service to inspect

Returns

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

Diagnostics &getDiagnostics()

Retrieve diagnostics information.

Returns

diagnostics configuration.

FlowControl &getFlowControl()

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

Returns

flow control settings.

HTTPProtocolSharedPtr getHTTPProtocol(const string &type)

Retrieves a HTTP Protocol object based on requested type.

Parameters

type – of the protocol to retrieve. E.g. “http”, “https”

Returns

pointer to HTTPProtocol object or empty pointer.

const HTTPProtocolContainer &getHTTPProtocols() const

Retrieve list of HTTP Protocol configurations.

Returns

vector containing http configurations.

Identity &getIdentity()

Retrieve server-wide identity information.

Returns

reference to identity information

Log &getLog()

Retrieve server-wide log information.

Returns

reference to log information.

Persistence &getPersistence()

Retrieve server-wide persistence information.

Returns

reference to persistence information

Policy &getPolicyConfig()

Retrieve server-wide policy information.

Returns

reference to policy information.

PublishedConfigurations &getPublishedConfigurations()

Retrieve the published configurations information.

Returns

Published configurations

Security &getSecurityConfig()

Retrieve server-wide security information.

Returns

reference to server-wide security definitions.

ServiceSharedPtr getService(const string &name) const

Retrieve service by name or by library name.

Parameters

name – the name for the service

Returns

shared pointer to service

ServiceSharedPtr getServiceByLibraryName(const string &libraryname) const

Retrieve service by library name.

Parameters

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

Returns

shared pointer to service

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

Retrieve service dependencies in recursive manner.

The returned dependencies are not in any specific order.

Parameters

name – the name of the service whom dependencies are to be retrieved

Returns

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

const ServiceContainer &getServices() const

Retrieve list of service configurations.

Returns

vector of items containing service defitions

const AttributeList &getServicesAttributes() const

Retrieve list of services attributes.

Returns

list of attributes.

bool isValid()

IS configuration read from a valid file.

Returns

true if configuration read from a file.

bool loadFromBuffer(const string &buffer)

Loads the structure from provided buffer.

Parameters

buffer – xml buffer

Returns

true if successfully loaded.

bool loadFromFile(const string &filename)

Loads the structure from file provided.

Parameters

filename – full path to file to load

Returns

true if successfully loaded.

bool loadFromFileset(FileSet &fileset)

Loades the structure from passed fileset.

Parameters

fileset – fileset containing the configuration information

Returns

true if successfully initialized.

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.

Parameters

filename – the filename to be read.

Returns

file contents.

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?

Parameters

the – name

Returns

true if contains, false otherwise.

size_t count() const

Amount of attributes held.

Returns

amount

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

Retrieve boolean type attribute.

Parameters
  • name – the name of the attribute

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

Returns

Attribute value

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

Retrieve integer type attribute.

Parameters
  • name – the name of the attribute

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

Returns

integer attribute value

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

Retrieve floating point type attribute.

Parameters
  • name – the name of the attribute

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

Returns

Attribute value

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

Retrieve string type attribute.

Parameters
  • name – the name of the attribute

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

Returns

string attribute value

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

Retrieve the optional type of the given attribute.

Parameters

name – the name of the attribute

Returns

optinal type for the attribute.

vector<string> keys() const

All attribute names.

Returns

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

Public Functions

virtual ~AttributeProviderBase() = default
AttributeList &getAttributes()

Retrieve attributes.

Returns

attribute list.

const AttributeList &getAttributes() const

Retrieve attributes.

Returns

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.

Returns

library name

Security &getSecurity()

Retrieve adapter related security information.

Returns

security information.

const string &getType() const

Retrieve the type.

Returns

type

class CustomConfiguration : public ServerConfig::AttributeProviderBase

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

Public Functions

explicit CustomConfiguration(const tinyxml2::XMLElement *element)

Constructor.

Parameters

element – Contains the XML definition for this configuration

virtual  ~CustomConfiguration () KZ_OVERRIDE=default

dtor

CustomConfiguration *getConfiguration(string &path)

Get the configuration specified by path.

Parameters

path – Identifies which configuration to return (hierarchies separated by ‘.’)

Returns

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

class Diagnostics : public ServerConfig::AttributeProviderBase

Diagnostics configuration.

Public Functions

explicit Diagnostics()

ctor

virtual  ~Diagnostics () KZ_OVERRIDE=default

dtor

Public Static Attributes

static const string AMOUNT_LOG_LINES_TO_KEEP

Amount of log lines to keep.

static constexpr int DEFAULT_LATENCY_MEAS_INTERVAL_ms = 1000 * 2

Latency measurement interval default value.

static constexpr int DEFAULT_LOG_LINES_TO_KEEP = 50

Amount of log lines to keep.

static constexpr int DEFAULT_REMOTE_DIAGNOSTICS_COLLECTION_FACTOR = 2

How often to connection remote diagnostics information.

static const string ENABLE_DETAILED_LOG_KEY

Detailed logging enabled.

static const string ENABLE_DIAGNOSTICS_KEY

Whether or not enable diagnostics overall.

static const string ENABLE_REMOTE_DIAGNOSTICS_COLLECTION

Whether or not to enable remote diagnostics collection.

static const string LATENCY_MEAS_INTERVAL_KEY

How often to measure latency.

static 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

explicit FlowControl()

ctor

virtual  ~FlowControl () KZ_OVERRIDE=default

dtor

Public Static Attributes

static const string CREDIT_RETURN_INTERVAL_KEY

Attribute name for creditreturninterval attribute.

static const string CREDITS_KEY

Attribute name for credits attribute.

static constexpr int DEFAULT_CREDIT_RETURN_INTERVAL = 5
static constexpr int DEFAULT_CREDITS = 15

Default value for write interval.

class HTTPProtocol : public ServerConfig::AttributeProviderBase

HTTP Setting encapsulation.

Public Functions

explicit HTTPProtocol(const string &type)

C++ constructor.

Parameters

type – the type protocol (http/https)

Security &getSecurity()

Retrieve server-wide security information.

Returns

reference to server-wide security definitions.

const string &getType() const

Retrieve the type.

Returns

type string, http|https

class Identity : public ServerConfig::AttributeProviderBase

Server identity related attributes.

Public Functions

explicit Identity()

ctor

virtual  ~Identity () KZ_OVERRIDE=default

dtor

Public Static Attributes

static const string DEFAULT_SERVER_NAME

Default name for the server.

static 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

explicit Persistence()

ctor

virtual  ~Persistence () KZ_OVERRIDE=default

dtor

Public Static Attributes

static constexpr int DEFAULT_WRITE_INTERVAL_S = 15

Default value for write interval.

static 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

explicit PublishedConfigurations() = default

ctor

~PublishedConfigurations() = default

dtor

vector<ConfigurationGroup> &getGroups()

Get the configuration groups.

Returns

Vector containing the groups

Public Static Attributes

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

Group of configurations for specific service/domain.

Public Functions

ConfigurationGroup(ConfigurationGroup &&other) = default

Move constructor.

ConfigurationGroup(const ConfigurationGroup &other) = default

Copy constructor.

explicit ConfigurationGroup(const string &name)

Constructor.

Parameters

name – Name of the configuration group

virtual ~ConfigurationGroup() = default

dtor

const string &getName() const

Get the configuration group name.

Returns

The name

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

Move assignment.

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

Copy assignment.

class Security : public ServerConfig::AttributeProviderBase

Security configuration.

Public Functions

Security()

C++ constructor - initialize object.

bool isEmpty()

Is there any security definitions.

Returns

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.

Parameters

service – the service

Returns

true if depends.

vector<string> getDependencies()

Retrieve service dependencies as list of strings.

Returns

vector of dependency definitions.

const string &getLibrary() const

Retrieve the library.

Returns

library name

bool getMandatory() const

Retrieve the mandatory status, i.e.

whether everyting should fail if accessing this service fails

Returns

true if this service is marked as mandatory.

const string &getName() const

Retrieve the configured name.

Returns

name

Security &getSecurity()

Retrieve security information related to a service.