Documentation ¶
Index ¶
- Constants
- func MaxStalenessSupported(wireVersion *VersionRange) error
- func ScramSHA1Supported(wireVersion *VersionRange) error
- func SessionsSupported(wireVersion *VersionRange) bool
- type HostlistDiff
- type SelectedServer
- type Server
- type ServerKind
- type ServerSelector
- type ServerSelectorFunc
- type Topology
- 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.
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 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 NewDefaultServer ¶ added in v1.3.9
NewDefaultServer creates a new unknown server description with the given address.
func NewServerFromError ¶ added in v1.3.9
NewServerFromError creates a new unknown server description with the given address and error.
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.
func (Server) SupportsRetryWrites ¶ added in v1.3.9
SupportsRetryWrites returns true if this description represents a server that supports retryable writes.
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.
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.
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.