Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrReversion is an error returned when an attempt to revert to a // previous version is detected. This is done to provide safety to users // as some upgrades may not be backwards-compatible. ErrReversion = errors.New("reverting to a previous version is not " + "supported") )
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func GetLatestVersion ¶
GetLatestVersion returns the latest version available from the given slice.
func Upgrade ¶
Upgrade attempts to upgrade a group of services exposed through the Manager interface. Each service will go through its available versions and determine whether it needs to apply any.
NOTE: In order to guarantee fault-tolerance, each service upgrade should happen within the same database transaction.
Types ¶
type Manager ¶
type Manager interface { // Name returns the name of the service we'll be attempting to upgrade. Name() string // Namespace returns the top-level bucket of the service. Namespace() walletdb.ReadWriteBucket // CurrentVersion returns the current version of the service's database. CurrentVersion(walletdb.ReadBucket) (uint32, error) // SetVersion sets the version of the service's database. SetVersion(walletdb.ReadWriteBucket, uint32) error // Versions returns all of the available database versions of the // service. Versions() []Version }
Manager is an interface that exposes the necessary methods needed in order to migrate/upgrade a service. Each service (i.e., an implementation of this interface) can then use the Upgrade function to perform any required database migrations.
type Version ¶
type Version struct { // Number represents the number of this version. Number uint32 // Migration represents a migration function that modifies the database // state. Care must be taken so that consequent migrations build off of // the previous one in order to ensure the consistency of the database. Migration func(walletdb.ReadWriteBucket) error }
Version denotes the version number of the database. A migration can be used to bring a previous version of the database to a later one.
func VersionsToApply ¶
VersionsToApply determines which versions should be applied as migrations based on the current version.