description

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Unknown = 0

Unknown is an unknown server or topology kind.

View Source
const UnknownStr = "Unknown"

UnknownStr represents an unknown server kind.

Variables

This section is empty.

Functions

This section is empty.

Types

type SelectedServer

type SelectedServer struct {
	Server
	Kind TopologyKind
}

SelectedServer augments the Server type by also including the TopologyKind of the topology that includes the server. This type should be used to track the state of a server that was selected to perform an operation.

type Server

type Server struct {
	Addr address.Address

	Arbiters              []string
	AverageRTT            time.Duration
	AverageRTTSet         bool
	Compression           []string // compression methods returned by server
	CanonicalAddr         address.Address
	ElectionID            bson.ObjectID
	HeartbeatInterval     time.Duration
	HelloOK               bool
	Hosts                 []string
	IsCryptd              bool
	LastError             error
	LastUpdateTime        time.Time
	LastWriteTime         time.Time
	MaxBatchCount         uint32
	MaxDocumentSize       uint32
	MaxMessageSize        uint32
	Members               []address.Address
	Passives              []string
	Passive               bool
	Primary               address.Address
	ReadOnly              bool
	ServiceID             *bson.ObjectID // Only set for servers that are deployed behind a load balancer.
	SessionTimeoutMinutes *int64
	SetName               string
	SetVersion            uint32
	Tags                  tag.Set
	TopologyVersion       *TopologyVersion
	Kind                  ServerKind
	WireVersion           *VersionRange
}

Server contains information about a node in a cluster. This is created from hello command responses. If the value of the Kind field is LoadBalancer, only the Addr and Kind fields will be set. All other fields will be set to the zero value of the field's type.

func (Server) String

func (s Server) String() string

type ServerKind

type ServerKind uint32

ServerKind represents the type of a single server in a topology.

const (
	ServerKindStandalone   ServerKind = 1
	ServerKindRSMember     ServerKind = 2
	ServerKindRSPrimary    ServerKind = 4 + ServerKindRSMember
	ServerKindRSSecondary  ServerKind = 8 + ServerKindRSMember
	ServerKindRSArbiter    ServerKind = 16 + ServerKindRSMember
	ServerKindRSGhost      ServerKind = 32 + ServerKindRSMember
	ServerKindMongos       ServerKind = 256
	ServerKindLoadBalancer ServerKind = 512
)

These constants are the possible types of servers.

func (ServerKind) String

func (kind ServerKind) String() string

String returns a stringified version of the kind or "Unknown" if the kind is invalid.

type ServerSelector

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

ServerSelector is an interface implemented by types that can perform server selection given a topology description and list of candidate servers. The selector should filter the provided candidates list and return a subset that matches some criteria.

type Topology

type Topology struct {
	Servers               []Server
	SetName               string
	Kind                  TopologyKind
	SessionTimeoutMinutes *int64
	CompatibilityErr      error
}

Topology contains information about a MongoDB cluster.

func (Topology) String

func (t Topology) String() string

String implements the Stringer interface.

type TopologyKind

type TopologyKind uint32

TopologyKind represents a specific topology configuration.

const (
	TopologyKindSingle                TopologyKind = 1
	TopologyKindReplicaSet            TopologyKind = 2
	TopologyKindReplicaSetNoPrimary   TopologyKind = 4 + TopologyKindReplicaSet
	TopologyKindReplicaSetWithPrimary TopologyKind = 8 + TopologyKindReplicaSet
	TopologyKindSharded               TopologyKind = 256
	TopologyKindLoadBalanced          TopologyKind = 512
)

These constants are the available topology configurations.

func (TopologyKind) String

func (kind TopologyKind) String() string

String implements the fmt.Stringer interface.

type TopologyVersion

type TopologyVersion struct {
	ProcessID bson.ObjectID
	Counter   int64
}

TopologyVersion represents a software version.

type VersionRange

type VersionRange struct {
	Min int32
	Max int32
}

VersionRange represents a range of versions.

Jump to

Keyboard shortcuts

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