Documentation ¶
Index ¶
- Constants
- func Add(session *mgo.Session, members ...Member) error
- func Initiate(session *mgo.Session, address, name string) error
- func Remove(session *mgo.Session, addrs ...string) error
- func Set(session *mgo.Session, members []Member) error
- type Config
- type IsMasterResults
- type Member
- type MemberState
- type MemberStatus
- type Status
Constants ¶
const ( StartupState = iota PrimaryState SecondaryState RecoveringState FatalState Startup2State UnknownState ArbiterState DownState RollbackState ShunnedState )
const MaxPeers = 7
MaxPeers defines the maximum number of peers that mongo supports.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds the given members to the session's replica set. Duplicates of existing replicas will be ignored.
Members will have their Ids set automatically if they are not already > 0
func Initiate ¶
Initiate sets up a replica set with the given replica set name with the single given member. It need be called only once for a given mongo replica set.
Note that you must set DialWithInfo and set Direct = true when dialing into a specific non-initiated mongo server. The session will be set to Monotonic mode.
See http://docs.mongodb.org/manual/reference/method/rs.initiate/ for more details.
Types ¶
type Config ¶
type Config struct { Name string `bson:"_id"` Version int `bson:"version"` Members []Member `bson:"members"` }
Config is the document stored in mongodb that defines the servers in the replica set
type IsMasterResults ¶
type IsMasterResults struct { // The following fields hold information about the specific mongodb node. IsMaster bool `bson:"ismaster"` Secondary bool `bson:"secondary"` Arbiter bool `bson:"arbiterOnly"` Address string `bson:"me"` LocalTime time.Time `bson:"localTime"` // The following fields hold information about the replica set. ReplicaSetName string `bson:"setName"` Addresses []string `bson:"hosts"` Arbiters []string `bson:"arbiters"` PrimaryAddress string `bson:"primary"` }
Config reports information about the configuration of a given mongo node
type Member ¶
type Member struct { // Id is a unique id for a member in a set. Id int `bson:"_id"` // Address holds the network address of the member, // in the form hostname:port. Address string `bson:"host"` // Arbiter holds whether the member is an arbiter only. // This value is optional; it defaults to false. Arbiter *bool `bson:"arbiterOnly,omitempty"` // BuildIndexes determines whether the mongod builds indexes on this member. // This value is optional; it defaults to true. BuildIndexes *bool `bson:"buildIndexes,omitempty"` // Hidden determines whether the replica set hides this member from // the output of IsMaster. // This value is optional; it defaults to false. Hidden *bool `bson:"hidden,omitempty"` // Priority determines eligibility of a member to become primary. // This value is optional; it defaults to 1. Priority *float64 `bson:"priority,omitempty"` // Tags store additional information about a replica member, often used for // customizing read preferences and write concern. Tags map[string]string `bson:"tags,omitempty"` // SlaveDelay describes the number of seconds behind the master that this // replica set member should lag rounded up to the nearest second. // This value is optional; it defaults to 0. SlaveDelay *time.Duration `bson:"slaveDelay,omitempty"` // Votes controls the number of votes a server has in a replica set election. // This value is optional; it defaults to 1. Votes *int `bson:"votes,omitempty"` }
Member holds configuration information for a replica set member.
See http://docs.mongodb.org/manual/reference/replica-configuration/ for more details
type MemberState ¶
type MemberState int
MemberState represents the state of a replica set member. See http://docs.mongodb.org/manual/reference/replica-states/
func (MemberState) String ¶
func (state MemberState) String() string
String returns a string describing the state.
type MemberStatus ¶
type MemberStatus struct { // Id holds the replica set id of the member that the status is describing. Id int `bson:"_id"` // Address holds address of the member that the status is describing. Address string `bson:"name"` // Self holds whether this is the status for the member that // the session is connected to. Self bool `bson:"self"` // ErrMsg holds the most recent error or status message received // from the member. ErrMsg string `bson:"errmsg"` // Healthy reports whether the member is up. It is true for the // member that the request was made to. Healthy bool `bson:"health"` // State describes the current state of the member. State MemberState `bson:"state"` // Uptime describes how long the member has been online. Uptime time.Duration `bson:"uptime"` // Ping describes the length of time a round-trip packet takes to travel // between the remote member and the local instance. It is zero for the // member that the session is connected to. Ping time.Duration `bson:"pingMS"` }
Status holds the status of a replica set member returned from replSetGetStatus.
type Status ¶
type Status struct { Name string `bson:"set"` Members []MemberStatus `bson:"members"` }
Status holds data about the status of members of the replica set returned from replSetGetStatus
See http://docs.mongodb.org/manual/reference/command/replSetGetStatus/#dbcmd.replSetGetStatus