inmem

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSourceID it the default source identifier
	DefaultSourceID = "020f755c3c082000"
	// DefaultSourceOrganizationID is the default source's organization identifier
	DefaultSourceOrganizationID = "50616e67652c206c"
)
View Source
const OpPrefix = "inmem/"

OpPrefix is the op prefix.

Variables

View Source
var DefaultSource = platform.Source{
	Default: true,
	Name:    "autogen",
	Type:    platform.SelfSourceType,
}

DefaultSource is the default source.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

Bucket is a btree that implements kv.Bucket.

func (*Bucket) Cursor

func (b *Bucket) Cursor(opts ...kv.CursorHint) (kv.Cursor, error)

Cursor creates a static cursor from all entries in the database.

func (*Bucket) Delete

func (b *Bucket) Delete(key []byte) error

Delete removes the key provided.

func (*Bucket) ForwardCursor

func (b *Bucket) ForwardCursor(seek []byte, opts ...kv.CursorOption) (kv.ForwardCursor, error)

ForwardCursor returns a directional cursor which starts at the provided seeked key

func (*Bucket) Get

func (b *Bucket) Get(key []byte) ([]byte, error)

Get retrieves the value at the provided key.

func (*Bucket) GetBatch

func (b *Bucket) GetBatch(keys ...[]byte) ([][]byte, error)

Get retrieves a batch of values for the provided keys.

func (*Bucket) Put

func (b *Bucket) Put(key []byte, value []byte) error

Put sets the key value pair provided.

type ForwardCursor

type ForwardCursor struct {
	// contains filtered or unexported fields
}

ForwardCursor is a kv.ForwardCursor which iterates over an in-memory btree

func (*ForwardCursor) Close

func (c *ForwardCursor) Close() error

Close releases the producing goroutines for the forward cursor. It blocks until the producing goroutine exits.

func (*ForwardCursor) Err

func (c *ForwardCursor) Err() error

Err returns a non-nil error when an error occurred during cursor iteration.

func (*ForwardCursor) Next

func (c *ForwardCursor) Next() ([]byte, []byte)

Next returns the next key/value pair in the cursor

type KVStore

type KVStore struct {
	// contains filtered or unexported fields
}

KVStore is an in memory btree backed kv.Store.

func NewKVStore

func NewKVStore() *KVStore

NewKVStore creates an instance of a KVStore.

func (*KVStore) Backup

func (s *KVStore) Backup(ctx context.Context, w io.Writer) error

func (*KVStore) Buckets

func (s *KVStore) Buckets(ctx context.Context) [][]byte

Buckets returns the names of all buckets within inmem.KVStore.

func (*KVStore) CreateBucket

func (s *KVStore) CreateBucket(ctx context.Context, name []byte) error

CreateBucket creates a bucket with the provided name if one does not exist.

func (*KVStore) DeleteBucket

func (s *KVStore) DeleteBucket(ctx context.Context, name []byte) error

DeleteBucket creates a bucket with the provided name if one does not exist.

func (*KVStore) Flush

func (s *KVStore) Flush(ctx context.Context)

Flush removes all data from the buckets. Used for testing.

func (*KVStore) RLock added in v2.1.0

func (s *KVStore) RLock()

func (*KVStore) RUnlock added in v2.1.0

func (s *KVStore) RUnlock()

func (*KVStore) Restore

func (s *KVStore) Restore(ctx context.Context, r io.Reader) error

func (*KVStore) Update

func (s *KVStore) Update(ctx context.Context, fn func(kv.Tx) error) error

Update opens up a transaction with a write lock.

func (*KVStore) View

func (s *KVStore) View(ctx context.Context, fn func(kv.Tx) error) error

View opens up a transaction with a read lock.

type Service

type Service struct {
	TokenGenerator platform.TokenGenerator
	IDGenerator    platform2.IDGenerator
	platform.TimeGenerator
	// contains filtered or unexported fields
}

Service implements various top level services.

func NewService

func NewService() *Service

NewService creates an instance of a Service.

func (*Service) DefaultSource

func (s *Service) DefaultSource(ctx context.Context) (*platform.Source, error)

DefaultSource retrieves the default source.

func (*Service) FindSourceByID

func (s *Service) FindSourceByID(ctx context.Context, id platform2.ID) (*platform.Source, error)

FindSourceByID retrieves a source by id.

func (*Service) FindSources

func (s *Service) FindSources(ctx context.Context, opt platform.FindOptions) ([]*platform.Source, int, error)

FindSources retrieves all sources that match an arbitrary source filter. Filters using ID, or OrganizationID and source Name should be efficient. Other filters will do a linear scan across all sources searching for a match.

func (*Service) Flush

func (s *Service) Flush()

Flush removes all data from the in-memory store

func (*Service) PutSource

func (s *Service) PutSource(ctx context.Context, src *platform.Source) error

PutSource will put a source without setting an ID.

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}

func NewSessionStore

func NewSessionStore() *SessionStore

func (*SessionStore) Delete

func (s *SessionStore) Delete(key string) error

func (*SessionStore) ExpireAt

func (s *SessionStore) ExpireAt(key string, expireAt time.Time) error

func (*SessionStore) Get

func (s *SessionStore) Get(key string) (string, error)

func (*SessionStore) Set

func (s *SessionStore) Set(key, val string, expireAt time.Time) error

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx is an in memory transaction. TODO: make transactions actually transactional

func (*Tx) Bucket

func (t *Tx) Bucket(b []byte) (kv.Bucket, error)

Bucket retrieves the bucket at the provided key.

func (*Tx) Context

func (t *Tx) Context() context.Context

Context returns the context for the transaction.

func (*Tx) WithContext

func (t *Tx) WithContext(ctx context.Context)

WithContext sets the context for the transaction.

Jump to

Keyboard shortcuts

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