model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Unknown = 0

Unknown is an unknown cluster or server kind.

View Source
const UnsetRTT = -1 * time.Millisecond

UnsetRTT is the unset value for a round trip time.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr string

Addr is the address of a mongodb server.

func (Addr) Canonicalize

func (a Addr) Canonicalize() Addr

Canonicalize creates a canonicalized address.

func (Addr) Network

func (a Addr) Network() string

Network returns the network of the address.

func (Addr) String

func (a Addr) String() string

String returns the canonical version of the address.

type Cluster

type Cluster struct {
	Servers []*Server
	Kind    ClusterKind
}

Cluster is a description of a cluster.

func (*Cluster) Server

func (i *Cluster) Server(addr Addr) (*Server, bool)

Server returns the model.Server with the specified address.

type ClusterDiff

type ClusterDiff struct {
	AddedServers   []*Server
	RemovedServers []*Server
}

ClusterDiff is the difference between two clusters.

func DiffCluster

func DiffCluster(old, new *Cluster) *ClusterDiff

DiffCluster returns the difference of two clusters.

type ClusterKind

type ClusterKind uint32

ClusterKind represents a type of the cluster.

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

ClusterKind constants.

func (ClusterKind) String

func (kind ClusterKind) String() string

type Conn

type Conn struct {
	Server

	// The connection identifier.
	ID string
}

Conn is a description of a connection.

type FSM

type FSM struct {
	Cluster
	SetName string
	// contains filtered or unexported fields
}

FSM is a finite state machine for transitioning cluster states.

func NewFSM

func NewFSM() *FSM

NewFSM creates a new FSM.

func (*FSM) Apply

func (fsm *FSM) Apply(s *Server) error

Apply uses the server model to transition states.

type Range

type Range struct {
	Min int32
	Max int32
}

Range is an inclusive range between 2 uint32.

func NewRange

func NewRange(min int32, max int32) Range

NewRange creates a new Range given a min and a max.

func (*Range) Includes

func (r *Range) Includes(i int32) bool

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

func (*Range) String

func (r *Range) String() string

type Server

type Server struct {
	Addr Addr

	AverageRTT        time.Duration
	AverageRTTSet     bool
	CanonicalAddr     Addr
	ElectionID        objectid.ObjectID
	GitVersion        string
	HeartbeatInterval time.Duration
	LastError         error
	LastUpdateTime    time.Time
	LastWriteTime     time.Time
	MaxBatchCount     uint16
	MaxDocumentSize   uint32
	MaxMessageSize    uint32
	Members           []Addr
	ReadOnly          bool
	SetName           string
	SetVersion        uint32
	Tags              TagSet
	Kind              ServerKind
	WireVersion       *Range
	Version           Version
}

Server is a description of a server.

func BuildServer

func BuildServer(addr Addr, isMasterResult *internal.IsMasterResult, buildInfoResult *internal.BuildInfoResult) *Server

BuildServer builds a server.Server from an endpoint, IsMasterResult, and a BuildInfoResult.

func (*Server) SetAverageRTT

func (i *Server) SetAverageRTT(rtt time.Duration)

SetAverageRTT sets the average round trip time.

type ServerKind

type ServerKind uint32

ServerKind represents a type of 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
)

ServerKind constants.

func (ServerKind) String

func (kind ServerKind) String() string

type Tag

type Tag struct {
	Name  string
	Value string
}

Tag is a name/value pair.

type TagSet

type TagSet []Tag

TagSet is an ordered list of Tags.

func NewTagSetFromMap

func NewTagSetFromMap(m map[string]string) TagSet

NewTagSetFromMap creates a new tag set from a map.

func NewTagSetsFromMaps

func NewTagSetsFromMaps(maps []map[string]string) []TagSet

NewTagSetsFromMaps creates new tag sets from maps.

func (TagSet) Contains

func (ts TagSet) Contains(name, value string) bool

Contains indicates whether the name/value pair exists in the tag set.

func (TagSet) ContainsAll

func (ts TagSet) ContainsAll(other []Tag) bool

ContainsAll indicates whether all the name/value pairs exist in the tag set.

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 representation of the Version.

Jump to

Keyboard shortcuts

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