mongo-drivergo.mongodb.org/mongo-driver/core/session Index | Files

package session

import "go.mongodb.org/mongo-driver/core/session"

Index

Constants

const UUIDSubtype byte = 4

UUIDSubtype is the BSON binary subtype that a UUID should be encoded as

Variables

var ErrSessionEnded = errors.New("ended session was used")

ErrSessionEnded is returned when a client session is used after a call to endSession().

Functions

func MaxClusterTime

func MaxClusterTime(ct1 *bson.Document, ct2 *bson.Document) *bson.Document

MaxClusterTime compares 2 clusterTime documents and returns the document representing the highest cluster time.

Types

type Client

type Client struct {
	ClientID    uuid.UUID
	ClusterTime *bson.Document
	SessionID   *bson.Document
	SessionType Type
	Terminated  bool
	// contains filtered or unexported fields
}

Client is a session for clients to run commands.

func NewClientSession

func NewClientSession(pool *Pool, clientID uuid.UUID, sessionType Type) (*Client, error)

NewClientSession creates a Client.

func (*Client) AdvanceClusterTime

func (c *Client) AdvanceClusterTime(clusterTime *bson.Document) error

AdvanceClusterTime updates the session's cluster time.

func (*Client) EndSession

func (c *Client) EndSession()

EndSession ends the session.

func (*Client) UpdateUseTime

func (c *Client) UpdateUseTime() error

UpdateUseTime updates the session's last used time. Must be called whenver this session is used to send a command to the server.

type ClusterClock

type ClusterClock struct {
	// contains filtered or unexported fields
}

ClusterClock represents a logical clock for keeping track of cluster time.

func (*ClusterClock) AdvanceClusterTime

func (cc *ClusterClock) AdvanceClusterTime(clusterTime *bson.Document)

AdvanceClusterTime updates the cluster's current time.

func (*ClusterClock) GetClusterTime

func (cc *ClusterClock) GetClusterTime() *bson.Document

GetClusterTime returns the cluster's current time.

type Node

type Node struct {
	*Server
	// contains filtered or unexported fields
}

Node represents a server session in a linked list

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool is a pool of server sessions that can be reused.

func NewPool

func NewPool(descChan <-chan description.Topology) *Pool

NewPool creates a new server session pool

func (*Pool) CheckedOut

func (p *Pool) CheckedOut() int

CheckedOut returns number of sessions checked out from pool.

func (*Pool) GetSession

func (p *Pool) GetSession() (*Server, error)

GetSession retrieves an unexpired session from the pool.

func (*Pool) IDSlice

func (p *Pool) IDSlice() []*bson.Document

IDSlice returns a slice of session IDs for each session in the pool

func (*Pool) ReturnSession

func (p *Pool) ReturnSession(ss *Server)

ReturnSession returns a session to the pool if it has not expired.

func (*Pool) String

func (p *Pool) String() string

String implements the Stringer interface

type Server

type Server struct {
	SessionID *bson.Document
	LastUsed  time.Time
}

Server is an open session with the server.

type Type

type Type uint8

Type describes the type of the session

const (
	Explicit Type = iota
	Implicit
)

These constants are the valid types for a client session.

Source Files

client_session.go cluster_clock.go server_session.go session_pool.go

Version
v0.0.10
Published
Jul 26, 2018
Platform
darwin/amd64
Imports
7 packages
Last checked
now

Tools for package owners.