inmem

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 11 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) 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) Flush

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

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

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

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

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 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