Documentation
¶
Overview ¶
Package inmemory contains an in-memory implementation of the databroker backend.
Index ¶
- type Backend
- func (backend *Backend) Close() error
- func (backend *Backend) Get(_ context.Context, recordType, id string) (*databroker.Record, error)
- func (backend *Backend) GetAll(_ context.Context) ([]*databroker.Record, *databroker.Versions, error)
- func (backend *Backend) GetOptions(_ context.Context, recordType string) (*databroker.Options, error)
- func (backend *Backend) Put(ctx context.Context, record *databroker.Record) (serverVersion uint64, err error)
- func (backend *Backend) SetOptions(_ context.Context, recordType string, options *databroker.Options) error
- func (backend *Backend) Sync(ctx context.Context, serverVersion, recordVersion uint64) (storage.RecordStream, error)
- type Option
- type RecordCollection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶ added in v0.14.0
type Backend struct {
// contains filtered or unexported fields
}
A Backend stores data in-memory.
func (*Backend) Close ¶ added in v0.14.0
Close closes the in-memory store and erases any stored data.
func (*Backend) GetAll ¶ added in v0.14.0
func (backend *Backend) GetAll(_ context.Context) ([]*databroker.Record, *databroker.Versions, error)
GetAll gets all the records from the in-memory store.
func (*Backend) GetOptions ¶ added in v0.14.0
func (backend *Backend) GetOptions(_ context.Context, recordType string) (*databroker.Options, error)
GetOptions returns the options for a type in the in-memory store.
func (*Backend) Put ¶ added in v0.14.0
func (backend *Backend) Put(ctx context.Context, record *databroker.Record) (serverVersion uint64, err error)
Put puts a record into the in-memory store.
func (*Backend) SetOptions ¶ added in v0.14.0
func (backend *Backend) SetOptions(_ context.Context, recordType string, options *databroker.Options) error
SetOptions sets the options for a type in the in-memory store.
type Option ¶ added in v0.14.0
type Option func(cfg *config)
An Option customizes the in-memory backend.
func WithBTreeDegree ¶ added in v0.14.0
WithBTreeDegree sets the btree degree of the changes btree.
func WithExpiry ¶ added in v0.14.0
WithExpiry sets the expiry for changes.
type RecordCollection ¶ added in v0.14.0
type RecordCollection struct {
// contains filtered or unexported fields
}
A RecordCollection is a collection of records which supports lookup by (record id) as well as enforcing capacity by insertion order. The collection is *not* thread safe.
func NewRecordCollection ¶ added in v0.14.0
func NewRecordCollection() *RecordCollection
NewRecordCollection creates a new RecordCollection.
func (*RecordCollection) Delete ¶ added in v0.14.0
func (c *RecordCollection) Delete(recordID string)
Delete deletes a record from the collection.
func (*RecordCollection) Get ¶ added in v0.14.0
func (c *RecordCollection) Get(recordID string) *databroker.Record
Get gets a record from the collection.
func (*RecordCollection) Len ¶ added in v0.14.0
func (c *RecordCollection) Len() int
Len returns the length of the collection.
func (*RecordCollection) List ¶ added in v0.14.0
func (c *RecordCollection) List() []*databroker.Record
List lists all the records in the collection in insertion order.
func (*RecordCollection) Put ¶ added in v0.14.0
func (c *RecordCollection) Put(record *databroker.Record)
Put puts a record in the collection.