Documentation ¶
Index ¶
- Constants
- func Dial(addrs []string, replset string, usersSecret *corev1.Secret, useTLS bool) (*mgo.Session, error)
- func WriteConfig(session *mgo.Session, cfg RSConfig) error
- type Member
- type OKResponse
- type RSConfig
- type RSMembers
- type ReplSetGetConfig
- type ReplsetTags
- type Settings
- type WriteConcern
Constants ¶
const ( MinVotingMembers = 1 MaxVotingMembers = 7 MaxMembers = 50 )
Variables ¶
This section is empty.
Functions ¶
func WriteConfig ¶
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
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 ¶
type RSMembers ¶
type RSMembers []Member
func (*RSMembers) RemoveOld ¶
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.
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 ReplsetTags ¶
Replica Set tags: https://docs.mongodb.com/manual/tutorial/configure-replica-set-tag-sets/#add-tag-sets-to-a-replica-set
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/