replset

package
v0.0.0-...-a288e68 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongod

type Mongod struct {
	Host    string
	Port    int
	Replset string
	PodName string
	Task    pod.Task
}

func NewMongod

func NewMongod(task pod.Task, podName string) (*Mongod, error)

func (*Mongod) DBConfig

func (m *Mongod) DBConfig(sslCnf *db.SSLConfig) *db.Config

DBConfig returns a direct database connection to a single mongod instance

func (*Mongod) Name

func (m *Mongod) Name() string

Name returns a string representing the host and port of a mongod instance

type Replset

type Replset struct {
	sync.Mutex
	Name string
	// contains filtered or unexported fields
}

func New

func New(config *config.Config, name string) *Replset

func (*Replset) GetMember

func (r *Replset) GetMember(name string) *Mongod

GetMember returns a Mongod structure reflecting a MongoDB mongod instance

func (*Replset) GetMembers

func (r *Replset) GetMembers() map[string]*Mongod

GetMembers returns a map of all mongod instances in a MongoDB Replica Set

func (*Replset) GetReplsetDBConfig

func (r *Replset) GetReplsetDBConfig(sslCnf *db.SSLConfig) *db.Config

GetReplsetDBConfig returns a db.Config for the MongoDB Replica Set

func (*Replset) HasMember

func (r *Replset) HasMember(name string) bool

HasMember returns a boolean reflecting whether or not the state of a MongoDB instance exists in Replica Set

func (*Replset) RemoveMember

func (r *Replset) RemoveMember(name string) error

RemoveMember removes the state of a MongoDB instance from a Replica Set

func (*Replset) UpdateMember

func (r *Replset) UpdateMember(member *Mongod) error

UpdateMember adds/updates the state of a MongoDB instance in a Replica Set

type State

type State struct {
	sync.Mutex
	Replset string
	Config  *rsConfig.Config
	Status  *rsStatus.Status
	// contains filtered or unexported fields
}

State is a struct reflecting the state of a MongoDB Replica Set

func NewState

func NewState(replset string) *State

NewState returns a new State struct

func (*State) AddConfigMembers

func (s *State) AddConfigMembers(session *mgo.Session, configManager rsConfig.Manager, members []*Mongod) error

AddConfigMembers adds members to the MongoDB Replica Set config

func (*State) Fetch

func (s *State) Fetch(session *mgo.Session, configManager rsConfig.Manager) error

Fetch gets the current MongoDB Replica Set status and config while locking the State

func (*State) GetConfig

func (s *State) GetConfig() *rsConfig.Config

GetConfig returns a Config struct representing a MongoDB Replica Set configuration

func (*State) GetStatus

func (s *State) GetStatus() *rsStatus.Status

GetStatus returns a Status struct representing the status of a MongoDB Replica Set

func (*State) RemoveConfigMembers

func (s *State) RemoveConfigMembers(session *mgo.Session, configManager rsConfig.Manager, members []*rsConfig.Member) error

RemoveConfigMembers removes members from the MongoDB Replica Set config

func (*State) VotingMembers

func (s *State) VotingMembers() int

VotingMembers returns the number of replset members with one or more votes

Jump to

Keyboard shortcuts

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