session

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UUIDSubtype byte = 4

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

Variables

View Source
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
	Consistent    bool // causal consistency
	OperationTime *bson.Timestamp
	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, opts ...ClientOptioner) (*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) AdvanceOperationTime added in v0.0.11

func (c *Client) AdvanceOperationTime(opTime *bson.Timestamp) error

AdvanceOperationTime updates the session's operation 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 ClientOptioner added in v0.0.11

type ClientOptioner interface {
	Option(*Client) error
}

ClientOptioner is the interface implemented by types that can be used as options for configuring a client session.

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 OptCausalConsistency added in v0.0.11

type OptCausalConsistency bool

OptCausalConsistency specifies if a session should be causally consistent.

func (OptCausalConsistency) Option added in v0.0.11

func (opt OptCausalConsistency) Option(c *Client) error

Option implements the ClientOptioner interface.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL