Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type MetadataStore ¶
type MetadataStore interface {
// Create the metadata containing the passed in data with the
// specified id.
// Note:
// * Create MUST return error if the id already exists.
// * The id and data MUST be added in one transaction to the store.
Create(string, []byte) error
// Get the data by id.
// Note that Get MUST return ErrNotExist if the id doesn't exist.
Get(string) ([]byte, error)
// Update the data by id.
// Note:
// * Update MUST return ErrNotExist is the id doesn't exist.
// * The update MUST be applied in one transaction.
Update(string, UpdateFunc) error
// List returns entire array of data from the store.
List() ([][]byte, error)
// Delete the data by id.
// Note:
// * Delete should be idempotent, it MUST not return error if the id
// doesn't exist or has been removed.
// * The id and data MUST be deleted in one transaction.
Delete(string) error
}
MetadataStore is the interface for storing metadata. All methods should be thread-safe. TODO(random-liu): Initialize the metadata store with a type, and replace []byte with interface{}, so as to avoid extra marshal/unmarshal on the user side.
func NewMetadataStore ¶
func NewMetadataStore() MetadataStore
NewMetadataStore creates a MetadataStore.
type UpdateFunc ¶
UpdateFunc is function used to update a specific metadata. The value passed in is the old value, it MUST NOT be changed in the function. The function should make a copy of the old value and apply update on the copy. The updated value should be returned. If there is an error, the update will be rolled back.
Source Files
¶
- metadata_store.go
Click to show internal directories.
Click to hide internal directories.