Documentation ¶
Overview ¶
Package store defines types to implement a store.
Package store defines types to implement a store.
Index ¶
Constants ¶
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 { SegmentReader LinkWriter EvidenceStore // Returns arbitrary information about the adapter. GetInfo() (interface{}, error) // Adds a channel that receives events from the store. AddStoreEventChannel(chan *Event) // Creates a new Batch NewBatch() (Batch, error) }
Adapter is the minimal interface that all stores should implement. Then a store may optionally implement the KeyValueStore interface.
type Batch ¶
type Batch interface { SegmentReader LinkWriter // Write definitely writes the content of the Batch Write() error }
Batch represents a database transaction.
type Event ¶ added in v0.2.0
type Event struct { EventType EventType Data interface{} }
Event is the object stores send to notify of important events.
func NewSavedEvidences ¶ added in v0.2.0
func NewSavedEvidences() *Event
NewSavedEvidences creates a new event to notify evidences were saved.
func NewSavedLinks ¶ added in v0.2.0
NewSavedLinks creates a new event to notify links were saved.
func (*Event) AddSavedEvidence ¶ added in v0.2.0
AddSavedEvidence adds an evidence to the event. It assumes the event is a correctly initialized SavedEvidences event.
func (*Event) AddSavedLinks ¶ added in v0.2.0
AddSavedLinks adds links to the event. It assumes the event is a correctly initialized SavedLinks event.
func (*Event) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON does custom deserialization to correctly type the Data field.
type EventType ¶ added in v0.2.0
type EventType string
EventType lets you know the kind of event received. A client should ignore events it doesn't care about or doesn't understand.
const ( // SavedLinks means that segment links were saved. SavedLinks EventType = "SavedLinks" // SavedEvidences means that segment evidences were saved. SavedEvidences = "SavedEvidences" )
type EvidenceReader ¶ added in v0.2.0
type EvidenceReader interface { // Get the evidences for a segment. // Can return a nil error with an empty evidence slice if // the segment currently doesn't have evidence. GetEvidences(linkHash *types.Bytes32) (*cs.Evidences, error) }
EvidenceReader is the interface for reading segment evidence from a store.
type EvidenceStore ¶ added in v0.2.0
type EvidenceStore interface { EvidenceReader EvidenceWriter }
EvidenceStore is the interface for storing and reading segment evidence.
type EvidenceWriter ¶ added in v0.2.0
type EvidenceWriter interface { // Add an evidence to a segment. AddEvidence(linkHash *types.Bytes32, evidence *cs.Evidence) error }
EvidenceWriter is the interface for adding evidence to a segment in a store.
type KeyValueReader ¶ added in v0.2.0
KeyValueReader is the interface for reading key-value pairs.
type KeyValueStore ¶ added in v0.2.0
type KeyValueStore interface { KeyValueReader KeyValueWriter }
KeyValueStore is the interface for a key-value store. Some stores will implement this interface, but not all.
type KeyValueWriter ¶ added in v0.2.0
type KeyValueWriter interface { SetValue(key []byte, value []byte) error DeleteValue(key []byte) ([]byte, error) }
KeyValueWriter is the interface for writing key-value pairs.
type LinkWriter ¶ added in v0.2.0
type LinkWriter interface { // Create the immutable part of a segment. // The input link is expected to be valid. // Returns the link hash or an error. CreateLink(link *cs.Link) (*types.Bytes32, error) }
LinkWriter is the interface for writing links to a store. Links are immutable and cannot be deleted.
type MapFilter ¶
type MapFilter struct { Pagination `json:"pagination"` // Process name is optionnal. Process string `json:"process" url:"-"` }
MapFilter contains filtering options for segments.
type Pagination ¶
type Pagination struct { // Index of the first entry. Offset int `json:"offset" url:"offset"` // Maximum number of entries. Limit int `json:"limit" url:"limit"` }
Pagination contains pagination options.
func (*Pagination) PaginateSegments ¶
func (p *Pagination) PaginateSegments(a cs.SegmentSlice) cs.SegmentSlice
PaginateSegments paginate a list of segments
func (*Pagination) PaginateStrings ¶
func (p *Pagination) PaginateStrings(a []string) []string
PaginateStrings paginates a list of strings
type SegmentFilter ¶
type SegmentFilter struct { Pagination `json:"pagination"` // Map IDs the segments must have. MapIDs []string `json:"mapIds" url:"mapIds,brackets"` // Process name is optionnal. Process string `json:"process" url:"-"` // A previous link hash the segments must have. // nil makes this attribute as optional // empty string is to search Segments without parent PrevLinkHash *string `json:"prevLinkHash" url:"prevLinkHash"` // A slice of linkHashes to search Segments. // This attribute is optional. LinkHashes []string `json:"linkHashes" url:"linkHashes,brackets"` // A slice of tags the segments must all contain. Tags []string `json:"tags" url:"tags,brackets"` }
SegmentFilter 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 SegmentReader ¶ added in v0.2.0
type SegmentReader interface { // Get a segment by link hash. Returns nil if no match is found. // Will return link and evidences (if there are some in that store). GetSegment(linkHash *types.Bytes32) (*cs.Segment, error) // Find segments. Returns an empty slice if there are no results. // Will return links and evidences (if there are some). FindSegments(filter *SegmentFilter) (cs.SegmentSlice, error) // Get all the existing map IDs. GetMapIDs(filter *MapFilter) ([]string, error) }
SegmentReader is the interface for reading Segments from a store.
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. |