inmem

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 13 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) 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    platform.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) Create

func (s *Service) Create(ctx context.Context, m *influxdb.DBRPMapping) error

Create creates a new dbrp mapping.

func (*Service) DefaultSource

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

DefaultSource retrieves the default source.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, cluster, db, rp string) error

Delete removes a dbrp mapping

func (*Service) Find

func (s *Service) Find(ctx context.Context, filter influxdb.DBRPMappingFilter) (*influxdb.DBRPMapping, error)

Find returns the first dbrp mapping that matches filter.

func (*Service) FindBy

func (s *Service) FindBy(ctx context.Context, cluster, db, rp string) (*influxdb.DBRPMapping, error)

FindBy returns a single dbrp mapping by cluster, db and rp.

func (*Service) FindMany

func (s *Service) FindMany(ctx context.Context, filter influxdb.DBRPMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.DBRPMapping, int, error)

FindMany returns a list of dbrpMappings that match filter and the total count of matching dbrp mappings. Additional options provide pagination & sorting.

func (*Service) FindSourceByID

func (s *Service) FindSourceByID(ctx context.Context, id platform.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 retrives 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) PutDBRPMapping

func (s *Service) PutDBRPMapping(ctx context.Context, m *influxdb.DBRPMapping) error

PutDBRPMapping sets dbrpMapping with the current ID.

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