Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrRecordNotFound = errors.New("record not found") ErrRecordAlreadyExists = errors.New("record already exists") )
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory func() Item
Factory interface provides a way to construct the object while returning results in the list method
type IDSetter ¶
type IDSetter interface {
SetID(string)
}
IDSetter interface can be used by the DB to provide new IDs for objects. If Item supports this, when we Create the new item we can set a unique ID based on different DB implementations
type Item ¶
type Item interface {
Serializable
GetNamespace() string
GetID() string
}
Item is a generic object which can be used to interact with the store. Users can create their own 'Item' for using the store
type ItemFilter ¶
type ListOpt ¶
type ListOpt struct {
Page int64
Limit int64
Sort Sort
Version int64
Filter ItemFilter
}
ListOpt provides different options for querying the DB Pagination can be used if supported by underlying DB
type Serializable ¶
Serializable interface for the Items to store/retrieve data to/from DB as bytes
type Sort ¶
type Sort int
Sort is an enum for using different sorting methods on the query
const ( // SortNatural use natural order SortNatural Sort = iota // SortCreatedDesc created newest to oldest SortCreatedDesc // SortCreatedAsc created oldest to newset SortCreatedAsc // SortUpdatedDesc updated newest to oldest SortUpdatedDesc // SortUpdatedAsc updated oldest to newset SortUpdatedAsc )
type Store ¶
type Store interface {
Create(context.Context, Item) error
Read(context.Context, Item) error
Update(context.Context, Item) error
Delete(context.Context, Item) error
List(context.Context, Factory, ListOpt) (<-chan *Result, error)
io.Closer
}
Store is a generic KV Store interface which provides an easier interface to access underlying database. It is mainly used to abstract the database used underneath so we can have a uniform API to use for clients
type TimeTracker ¶
type TimeTracker interface {
SetCreated(t int64)
GetCreated() int64
SetUpdated(t int64)
GetUpdated() int64
}
TimeTracker interface implements basic time tracking functionality for the objects. If Item supports this interface, additional indexes can be maintained to support queries based on this