package description
import "go.mongodb.org/mongo-driver/x/mongo/driver/description"
Index ¶
- Constants
- func MaxStalenessSupported(wireVersion *VersionRange) error
- func ScramSHA1Supported(wireVersion *VersionRange) error
- func SessionsSupported(wireVersion *VersionRange) bool
- type HostlistDiff
- type SelectedServer
- type Server
- func NewServer(addr address.Address, response bsoncore.Document) Server
- func (s Server) DataBearing() bool
- func (s Server) SelectServer(_ Topology, candidates []Server) ([]Server, error)
- func (s Server) SetAverageRTT(rtt time.Duration) Server
- type ServerKind
- type ServerSelector
- func CompositeSelector(selectors []ServerSelector) ServerSelector
- func LatencySelector(latency time.Duration) ServerSelector
- func ReadPrefSelector(rp *readpref.ReadPref) ServerSelector
- func WriteSelector() ServerSelector
- type ServerSelectorFunc
- type Topology
- func (t Topology) DiffHostlist(hostlist []string) HostlistDiff
- func (t Topology) Server(addr address.Address) (Server, bool)
- type TopologyDiff
- type TopologyKind
- type Version
- type VersionRange
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.
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 HostlistDiff ¶
HostlistDiff is the difference between a topology and a host list.
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 ¶
NewServer creates a new server description from the given parameters.
func (Server) DataBearing ¶
DataBearing returns true if the server is a data bearing server.
func (Server) SelectServer ¶
SelectServer selects this server if it is in the list of given candidates.
func (Server) SetAverageRTT ¶
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 ¶
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 ¶
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) DiffHostlist ¶
func (t Topology) DiffHostlist(hostlist []string) HostlistDiff
DiffHostlist compares the topology description and host list and returns the difference.
func (Topology) Server ¶
Server returns the server for the given address. Returns false if the server could not be found.
type TopologyDiff ¶
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 ¶
Version represents a software version.
func (Version) AtLeast ¶
AtLeast ensures that the version is at least as large as the "other" version.
func (Version) String ¶
String provides the string represtation of the Version.
type VersionRange ¶
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.
Source Files ¶
description.go feature.go server.go server_kind.go server_selector.go topology.go topology_kind.go version.go version_range.go
- Version
- v1.3.0
- Published
- Feb 5, 2020
- Platform
- darwin/amd64
- Imports
- 10 packages
- Last checked
- 1 second ago –
Tools for package owners.