package store

import "github.com/containerd/cri/pkg/metadata/store"

Index

Variables

var (
	// ErrNotExist is the error returned when specified id does
	// not exist.
	ErrNotExist = errors.New("does not exist")
	// ErrAlreadyExist is the error returned when specified id already
	// exists.
	ErrAlreadyExist = errors.New("already exists")
)

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

type UpdateFunc func([]byte) ([]byte, error)

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

Version
v0.1.0-alpha.1
Published
Jun 22, 2017
Platform
js/wasm
Imports
3 packages
Last checked
4 hours ago

Tools for package owners.