mongo

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinVotingMembers = 1
	MaxVotingMembers = 7
	MaxMembers       = 50
)

Variables

This section is empty.

Functions

func Dial

func Dial(addrs []string, replset string, usersSecret *corev1.Secret, useTLS bool) (*mgo.Session, error)

func WriteConfig

func WriteConfig(session *mgo.Session, cfg RSConfig) error

Types

type Member

type Member struct {
	ID           int         `bson:"_id" json:"_id"`
	Host         string      `bson:"host" json:"host"`
	ArbiterOnly  bool        `bson:"arbiterOnly" json:"arbiterOnly"`
	BuildIndexes bool        `bson:"buildIndexes" json:"buildIndexes"`
	Hidden       bool        `bson:"hidden" json:"hidden"`
	Priority     int         `bson:"priority" json:"priority"`
	Tags         ReplsetTags `bson:"tags,omitempty" json:"tags,omitempty"`
	SlaveDelay   int64       `bson:"slaveDelay" json:"slaveDelay"`
	Votes        int         `bson:"votes" json:"votes"`
}

Member document from 'replSetGetConfig': https://docs.mongodb.com/manual/reference/command/replSetGetConfig/#dbcmd.replSetGetConfig

func (Member) String

func (m Member) String() string

type OKResponse

type OKResponse struct {
	Errmsg string `bson:"errmsg,omitempty" json:"errmsg,omitempty"`
	OK     int    `bson:"ok" json:"ok" json:"ok"`
}

OKResponse is a standard MongoDB response

type RSConfig

type RSConfig struct {
	ID                                 string    `bson:"_id" json:"_id"`
	Version                            int       `bson:"version" json:"version"`
	Members                            RSMembers `bson:"members" json:"members"`
	Configsvr                          bool      `bson:"configsvr,omitempty" json:"configsvr,omitempty"`
	ProtocolVersion                    int       `bson:"protocolVersion,omitempty" json:"protocolVersion,omitempty"`
	Settings                           Settings  `bson:"settings,omitempty" json:"settings,omitempty"`
	WriteConcernMajorityJournalDefault bool      `bson:"writeConcernMajorityJournalDefault,omitempty" json:"writeConcernMajorityJournalDefault,omitempty"`
}

func ReadConfig

func ReadConfig(session *mgo.Session) (RSConfig, error)

type RSMembers

type RSMembers []Member

func (*RSMembers) AddNew

func (m *RSMembers) AddNew(from RSMembers) (changes bool)

AddNew adds new members from given list

func (*RSMembers) RemoveOld

func (m *RSMembers) RemoveOld(compareWith RSMembers) (changes bool)

RemoveOld removes from the list those members which are not present in the given list. It always should leave at least one element. The config won't be valid for mongo otherwise. Better, if the last element has the smallest ID in order not to produce defragmentation when the next element will be added (ID = maxID + 1). Mongo replica set member ID must be between 0 and 255, so it matters.

func (*RSMembers) SetVotes

func (m *RSMembers) SetVotes()

SetVotes sets voting parameters for members list

type ReplSetGetConfig

type ReplSetGetConfig struct {
	Config *RSConfig `bson:"config" json:"config"`
	Errmsg string    `bson:"errmsg,omitempty" json:"errmsg,omitempty"`
	OKResponse
}

Response document from 'replSetGetConfig': https://docs.mongodb.com/manual/reference/command/replSetGetConfig/#dbcmd.replSetGetConfig

type Settings

type Settings struct {
	ChainingAllowed         bool                   `bson:"chainingAllowed,omitempty" json:"chainingAllowed,omitempty"`
	HeartbeatIntervalMillis int64                  `bson:"heartbeatIntervalMillis,omitempty" json:"heartbeatIntervalMillis,omitempty"`
	HeartbeatTimeoutSecs    int                    `bson:"heartbeatTimeoutSecs,omitempty" json:"heartbeatTimeoutSecs,omitempty"`
	ElectionTimeoutMillis   int64                  `bson:"electionTimeoutMillis,omitempty" json:"electionTimeoutMillis,omitempty"`
	CatchUpTimeoutMillis    int64                  `bson:"catchUpTimeoutMillis,omitempty" json:"catchUpTimeoutMillis,omitempty"`
	GetLastErrorModes       map[string]ReplsetTags `bson:"getLastErrorModes,omitempty" json:"getLastErrorModes,omitempty"`
	GetLastErrorDefaults    WriteConcern           `bson:"getLastErrorDefaults,omitempty" json:"getLastErrorDefaults,omitempty"`
	ReplicaSetID            bson.ObjectId          `bson:"replicaSetId,omitempty" json:"replicaSetId,omitempty"`
}

Settings document from 'replSetGetConfig': https://docs.mongodb.com/manual/reference/command/replSetGetConfig/#dbcmd.replSetGetConfig

type WriteConcern

type WriteConcern struct {
	WriteConcern interface{} `bson:"w" json:"w"`
	WriteTimeout int         `bson:"wtimeout" json:"wtimeout"`
	Journal      bool        `bson:"j,omitempty" json:"j,omitempty"`
}

WriteConcern document: https://docs.mongodb.com/manual/reference/write-concern/

Jump to

Keyboard shortcuts

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