mongo-driver: go.mongodb.org/mongo-driver/x/mongo/driver/description Index | Files

package description

import "go.mongodb.org/mongo-driver/x/mongo/driver/description"

Index

Package Files

description.go feature.go server.go server_kind.go server_selector.go topology.go topology_kind.go version.go version_range.go

Constants

const Unknown = 0

Unknown is an unknown server or topology kind.

const UnsetRTT = -1 * time.Millisecond

UnsetRTT is the unset value for a round trip time.

func MaxStalenessSupported Uses

func MaxStalenessSupported(wireVersion *VersionRange) error

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

func ScramSHA1Supported Uses

func ScramSHA1Supported(wireVersion *VersionRange) error

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

func SessionsSupported Uses

func SessionsSupported(wireVersion *VersionRange) bool

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

type HostlistDiff Uses

type HostlistDiff struct {
    Added   []string
    Removed []string
}

HostlistDiff is the difference between a topology and a host list.

type SelectedServer Uses

type SelectedServer struct {
    Server
    Kind TopologyKind
}

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

type Server Uses

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 Uses

func NewServer(addr address.Address, response bsoncore.Document) Server

NewServer creates a new server description from the given parameters.

func (Server) DataBearing Uses

func (s Server) DataBearing() bool

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

func (Server) SelectServer Uses

func (s Server) SelectServer(_ Topology, candidates []Server) ([]Server, error)

SelectServer selects this server if it is in the list of given candidates.

func (Server) SetAverageRTT Uses

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

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

type ServerKind Uses

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 Uses

func (kind ServerKind) String() string

String implements the fmt.Stringer interface.

type ServerSelector Uses

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 Uses

func CompositeSelector(selectors []ServerSelector) ServerSelector

CompositeSelector combines multiple selectors into a single selector.

func LatencySelector Uses

func LatencySelector(latency time.Duration) ServerSelector

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

func ReadPrefSelector Uses

func ReadPrefSelector(rp *readpref.ReadPref) ServerSelector

ReadPrefSelector selects servers based on the provided read preference.

func WriteSelector Uses

func WriteSelector() ServerSelector

WriteSelector selects all the writable servers.

type ServerSelectorFunc Uses

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

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

func (ServerSelectorFunc) SelectServer Uses

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

SelectServer implements the ServerSelector interface.

type Topology Uses

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

Topology represents a description of a mongodb topology

func (Topology) DiffHostlist Uses

func (t Topology) DiffHostlist(hostlist []string) HostlistDiff

DiffHostlist compares the topology description and host list and returns the difference.

func (Topology) Server Uses

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 Uses

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

TopologyDiff is the difference between two different topology descriptions.

func DiffTopology Uses

func DiffTopology(old, new Topology) TopologyDiff

DiffTopology compares the two topology descriptions and returns the difference.

type TopologyKind Uses

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 Uses

func (kind TopologyKind) String() string

String implements the fmt.Stringer interface.

type Version Uses

type Version struct {
    Desc  string
    Parts []uint8
}

Version represents a software version.

func (Version) AtLeast Uses

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

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

func (Version) String Uses

func (v Version) String() string

String provides the string represtation of the Version.

type VersionRange Uses

type VersionRange struct {
    Min int32
    Max int32
}

VersionRange represents a range of versions.

func NewVersionRange Uses

func NewVersionRange(min, max int32) VersionRange

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

func (VersionRange) Includes Uses

func (vr VersionRange) Includes(v int32) bool

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

func (VersionRange) String Uses

func (vr VersionRange) String() string

String implements the fmt.Stringer interface.

Package description imports 10 packages (graph) and is imported by 9 packages. Updated 2019-09-26. Refresh now. Tools for package owners.