description

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Unknown = 0

Unknown is an unknown server or topology kind.

View Source
const UnsetRTT = -1 * time.Millisecond

UnsetRTT is the unset value for a round trip time.

Variables

This section is empty.

Functions

func MaxStalenessSupported

func MaxStalenessSupported(wireVersion *VersionRange) error

MaxStalenessSupported returns an error if the given server version does not support max staleness.

func ScramSHA1Supported

func ScramSHA1Supported(wireVersion *VersionRange) error

ScramSHA1Supported returns an error if the given server version does not support scram-sha-1.

func SessionsSupported

func SessionsSupported(wireVersion *VersionRange) bool

SessionsSupported returns true of the given server version indicates that it supports sessions.

Types

type SelectedServer

type SelectedServer struct {
	Server
	Kind TopologyKind
}

SelectedServer represents a selected server that is a member of a topology.

type Server

type Server struct {
	Addr address.Address

	AverageRTT            time.Duration
	AverageRTTSet         bool
	Compression           []string // compression methods returned by server
	CanonicalAddr         address.Address
	ElectionID            primitive.ObjectID
	HeartbeatInterval     time.Duration
	LastError             error
	LastUpdateTime        time.Time
	LastWriteTime         time.Time
	MaxBatchCount         uint32
	MaxDocumentSize       uint32
	MaxMessageSize        uint32
	Members               []address.Address
	ReadOnly              bool
	SessionTimeoutMinutes uint32
	SetName               string
	SetVersion            uint32
	Tags                  tag.Set
	Kind                  ServerKind
	WireVersion           *VersionRange

	SaslSupportedMechs []string // user-specific from server handshake
}

Server represents a description of a server. This is created from an isMaster command.

func NewServer

func NewServer(addr address.Address, isMaster result.IsMaster) Server

NewServer creates a new server description from the given parameters.

func (Server) DataBearing

func (s Server) DataBearing() bool

DataBearing returns true if the server is a data bearing server.

func (Server) SetAverageRTT

func (s Server) SetAverageRTT(rtt time.Duration) Server

SetAverageRTT sets the average round trip time for this server description.

type ServerKind

type ServerKind uint32

ServerKind represents the type of a server.

const (
	Standalone  ServerKind = 1
	RSMember    ServerKind = 2
	RSPrimary   ServerKind = 4 + RSMember
	RSSecondary ServerKind = 8 + RSMember
	RSArbiter   ServerKind = 16 + RSMember
	RSGhost     ServerKind = 32 + RSMember
	Mongos      ServerKind = 256
)

These constants are the possible types of servers.

func (ServerKind) String

func (kind ServerKind) String() string

String implements the fmt.Stringer interface.

type ServerSelector

type ServerSelector interface {
	SelectServer(Topology, []Server) ([]Server, error)
}

ServerSelector is an interface implemented by types that can select a server given a topology description.

func CompositeSelector

func CompositeSelector(selectors []ServerSelector) ServerSelector

CompositeSelector combines multiple selectors into a single selector.

func LatencySelector

func LatencySelector(latency time.Duration) ServerSelector

LatencySelector creates a ServerSelector which selects servers based on their latency.

func ReadPrefSelector

func ReadPrefSelector(rp *readpref.ReadPref) ServerSelector

ReadPrefSelector selects servers based on the provided read preference.

func WriteSelector

func WriteSelector() ServerSelector

WriteSelector selects all the writable servers.

type ServerSelectorFunc

type ServerSelectorFunc func(Topology, []Server) ([]Server, error)

ServerSelectorFunc is a function that can be used as a ServerSelector.

func (ServerSelectorFunc) SelectServer

func (ssf ServerSelectorFunc) SelectServer(t Topology, s []Server) ([]Server, error)

SelectServer implements the ServerSelector interface.

type Topology

type Topology struct {
	Servers               []Server
	Kind                  TopologyKind
	SessionTimeoutMinutes uint32
}

Topology represents a description of a mongodb topology

func (Topology) Server

func (t Topology) Server(addr address.Address) (Server, bool)

Server returns the server for the given address. Returns false if the server could not be found.

type TopologyDiff

type TopologyDiff struct {
	Added   []Server
	Removed []Server
}

TopologyDiff is the difference between two different topology descriptions.

func DiffTopology

func DiffTopology(old, new Topology) TopologyDiff

DiffTopology compares the two topology descriptions and returns the difference.

type TopologyKind

type TopologyKind uint32

TopologyKind represents a specific topology configuration.

const (
	Single                TopologyKind = 1
	ReplicaSet            TopologyKind = 2
	ReplicaSetNoPrimary   TopologyKind = 4 + ReplicaSet
	ReplicaSetWithPrimary TopologyKind = 8 + ReplicaSet
	Sharded               TopologyKind = 256
)

These constants are the available topology configurations.

func (TopologyKind) String

func (kind TopologyKind) String() string

String implements the fmt.Stringer interface.

type Version

type Version struct {
	Desc  string
	Parts []uint8
}

Version represents a software version.

func (Version) AtLeast

func (v Version) AtLeast(other ...uint8) bool

AtLeast ensures that the version is at least as large as the "other" version.

func (Version) String

func (v Version) String() string

String provides the string represtation of the Version.

type VersionRange

type VersionRange struct {
	Min int32
	Max int32
}

VersionRange represents a range of versions.

func NewVersionRange

func NewVersionRange(min, max int32) VersionRange

NewVersionRange creates a new VersionRange given a min and a max.

func (VersionRange) Includes

func (vr VersionRange) Includes(v int32) bool

Includes returns a bool indicating whether the supplied integer is included in the range.

func (VersionRange) String

func (vr VersionRange) String() string

String implements the fmt.Stringer interface.

Jump to

Keyboard shortcuts

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