store

package
v0.0.1-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package store defines types to implement a store.

Index

Constants

View Source
const (
	// DefaultLimit is the default pagination limit.
	DefaultLimit = 20

	// MaxLimit is the maximum pagination limit.
	MaxLimit = 200
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	// Returns arbitrary information about the adapter.
	GetInfo() (interface{}, error)

	// Creates or updates a segment. Segments passed to this method are
	// assumed to be valid.
	SaveSegment(segment *cs.Segment) error

	// Get a segment by link hash. Returns nil if no match is found.
	GetSegment(linkHash *types.Bytes32) (*cs.Segment, error)

	// Deletes a segment by link hash. Returns the removed segment or nil
	// if not found.
	DeleteSegment(linkHash *types.Bytes32) (*cs.Segment, error)

	// Find segments. Returns an empty slice if there are no results.
	FindSegments(filter *Filter) (cs.SegmentSlice, error)

	// Get all the existing map IDs.
	GetMapIDs(pagination *Pagination) ([]string, error)
}

Adapter must be implemented by a store.

type Filter

type Filter struct {
	Pagination

	// A map ID the segments must have.
	MapID string

	// A previous link hash the segments must have.
	PrevLinkHash *types.Bytes32

	// A slice of tags the segments must all contain.
	Tags []string
}

Filter contains filtering options for segments. If PrevLinkHash is not nil, MapID is ignored because a previous link hash implies the map ID of the previous segment.

type Pagination

type Pagination struct {
	// Index of the first entry.
	Offset int

	// Maximum number of entries, all if zero.
	Limit int
}

Pagination contains pagination options.

Directories

Path Synopsis
Package storehttp is used to create an HTTP server from a store adapter.
Package storehttp is used to create an HTTP server from a store adapter.
Package storetestcases defines test cases to test stores.
Package storetestcases defines test cases to test stores.
Package storetesting defines helpers to test stores.
Package storetesting defines helpers to test stores.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL