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) GetOptions(_ context.Context, recordType string) (*databroker.Options, error)
- func (backend *Backend) Lease(_ context.Context, leaseName, leaseID string, ttl time.Duration) (bool, error)
- func (backend *Backend) ListTypes(_ context.Context) ([]string, error)
- func (backend *Backend) Put(ctx context.Context, records []*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, recordType string, serverVersion, recordVersion uint64) (storage.RecordStream, error)
- func (backend *Backend) SyncLatest(ctx context.Context, recordType string, expr storage.FilterExpression) (serverVersion, recordVersion uint64, stream storage.RecordStream, err 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) 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) Lease ¶ added in v0.15.0
func (backend *Backend) Lease(_ context.Context, leaseName, leaseID string, ttl time.Duration) (bool, error)
Lease acquires or renews a lease.
func (*Backend) Put ¶ added in v0.14.0
func (backend *Backend) Put(ctx context.Context, records []*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.
func (*Backend) Sync ¶ added in v0.14.0
func (backend *Backend) Sync(ctx context.Context, recordType string, serverVersion, recordVersion uint64) (storage.RecordStream, error)
Sync returns a record stream for any changes after recordVersion.
func (*Backend) SyncLatest ¶ added in v0.17.3
func (backend *Backend) SyncLatest( ctx context.Context, recordType string, expr storage.FilterExpression, ) (serverVersion, recordVersion uint64, stream storage.RecordStream, err error)
SyncLatest returns a record stream for all the records.
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.