Documentation
¶
Overview ¶
Package startup of the Tideland Go CouchDB Client provides a simple mechanism for a clean startup and maintenance of CouchDB databases.
The major function is
err := startup.Run(cdb, stepA, stepB, stepC)
Here cdb is the opened CouchDB and the steps is a variadic number of functions having the signature
func(cdb couchdb.CouchDB, v version.Version) (version.Version, error)
When Run() is called it first checks if the database already exists and if needed creates it. Then it adds a version document with the version 0.0.0. Now each step is called in order with the current version. It can check if it has to modify the database (e.g. add design and other document, add fields to existing documents, transform documents, etc.), perform those changes, and return the new version. So the version document will be updated and the next step performed.
Index ¶
Constants ¶
const ( ErrIllegalVersion = iota + 1 ErrStartupActionFailed )
Error codes.
const DatabaseVersionID = "database-version"
DatabaseVersionID is used for the database version document.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DatabaseVersion ¶
type DatabaseVersion struct { ID string `json:"_id"` Revision string `json:"_rev,omitempty"` Version string `json:"version"` }
DatabaseVersion stores the current database version with the document ID "database-version".
type Step ¶
type Step func() (version.Version, StepAction)
Step returns the version after a startup step and the action that shall be performed on the database. The returned action will only be performed, if the current if the new version is than the current version.
type StepAction ¶
StepAction is the concrete action of a step.