Documentation
¶
Index ¶
- Variables
- func NewStorageController(store Interface, spec usher.Spec) usher.Controller
- type ByParents
- type ByState
- type ByTags
- type Interface
- type StorageController
- func (sc *StorageController) Create(obj usher.Object) (*usher.Object, *usher.Error)
- func (sc *StorageController) Delete(id usher.ObjectID) (*usher.Object, *usher.Error)
- func (sc *StorageController) Exists(id usher.ObjectID) *usher.Error
- func (sc *StorageController) Get(id usher.ObjectID) (*usher.Object, *usher.Error)
- func (sc *StorageController) GetAll(query usher.Query) (*[]usher.Object, *usher.Error)
- func (sc *StorageController) PartialUpdate(id usher.ObjectID, updates []usher.UpdateClause) (*usher.Object, *usher.Error)
- func (sc *StorageController) Update(id usher.ObjectID, newObject usher.Object) (*usher.Object, *usher.Error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknownClause = errors.New("unknown clause")
ErrUnknownClause is returned when the update clause is not known.
Functions ¶
func NewStorageController ¶
func NewStorageController(store Interface, spec usher.Spec) usher.Controller
NewStorageController initializes a StorageController with given 'store' as the storage backend. If 'spec' is not nil, it will be assumed to be the type for `obj.Spec` field and type assertion will be done before reading.
Types ¶
type ByParents ¶
type ByParents struct {
Parents usher.ParentRefs
}
ByParents is used to filter results by parents.
type ByState ¶
type ByState struct {
State string
}
ByState is used to filter results based on state
type Interface ¶
type Interface interface {
// Get should populate `obj` with data in the first object that
// exactly and completely matches the `id`. If no object found,
// return value should be 404.
Get(obj *usher.Object, id usher.ObjectID) *usher.Error
// GetLatest should get the latest object matches all the query clauses
// specified as `[]qa`. If no object found, return value should be 404.
GetLatest(obj *usher.Object, kind string, qa ...interface{}) *usher.Error
// GetAll should get all objects of given 'kind' matching all clauses
// from 'qa'. If not object found, return value should be nil and `objList`
// should be empty slice.
GetAll(objList *[]usher.Object, kind string, qa ...interface{}) *usher.Error
// Exists should return true if an object with the given `id` exists in the
// storage.
Exists(id usher.ObjectID) *usher.Error
// Delete should delete the object identified by the `id` and populate `obj`
// with the data from the deleted object.
Delete(obj *usher.Object, id usher.ObjectID) *usher.Error
// Update should apply ALL the updates provided as slice of 'UpdateClause'
// to the object identified by the `id`. Finally, the 'obj' pointer must
// point to the updated object.
Update(obj *usher.Object, id usher.ObjectID, updates []usher.UpdateClause) *usher.Error
// Create should Store the 'obj' into the Store as-is. Timestamps should be
// set to the time at which the Store committed the object to backend.
Create(obj *usher.Object) *usher.Error
}
Interface can be implemented to provide easy storage for Usher.
type StorageController ¶
type StorageController struct {
// Store to be used for storing objects
Store Interface
// Type of the 'spec' field (used only for validation
Type reflect.Type
}
StorageController is a basic implementation of Usher Controller with storage support.
func (*StorageController) Exists ¶
func (sc *StorageController) Exists(id usher.ObjectID) *usher.Error
func (*StorageController) PartialUpdate ¶
func (sc *StorageController) PartialUpdate(id usher.ObjectID, updates []usher.UpdateClause) (*usher.Object, *usher.Error)
Click to show internal directories.
Click to hide internal directories.