Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExistsError ¶
type ExistsError struct {
ID ID
}
ExistsError is returned when CreateTake is attempted with an existing ID.
func (*ExistsError) Error ¶
func (e *ExistsError) Error() string
type NotFoundError ¶
type NotFoundError struct {
ID ID
}
NotFoundError is returned when a Storage method fails to find a take.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Storage ¶
type Storage interface { // ListTakes returns a sorted list of all takes in the storage. // The returned takes should not be modified. ListTakes() ([]*Take, error) // GetTake retrieves a take with the given ID. // The returned takes should not be modified. GetTake(id ID) (*Take, error) // InsertTake adds a new take. InsertTake(take *Take) error // UpdateTake updates an existing take. UpdateTake(id ID, take *Take) error // DeleteTake deletes a single take. DeleteTake(id ID) error // Close flushes the storage to disk. Close() error }
Storage provides a database of takes. Calls to ListTakes and GetTake from multiple goroutines are safe, as long as they do not happen concurrently any other calls.
func NewCSVStorage ¶
func NewCSVStorage(rw io.ReadWriter) (Storage, error)
NewCSVStorage creates a CSV-file-backed storage from rw. rw is first read to get the initial contents, then mutations are written afterward. No attempt is made to deduplicate records.
func NewMemoryStorage ¶
func NewMemoryStorage() Storage
NewMemoryStorage returns a new in-memory storage.
Click to show internal directories.
Click to hide internal directories.