Documentation
¶
Index ¶
- Variables
- type Database
- type DatabaseType
- type Goba
- func (g Goba) AllImages(typ DatabaseType) ([]Image, error)
- func (g Goba) ApplyImage(typ DatabaseType, name string) error
- func (g Goba) CreateImage(typ DatabaseType) (*Image, error)
- func (g Goba) DeleteImage(typ DatabaseType, name string) error
- func (g Goba) FindImage(typ DatabaseType, name string) (*Image, error)
- type Image
- type ImageHandler
- func (h ImageHandler) AllImages() ([]Image, error)
- func (h ImageHandler) ApplyImage(name string) error
- func (h ImageHandler) CreateImage() (*Image, error)
- func (h ImageHandler) DeleteImage(name string) error
- func (h ImageHandler) FindImage(name string) (*Image, error)
- func (h ImageHandler) Type() DatabaseType
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrNoSuchHandler = errors.New("no such handler")
ErrNoSuchHandler occurs whenever Goba could not find a handler for some DatabaseType.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface {
// Type returns the Database's type.
Type() DatabaseType
// CreateImage returns an Image containing the Database's current state.
CreateImage() (*Image, error)
// ApplyImage applies the given Image to the Database.
ApplyImage(image Image) error
}
A Database represents a collection of data.
type Goba ¶
type Goba struct {
// contains filtered or unexported fields
}
Goba manages a collection of image handlers and acts as the main interface of the application.
func New ¶
func New(handlers ...ImageHandler) *Goba
New creates a new Goba managing the given handlers.
func (Goba) AllImages ¶
func (g Goba) AllImages(typ DatabaseType) ([]Image, error)
AllImages retrieves all images with the given type.
func (Goba) ApplyImage ¶
func (g Goba) ApplyImage(typ DatabaseType, name string) error
ApplyImage applies the Image with the given name to the Database with the given type.
func (Goba) CreateImage ¶
func (g Goba) CreateImage(typ DatabaseType) (*Image, error)
CreateImage creates a new Image of the Database with the given type.
func (Goba) DeleteImage ¶
func (g Goba) DeleteImage(typ DatabaseType, name string) error
DeleteImage deletes the Image with the given type and name.
type Image ¶
type Image struct {
// Type is the type of the Database that created the Image.
Type DatabaseType `json:"type,omitempty"`
// Name is the name of the Image.
Name string `json:"name,omitempty"`
// Content represents the Database's state.
Content []byte `json:"content,omitempty"`
}
An Image represents the current state of some Database.
type ImageHandler ¶
An ImageHandler combines a Database with a Store to ensure that any images created by that Database are submitted to the store and that an Image can be loaded into the Database by name.
func (ImageHandler) AllImages ¶
func (h ImageHandler) AllImages() ([]Image, error)
AllImages retrieves all images from h's Store.
func (ImageHandler) ApplyImage ¶
func (h ImageHandler) ApplyImage(name string) error
ApplyImage retrieves the Image with the given name from h's Store and applies it to h's Database.
func (ImageHandler) CreateImage ¶
func (h ImageHandler) CreateImage() (*Image, error)
CreateImage creates a new Image of h's Database, submits it to h's Store and returns it.
func (ImageHandler) DeleteImage ¶
func (h ImageHandler) DeleteImage(name string) error
DeleteImage deletes the Image with the given name from h's Store.
func (ImageHandler) FindImage ¶
func (h ImageHandler) FindImage(name string) (*Image, error)
FindImage retrieves the Image with given name from h's Store.
func (ImageHandler) Type ¶
func (h ImageHandler) Type() DatabaseType
Type returns the type of h's Database.
type Store ¶
type Store interface {
// SaveImage saves the given Image. If an Image with the
// given Image's name already exists, SaveImage should
// return a non-nil error.
SaveImage(image Image) error
// FindImage retrieves an Image with the given name.
// If no such Image exists, FindImage should return
// a non-nil error.
FindImage(name string) (*Image, error)
// AllImages retrieves all images known to the Store.
// If there are no images to retrieve, AllImages should
// be a no-op.
AllImages() ([]Image, error)
// DeleteImage deletes the Image with the given name.
// If no such Image exists, DeleteImage should be a no-op.
DeleteImage(name string) error
}
A Store manages database images.