peergrouper

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitiateMongoServer

func InitiateMongoServer(p InitiateMongoParams) error

InitiateMongoServer checks for an existing mongo configuration. If no existing configuration is found one is created using Initiate.

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a peergrouper.

func New

func New(config Config) (worker.Worker, error)

New returns a new worker that maintains the mongo replica set with respect to the given state.

Types

type APIHostPortsSetter

type APIHostPortsSetter interface {
	SetAPIHostPorts([][]network.HostPort) error
}

type CachingAPIHostPortsSetter

type CachingAPIHostPortsSetter struct {
	APIHostPortsSetter
	// contains filtered or unexported fields
}

CachingAPIHostPortsSetter is an APIHostPortsSetter that caches the most recently set values, suppressing further calls to the underlying setter if any call's arguments match those of the preceding call.

func (*CachingAPIHostPortsSetter) SetAPIHostPorts

func (s *CachingAPIHostPortsSetter) SetAPIHostPorts(apiServers [][]network.HostPort) error

type Config

type Config struct {
	State              State
	APIHostPortsSetter APIHostPortsSetter
	MongoSession       MongoSession
	Clock              clock.Clock
	SupportsSpaces     bool
	MongoPort          int
	APIPort            int
	ControllerAPIPort  int

	// Hub is the central hub of the apiserver,
	// and is used to publish the details of the
	// API servers.
	Hub Hub
}

Config holds the configuration for a peergrouper worker.

func (Config) Validate

func (config Config) Validate() error

Validate validates the worker configuration.

type Hub

type Hub interface {
	Subscribe(topic string, handler interface{}) (func(), error)
	Publish(topic string, data interface{}) (<-chan struct{}, error)
}

Hub defines the methods of the apiserver centralhub that the peer grouper uses.

type InitiateMongoParams

type InitiateMongoParams struct {
	// DialInfo specifies how to connect to the mongo server.
	DialInfo *mgo.DialInfo

	// MemberHostPort provides the address to use for
	// the first replica set member.
	MemberHostPort string

	// User holds the user to log as in to the mongo server.
	// If it is empty, no login will take place.
	User     string
	Password string
}

InitiateMongoParams holds parameters for the MaybeInitiateMongo call.

type Machine

type Machine interface {
	Id() string
	Life() state.Life
	Status() (status.StatusInfo, error)
	SetStatus(status.StatusInfo) error
	Refresh() error
	Watch() state.NotifyWatcher
	WantsVote() bool
	HasVote() bool
	SetHasVote(hasVote bool) error
	Addresses() []network.Address
}

type ManifoldConfig

type ManifoldConfig struct {
	AgentName                string
	ClockName                string
	ControllerPortName       string
	StateName                string
	Hub                      Hub
	NewWorker                func(Config) (worker.Worker, error)
	ControllerSupportsSpaces func(*state.State) (bool, error)
}

ManifoldConfig holds the information necessary to run a peergrouper in a dependency.Engine.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate validates the manifold configuration.

type MongoSession

type MongoSession interface {
	CurrentStatus() (*replicaset.Status, error)
	CurrentMembers() ([]replicaset.Member, error)
	Set([]replicaset.Member) error
	StepDownPrimary() error
	Refresh()
}

type MongoSessionShim

type MongoSessionShim struct {
	*mgo.Session
}

MongoSessionShim wraps a *mgo.Session to conform to the MongoSession interface.

func (MongoSessionShim) CurrentMembers

func (s MongoSessionShim) CurrentMembers() ([]replicaset.Member, error)

func (MongoSessionShim) CurrentStatus

func (s MongoSessionShim) CurrentStatus() (*replicaset.Status, error)

func (MongoSessionShim) Refresh

func (s MongoSessionShim) Refresh()

func (MongoSessionShim) Set

func (s MongoSessionShim) Set(members []replicaset.Member) error

func (MongoSessionShim) StepDownPrimary

func (s MongoSessionShim) StepDownPrimary() error

type Space

type Space interface {
	Name() string
}

type State

type State interface {
	RemoveControllerMachine(m Machine) error
	ControllerConfig() (controller.Config, error)
	ControllerInfo() (*state.ControllerInfo, error)
	Machine(id string) (Machine, error)
	WatchControllerInfo() state.NotifyWatcher
	WatchControllerStatusChanges() state.StringsWatcher
	WatchControllerConfig() state.NotifyWatcher
}

type StateShim

type StateShim struct {
	*state.State
}

func (StateShim) Machine

func (s StateShim) Machine(id string) (Machine, error)

func (StateShim) RemoveControllerMachine

func (s StateShim) RemoveControllerMachine(m Machine) error

func (StateShim) Space

func (s StateShim) Space(name string) (Space, error)

Jump to

Keyboard shortcuts

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