inmemory

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package inmemory contains an in-memory implementation of the databroker backend.

Index

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 New added in v0.14.0

func New(options ...Option) *Backend

New creates a new in-memory backend storage.

func (*Backend) Close added in v0.14.0

func (backend *Backend) Close() error

Close closes the in-memory store and erases any stored data.

func (*Backend) Get added in v0.14.0

func (backend *Backend) Get(_ context.Context, recordType, id string) (*databroker.Record, error)

Get gets a record 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) 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) ListTypes added in v0.22.0

func (backend *Backend) ListTypes(_ context.Context) ([]string, error)

ListTypes lists the record types.

func (*Backend) Patch added in v0.24.0

func (backend *Backend) Patch(
	ctx context.Context, records []*databroker.Record, fields *fieldmaskpb.FieldMask,
) (serverVersion uint64, patchedRecords []*databroker.Record, err error)

Patch updates the specified fields of existing record(s).

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

func WithBTreeDegree(degree int) Option

WithBTreeDegree sets the btree degree of the changes btree.

func WithExpiry added in v0.14.0

func WithExpiry(expiry time.Duration) Option

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.

Jump to

Keyboard shortcuts

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