ClientSettings are used to construct Client objects.
More...
ClientSettings are used to construct Client objects.
It can be constructed using a connection string plus a JSON with client options, or by setting each ClientOption and SessionOption with its correspondant value.
◆ ClientSettings() [1/5]
◆ ClientSettings() [2/5]
◆ ClientSettings() [3/5]
Create client settings from a connection string and.
Client options are expressed in JSON format. Here is an example:
{ "pooling": {
"enabled": true,
"maxSize": 25,
"queueTimeout": 1000,
"maxIdleTime": 5000}
}
All options are defined under a document with key vale "pooling". Inside the document, the available options are these:
enabled
: boolean value that enable or disable connection pooling. If disabled, session created from pool are the same as created directly without client handle. Enabled by default.
maxSize
: integer that defines the max pooling sessions possible. If uses tries to get session from pool when maximum sessions are used, it will wait for an available session untill queueTimeout
. Defaults to 25.
queueTimeout
: integer value that defines the time, in milliseconds, that client will wait to get an available session. By default it doesn't timeouts.
maxIdleTime
: integer value that defines the time, in milliseconds, that an available session will wait in the pool before it is removed. By default it doesn't cleans sessions.
◆ ClientSettings() [4/5]
Create client settings from a connection string and.
Client options are expressed in JSON format. Here is an example:
{ "pooling": {
"enabled": true,
"maxSize": 25,
"queueTimeout": 1000,
"maxIdleTime": 5000}
}
All options are defined under a document with key vale "pooling". Inside the document, the available options are these:
enabled
: boolean value that enable or disable connection pooling. If disabled, session created from pool are the same as created directly without client handle. Enabled by default.
maxSize
: integer that defines the max pooling sessions possible. If uses tries to get session from pool when maximum sessions are used, it will wait for an available session untill queueTimeout
. Defaults to 25.
queueTimeout
: integer value that defines the time, in milliseconds, that client will wait to get an available session. By default it doesn't timeouts.
maxIdleTime
: integer value that defines the time, in milliseconds, that an available session will wait in the pool before it is removed. By default it doesn't cleans sessions.
◆ ClientSettings() [5/5]
Create client settings from a connection string and client settings as a list of client options.
The list of options consist of a ClientOption constant, identifying the option to set, followed by the value of the option.
Example:
);
@ POOLING
Definition: settings.h:132
@ POOL_QUEUE_TIMEOUT
Definition: settings.h:132
@ POOL_MAX_SIZE
Definition: settings.h:132
@ POOL_MAX_IDLE_TIME
Definition: settings.h:132
ClientSettings(const string &uri)
Create client settings from a connection string.
Definition: settings.h:844
ClientOption::POOL_QUEUE_TIMEOUT and ClientOption::POOL_MAX_IDLE_TIME can be specified using std::chrono::duration objects, or by integer values, with the latest to be specified in milliseconds.
- See also
- SessionSettings
◆ find()
Find the specified option opt
and returns its Value.
Returns NULL Value if not found.
◆ set()
void set |
( |
OPT |
opt, |
|
|
R &&... |
rest |
|
) |
| |
|
inline |
Set client and session options.
Accepts a list of one or more ClientOption
or SessionOption
constants, each followed by the option value. Options specified here are added to the current settings.
Repeated HOST
, PORT
, SOCKET
and PRIORITY
options build a list of hosts to be used by the fail-over logic. For other options, if they are set again, the new value overrides the previous setting.
- Note
- When using
HOST
, PORT
and PRIORITY
options to specify a single host, all have to be specified in the same set()
call.
The documentation for this class was generated from the following file: