mongo

package
v0.0.0-...-732aecd Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2014 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SharedSecretFile is the name of the Mongo shared secret file
	// located within the Juju data directory.
	SharedSecretFile = "shared-secret"

	// ReplicaSetName is the name of the replica set that juju uses for its
	// state servers.
	ReplicaSetName = "juju"
)
View Source
const (
	// WithHA is used when we want to start a mongo service with HA support.
	WithHA = true
	// WithoutHA is used when we want to start a mongo service without HA support.
	WithoutHA = false
)

Variables

View Source
var (

	// JujuMongodPath holds the default path to the juju-specific mongod.
	JujuMongodPath = "/usr/lib/juju/bin/mongod"
)

Functions

func EnsureAdminUser

func EnsureAdminUser(p EnsureAdminUserParams) (added bool, err error)

EnsureAdminUser ensures that the specified user and password are added to the admin database.

This function will stop the Mongo service if it needs to add the admin user, as it must restart Mongo in --noauth mode.

func EnsureServer

func EnsureServer(dataDir string, namespace string, info params.StateServingInfo, withHA bool) error

EnsureMongoServer ensures that the correct mongo upstart script is installed and running.

This method will remove old versions of the mongo upstart script as necessary before installing the new version.

The namespace is a unique identifier to prevent multiple instances of mongo on this machine from colliding. This should be empty unless using the local provider.

func GenerateSharedSecret

func GenerateSharedSecret() (string, error)

GenerateSharedSecret generates a pseudo-random shared secret (keyfile) for use with Mongo replica sets.

func IsMaster

func IsMaster(session *mgo.Session, obj WithAddresses) (bool, error)

IsMaster returns a boolean that represents whether the given machine's peer address is the primary mongo host for the replicaset

func Path

func Path() (string, error)

Path returns the executable path to be used to run mongod on this machine. If the juju-bundled version of mongo exists, it will return that path, otherwise it will return the command to run mongod from the path.

func RemoveService

func RemoveService(namespace string) error

RemoveService removes the mongoDB upstart service from this machine.

func SelectPeerAddress

func SelectPeerAddress(addrs []instance.Address) string

SelectPeerAddress returns the address to use as the mongo replica set peer address by selecting it from the given addresses.

func SelectPeerHostPort

func SelectPeerHostPort(hostPorts []instance.HostPort) string

SelectPeerHostPort returns the HostPort to use as the mongo replica set peer by selecting it from the given hostPorts.

func ServiceName

func ServiceName(namespace string) string

ServiceName returns the name of the upstart service config for mongo using the given namespace.

Types

type EnsureAdminUserParams

type EnsureAdminUserParams struct {
	// DialInfo specifies how to connect to the mongo server.
	DialInfo *mgo.DialInfo
	// Namespace is the agent namespace, used to derive the Mongo service name.
	Namespace string
	// DataDir is the Juju data directory, used to start a --noauth server.
	DataDir string
	// Port is the listening port of the Mongo server.
	Port int
	// User holds the user to log in to the mongo server as.
	User string
	// Password holds the password for the user to log in as.
	Password string
}

type WithAddresses

type WithAddresses interface {
	Addresses() []instance.Address
}

WithAddresses represents an entity that has a set of addresses. e.g. a state Machine object

Jump to

Keyboard shortcuts

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