tnt::Configurator Class Reference

Helper class for easier configuration of tntnet when used as library. More...

#include <tnt/configurator.h>

Public Member Functions

 Configurator (tnt::Tntnet &tntnet)
unsigned getMinThreads () const
 Returns the minimum number of worker threads.
void setMinThreads (unsigned n)
 Sets the minimum number of worker threads.
unsigned getMaxThreads () const
 Returns the maximum number of worker threads.
void setMaxThreads (unsigned n)
 Sets the maximum number of worker threads.
cxxtools::Seconds getTimerSleep () const
 Returns the time in seconds after which cleanup like checking sessiontimeout is done.
void setTimerSleep (cxxtools::Seconds sec)
 Sets the time in seconds after which cleanup like checking sessiontimeout is done.
cxxtools::Milliseconds getThreadStartDelay () const
 Returns the time in seconds between thread starts.
void setThreadStartDelay (cxxtools::Milliseconds sec)
 Sets the time in seconds between thread starts.
unsigned getQueueSize () const
 Returns the maximum number of jobs waiting for processing.
void setQueueSize (unsigned n)
 Sets the maximum number of jobs waiting for processing.
cxxtools::Seconds getMaxRequestTime () const
 Returns the maximum request time, after which tntnet is automatically restarted in daemon mode.
void setMaxRequestTime (cxxtools::Seconds sec)
 Sets the maximum request time, after which tntnet is automatically restarted in daemon mode.
bool getEnableCompression () const
 Returns true, when http compression is used.
void setEnableCompression (bool sw=true)
 enables or disables http compression.
cxxtools::Seconds getSessionTimeout () const
 Returns the time of inactivity in seconds after which a session is destroyed.
void setSessionTimeout (cxxtools::Seconds sec)
 Sets the time of inactivity in seconds after which a session is destroyed.
int getListenBacklog () const
 Returns the listen backlog parameter (see also listen(2)).
void setListenBacklog (int n)
 Sets the listen backlog parameter (see also listen(2)).
unsigned getListenRetry () const
 Returns the number of retries, when a listen retried, when failing.
void setListenRetry (int n)
 Sets the number of retries, when a listen retried, when failing.
unsigned getMaxUrlMapCache () const
 Returns the maximum number of cached urlmappings.
void setMaxUrlMapCache (int n)
 Sets the maximum number of cached urlmappings.
size_t getMaxRequestSize () const
 Returns the maximum size of a request.
void setMaxRequestSize (size_t s)
 Sets the maximum size of a request.
cxxtools::Milliseconds getSocketReadTimeout () const
 Returns the read timeout in millisecods after which the request is passed to the poller.
void setSocketReadTimeout (cxxtools::Milliseconds ms)
 Sets the timeout in millisecods after which the request is passed to the poller.
cxxtools::Milliseconds getSocketWriteTimeout () const
 Returns the write timeout in millisecods after which the request is timed out.
void setSocketWriteTimeout (cxxtools::Milliseconds ms)
 Sets the write timeout in millisecods after which the request is timed out.
unsigned getKeepAliveMax () const
 Returns the maximum number of requests handled over a single connection.
void setKeepAliveMax (unsigned ms)
 Sets the maximum number of requests handled over a single connection.
unsigned getSocketBufferSize () const
 Returns the size of the socket buffer.
void setSocketBufferSize (unsigned ms)
 Sets the size of the socket buffer.
unsigned getMinCompressSize () const
 Returns the minimum size of a request body for compression.
void setMinCompressSize (unsigned s)
 Sets the minimum size of a request body for compression.
cxxtools::Seconds getKeepAliveTimeout () const
 Returns the keep alive timeout in milliseconds.
void setKeepAliveTimeout (cxxtools::Seconds s)
 Sets the keep alive timeout in milliseconds.
const std::string & getDefaultContentType () const
 Returns the default content type.
void setDefaultContentType (const std::string &s)
 Sets the default content type.
void setAccessLog (const std::string &accessLog)

Detailed Description

Helper class for easier configuration of tntnet when used as library.

Configuration of tntnet is spread througout the system and it is a tendious task to search the right place, where to set some setting. This Class helps here and offers methods for all settings in one place. The methods dispatch the setting to the right place, so the user needs to know only this class, when he wants to set some settings.

This is yet deprecated since all configuration is done in tnt::TntConfig.

Constructor & Destructor Documentation

tnt::Configurator::Configurator ( tnt::Tntnet tntnet)
inlineexplicit

Member Function Documentation

const std::string& tnt::Configurator::getDefaultContentType ( ) const
inline

Returns the default content type.

The default content type is "text/html; charset=iso-8859-1".

bool tnt::Configurator::getEnableCompression ( ) const
inline

Returns true, when http compression is used.

unsigned tnt::Configurator::getKeepAliveMax ( ) const
inline

Returns the maximum number of requests handled over a single connection.

The default value is 1000.

cxxtools::Seconds tnt::Configurator::getKeepAliveTimeout ( ) const
inline

Returns the keep alive timeout in milliseconds.

This specifies, how long a connection is kept for keep alive. A keep alive request binds (little) resources, so it is good to free it after some time of inactivity. The default value if 15000 ms.

int tnt::Configurator::getListenBacklog ( ) const
inline

Returns the listen backlog parameter (see also listen(2)).

unsigned tnt::Configurator::getListenRetry ( ) const
inline

Returns the number of retries, when a listen retried, when failing.

size_t tnt::Configurator::getMaxRequestSize ( ) const
inline

Returns the maximum size of a request.

Requestdata are collected in memory and therefore requests, which exceed the size of available memory may lead to a denial of service.

cxxtools::Seconds tnt::Configurator::getMaxRequestTime ( ) const
inline

Returns the maximum request time, after which tntnet is automatically restarted in daemon mode.

unsigned tnt::Configurator::getMaxThreads ( ) const
inline

Returns the maximum number of worker threads.

unsigned tnt::Configurator::getMaxUrlMapCache ( ) const
inline

Returns the maximum number of cached urlmappings.

The cache stores results of the regular expressions used for defining mappings. Since the number of different urls used is normally quite limited, the cache reduces significantly the number of executed regular expressions.

unsigned tnt::Configurator::getMinCompressSize ( ) const
inline

Returns the minimum size of a request body for compression.

Small requests are not worth compressing, so tntnet has a limit, to save cpu. The default value is 1024 bytes.

unsigned tnt::Configurator::getMinThreads ( ) const
inline

Returns the minimum number of worker threads.

unsigned tnt::Configurator::getQueueSize ( ) const
inline

Returns the maximum number of jobs waiting for processing.

cxxtools::Seconds tnt::Configurator::getSessionTimeout ( ) const
inline

Returns the time of inactivity in seconds after which a session is destroyed.

unsigned tnt::Configurator::getSocketBufferSize ( ) const
inline

Returns the size of the socket buffer.

This specifies the maximum number of bytes after which the data sent or received over a socket is passed to the operating system. The default value is 16384 bytes (16 kBytes).

cxxtools::Milliseconds tnt::Configurator::getSocketReadTimeout ( ) const
inline

Returns the read timeout in millisecods after which the request is passed to the poller.

Tntnet tries to keep a connection on the same thread to reduce context switches by waiting a short period if additional data arrives. After that period the request is passed to the poller, which waits for activity on the socket. The default value is 10 ms.

cxxtools::Milliseconds tnt::Configurator::getSocketWriteTimeout ( ) const
inline

Returns the write timeout in millisecods after which the request is timed out.

The default value is 10000 ms.

cxxtools::Milliseconds tnt::Configurator::getThreadStartDelay ( ) const
inline

Returns the time in seconds between thread starts.

cxxtools::Seconds tnt::Configurator::getTimerSleep ( ) const
inline

Returns the time in seconds after which cleanup like checking sessiontimeout is done.

void tnt::Configurator::setAccessLog ( const std::string &  accessLog)
inline
void tnt::Configurator::setDefaultContentType ( const std::string &  s)
inline

Sets the default content type.

void tnt::Configurator::setEnableCompression ( bool  sw = true)
inline

enables or disables http compression.

void tnt::Configurator::setKeepAliveMax ( unsigned  ms)
inline

Sets the maximum number of requests handled over a single connection.

void tnt::Configurator::setKeepAliveTimeout ( cxxtools::Seconds  s)
inline

Sets the keep alive timeout in milliseconds.

void tnt::Configurator::setListenBacklog ( int  n)
inline

Sets the listen backlog parameter (see also listen(2)).

void tnt::Configurator::setListenRetry ( int  n)
inline

Sets the number of retries, when a listen retried, when failing.

void tnt::Configurator::setMaxRequestSize ( size_t  s)
inline

Sets the maximum size of a request.

void tnt::Configurator::setMaxRequestTime ( cxxtools::Seconds  sec)
inline

Sets the maximum request time, after which tntnet is automatically restarted in daemon mode.

void tnt::Configurator::setMaxThreads ( unsigned  n)
inline

Sets the maximum number of worker threads.

void tnt::Configurator::setMaxUrlMapCache ( int  n)
inline

Sets the maximum number of cached urlmappings.

void tnt::Configurator::setMinCompressSize ( unsigned  s)
inline

Sets the minimum size of a request body for compression.

void tnt::Configurator::setMinThreads ( unsigned  n)
inline

Sets the minimum number of worker threads.

void tnt::Configurator::setQueueSize ( unsigned  n)
inline

Sets the maximum number of jobs waiting for processing.

void tnt::Configurator::setSessionTimeout ( cxxtools::Seconds  sec)
inline

Sets the time of inactivity in seconds after which a session is destroyed.

void tnt::Configurator::setSocketBufferSize ( unsigned  ms)
inline

Sets the size of the socket buffer.

void tnt::Configurator::setSocketReadTimeout ( cxxtools::Milliseconds  ms)
inline

Sets the timeout in millisecods after which the request is passed to the poller.

void tnt::Configurator::setSocketWriteTimeout ( cxxtools::Milliseconds  ms)
inline

Sets the write timeout in millisecods after which the request is timed out.

void tnt::Configurator::setThreadStartDelay ( cxxtools::Milliseconds  sec)
inline

Sets the time in seconds between thread starts.

void tnt::Configurator::setTimerSleep ( cxxtools::Seconds  sec)
inline

Sets the time in seconds after which cleanup like checking sessiontimeout is done.


The documentation for this class was generated from the following file: