Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Manifold ¶
func Manifold(cfg ManifoldConfig) dependency.Manifold
Manifold returns a dependency manifold that runs a database upgrade worker using the resource names defined in the supplied config.
Types ¶
type Clock ¶
type Clock interface {
// After waits for the duration to elapse and then sends the
// current time on the returned channel.
After(time.Duration) <-chan time.Time
}
Clock provides an interface for dealing with clocks.
type Config ¶
type Config struct {
// UpgradeComplete is a lock used to synchronise workers that must start
// after database upgrades are verified as completed.
UpgradeComplete gate.Lock
// Tag is the current machine tag.
Tag names.Tag
// agent is the running machine agent.
Agent agent.Agent
// Logger is the logger for this worker.
Logger Logger
// Open state is a function pointer for returning a state pool indirection.
OpenState func() (Pool, error)
// PerformUpgrade is a function pointer for executing the DB upgrade steps.
// Context retrieval is lazy because because it requires a real
// state.StatePool that we cast our Pool indirection back to.
// We need the concrete type, because we are unable to indirect all the
// state methods that upgrade steps might require.
// This is OK for in-theatre operation, but is not suitable for testing.
PerformUpgrade func(version.Number, []upgrades.Target, func() upgrades.Context) error
// RetryStrategy is the strategy to use for re-attempting failed upgrades.
RetryStrategy utils.AttemptStrategy
// Clock is used to enforce time-out logic for controllers waiting for the
// master MongoDB upgrades to execute.
Clock Clock
}
Config is the configuration needed to construct an upgradeDB worker.
type Logger ¶
type Logger interface {
Debugf(message string, args ...interface{})
Infof(message string, args ...interface{})
Errorf(message string, args ...interface{})
}
Logger represents the methods required to emit log messages.
type ManifoldConfig ¶
type ManifoldConfig struct {
AgentName string
UpgradeDBGateName string
Logger Logger
OpenState func() (*state.StatePool, error)
Clock Clock
}
ManifoldConfig defines the configuration on which this manifold depends.
func (ManifoldConfig) Validate ¶
func (cfg ManifoldConfig) Validate() error
Validate returns an error if the manifold config is not valid.
type Pool ¶
type Pool interface {
// IsPrimary returns true if the Mongo primary is
// running on the machine with the input ID.
IsPrimary(string) (bool, error)
// SetStatus updates the status of the machine with the input ID.
SetStatus(string, status.Status, string) error
// EnsureUpgradeInfo ensures that a document exists in the "upgradeInfo"
// collection for coordinating the current upgrade.
EnsureUpgradeInfo(string, version.Number, version.Number) (UpgradeInfo, error)
// Close closes the state pool.
Close() error
}
Pool describes methods required by the upgradeDB worker, supplied by a state pool.
type UpgradeInfo ¶
type UpgradeInfo interface {
// Status returns the current status of the upgrade.
Status() state.UpgradeStatus
// SetStatus sets the current status of the upgrade.
SetStatus(status state.UpgradeStatus) error
// Watch returns a watcher that notifies of changes to the UpgradeInfo.
Watch() state.NotifyWatcher
// Refresh refreshes the UpgradeInfo from state.
Refresh() error
}
UpgradeInfo describes methods for working with the state representation of an upgrade-in-progress.
Click to show internal directories.
Click to hide internal directories.