Mongo.Session.ServerSession (mongodb-driver v1.4.0) View Source

This module represents the server-side session. There are three fields:

  • last_use - The timestamp for the last use of this server session
  • txn_num - The current transaction number
  • session_id - The session id of this server session

When a transaction is active, all operations in that transaction use the same transaction number.

Transaction number is also used outside of transactions for retryable writes. In this case, each write operation has its own transaction number, but retries of a write operation use the same transaction number as the first write (which is how the server knows that subsequent writes are retries and should be ignored if the first write succeeded on the server but was not read by the client, for example).

Link to this section Summary

Functions

Return true, if the server session will time out. In this case the session can be removed from the queue.

Create a new server session.

Increment the current transaction number and return the new value.

Update the last_use attribute of the server session to now.

Link to this section Types

Specs

t() :: %Mongo.Session.ServerSession{
  last_use: integer(),
  session_id: BSON.Binary.t(),
  txn_num: non_neg_integer()
}

Link to this section Functions

Link to this function

about_to_expire?(server_session, logical_session_timeout)

View Source

Specs

about_to_expire?(t(), integer()) :: boolean()

Return true, if the server session will time out. In this case the session can be removed from the queue.

Specs

new() :: t()

Create a new server session.

Specs

next_txn_num(t()) :: t()

Increment the current transaction number and return the new value.

Specs

set_last_use(t()) :: t()

Update the last_use attribute of the server session to now.