Documentation ¶
Overview ¶
Package store is an interface for distributed data storage. The design document is located at https://github.com/micro/development/blob/master/design/store.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeleteOption ¶ added in v2.3.0
type DeleteOption func(d *DeleteOptions)
DeleteOption sets values in DeleteOptions
func DeleteFrom ¶ added in v2.5.0
func DeleteFrom(database, table string) DeleteOption
DeleteFrom the database and table
type DeleteOptions ¶ added in v2.3.0
type DeleteOptions struct {
Database, Table string
}
DeleteOptions configures an individual Delete operation
type ListOption ¶ added in v2.3.0
type ListOption func(l *ListOptions)
ListOption sets values in ListOptions
func ListFrom ¶ added in v2.5.0
func ListFrom(database, table string) ListOption
ListFrom the database and table
func ListLimit ¶ added in v2.3.0
func ListLimit(l uint) ListOption
ListLimit limits the number of returned keys to l
func ListOffset ¶ added in v2.3.0
func ListOffset(o uint) ListOption
ListOffset starts returning responses from o. Use in conjunction with Limit for pagination.
func ListPrefix ¶ added in v2.3.0
func ListPrefix(p string) ListOption
ListPrefix returns all keys that are prefixed with key
func ListSuffix ¶ added in v2.3.0
func ListSuffix(s string) ListOption
ListSuffix returns all keys that end with key
type ListOptions ¶ added in v2.3.0
type ListOptions struct {
// List from the following
Database, Table string
// Prefix returns all keys that are prefixed with key
Prefix string
// Suffix returns all keys that end with key
Suffix string
// Limit limits the number of returned keys
Limit uint
// Offset when combined with Limit supports pagination
Offset uint
}
ListOptions configures an individual List operation
type Option ¶
type Option func(o *Options)
Option sets values in Options
func Database ¶ added in v2.5.0
Database allows multiple isolated stores to be kept in one backend, if supported.
func Nodes ¶
Nodes contains the addresses or other connection information of the backing storage. For example, an etcd implementation would contain the nodes of the cluster. A SQL implementation could contain one or more connection strings.
func Table ¶ added in v2.5.0
Table is analagous to a table in database backends or a key prefix in KV backends
func WithClient ¶ added in v2.7.0
WithClient sets the stores client to use for RPC
func WithContext ¶ added in v2.3.0
WithContext sets the stores context, for any extra configuration
type Options ¶
type Options struct { // Nodes contains the addresses or other connection information of the backing storage. // For example, an etcd implementation would contain the nodes of the cluster. // A SQL implementation could contain one or more connection strings. Nodes []string // Database allows multiple isolated stores to be kept in one backend, if supported. Database string // Table is analagous to a table in database backends or a key prefix in KV backends Table string // Context should contain all implementation specific options, using context.WithValue. Context context.Context // Client to use for RPC Client client.Client }
Options contains configuration for the Store
type ReadOption ¶
type ReadOption func(r *ReadOptions)
ReadOption sets values in ReadOptions
func ReadFrom ¶ added in v2.5.0
func ReadFrom(database, table string) ReadOption
ReadFrom the database and table
func ReadLimit ¶ added in v2.3.0
func ReadLimit(l uint) ReadOption
ReadLimit limits the number of responses to l
func ReadOffset ¶ added in v2.3.0
func ReadOffset(o uint) ReadOption
ReadOffset starts returning responses from o. Use in conjunction with Limit for pagination
func ReadPrefix ¶
func ReadPrefix() ReadOption
ReadPrefix returns all records that are prefixed with key
func ReadSuffix ¶ added in v2.1.0
func ReadSuffix() ReadOption
ReadSuffix returns all records that have the suffix key
type ReadOptions ¶
type ReadOptions struct {
Database, Table string
// Prefix returns all records that are prefixed with key
Prefix bool
// Suffix returns all records that have the suffix key
Suffix bool
// Limit limits the number of returned records
Limit uint
// Offset when combined with Limit supports pagination
Offset uint
}
ReadOptions configures an individual Read operation
type Record ¶
type Record struct { // The key to store the record Key string `json:"key"` // The value within the record Value []byte `json:"value"` // Any associated metadata for indexing Metadata map[string]interface{} `json:"metadata"` // Time to expire a record: TODO: change to timestamp Expiry time.Duration `json:"expiry,omitempty"` }
Record is an item stored or retrieved from a Store
type Store ¶
type Store interface { // Init initialises the store. It must perform any required setup on the backing storage implementation and check that it is ready for use, returning any errors. Init(...Option) error // Options allows you to view the current options. Options() Options // Read takes a single key name and optional ReadOptions. It returns matching []*Record or an error. Read(key string, opts ...ReadOption) ([]*Record, error) // Write() writes a record to the store, and returns an error if the record was not written. Write(r *Record, opts ...WriteOption) error // Delete removes the record with the corresponding key from the store. Delete(key string, opts ...DeleteOption) error // List returns any keys that match, or an empty list with no error if none matched. List(opts ...ListOption) ([]string, error) // Close the store Close() error // String returns the name of the implementation. String() string }
Store is a data storage interface
type WriteOption ¶ added in v2.3.0
type WriteOption func(w *WriteOptions)
WriteOption sets values in WriteOptions
func WriteExpiry ¶ added in v2.3.0
func WriteExpiry(t time.Time) WriteOption
WriteExpiry is the time the record expires
func WriteTTL ¶ added in v2.3.0
func WriteTTL(d time.Duration) WriteOption
WriteTTL is the time the record expires
func WriteTo ¶ added in v2.5.0
func WriteTo(database, table string) WriteOption
WriteTo the database and table
type WriteOptions ¶ added in v2.3.0
type WriteOptions struct {
Database, Table string
// Expiry is the time the record expires
Expiry time.Time
// TTL is the time until the record expires
TTL time.Duration
}
WriteOptions configures an individual Write operation If Expiry and TTL are set TTL takes precedence
Directories ¶
Path | Synopsis |
---|---|
Package cache implements a faulting style read cache on top of multiple micro stores
|
Package cache implements a faulting style read cache on top of multiple micro stores |
Package cockroach implements the cockroach store
|
Package cockroach implements the cockroach store |
Package local is a file system backed store
|
Package local is a file system backed store |
Package memory is a in-memory store store
|
Package memory is a in-memory store store |
Package service implements the store service interface
|
Package service implements the store service interface |