Represents a session which gives access to data stored in a data store.
A Session
object can be created from a connection string, from SessionSettings
or by directly specifying a host name, TCP/IP port and user credentials. Once created, a session is ready to be used. Session destructor closes the session and cleans up after it.
If it is not possible to create a valid session for some reason, errors are thrown from session constructor.
Several hosts can be specified by session creation parameters. In that case a failed connection to one of the hosts triggers a fail-over attempt to connect to a different host in the list. Only if none of the hosts could be contacted, session creation fails.
The fail-over logic tries hosts in the order in which they are specified in session settings unless explicit priorities are assigned to the hosts. In that case hosts are tried in the decreasing priority order and for hosts with the same priority the order in which they are tired is random.
Once a valid session is created using one of the hosts, the session is bound to that host and never re-connected again. If the connection gets broken, the session fails without making any other fail-over attempts. The fail-over logic is executed only when establishing a new session.
- Note
- A
Session
object should be used by at most one thread at a time. It is not safe to call its methods by several threads simultaneously. It is responsibility of the user to ensure this using a synchronization mechanism such as mutexes.