Documentation
¶
Index ¶
- Variables
- func CreatePool(dataPath, metaPath string) error
- func DrainPool() error
- func IndexKey(tableName, indexName, value string, primaryKey string) []byte
- func ParseTableRowKey(key []byte) (tableName, rowID string, valid bool)
- func VersionKey(baseKey []byte, version uint64) []byte
- type BadgerBatch
- type BadgerItem
- type BadgerIterator
- type BadgerStore
- func (s *BadgerStore) Begin(writable bool) (Transaction, error)
- func (s *BadgerStore) Close() error
- func (s *BadgerStore) Delete(ctx context.Context, key []byte) error
- func (s *BadgerStore) Get(ctx context.Context, key []byte) ([]byte, error)
- func (s *BadgerStore) NewBatch() Batch
- func (s *BadgerStore) NewIterator(opts IteratorOptions) Iterator
- func (s *BadgerStore) Put(ctx context.Context, key, value []byte) error
- func (s *BadgerStore) Size() (int64, error)
- func (s *BadgerStore) Sync() error
- type BadgerTransaction
- func (t *BadgerTransaction) Begin(writable bool) (Transaction, error)
- func (t *BadgerTransaction) Close() error
- func (t *BadgerTransaction) Commit() error
- func (t *BadgerTransaction) Delete(ctx context.Context, key []byte) error
- func (t *BadgerTransaction) Discard()
- func (t *BadgerTransaction) Get(ctx context.Context, key []byte) ([]byte, error)
- func (t *BadgerTransaction) NewBatch() Batch
- func (t *BadgerTransaction) NewIterator(opts IteratorOptions) Iterator
- func (t *BadgerTransaction) Put(ctx context.Context, key, value []byte) error
- func (t *BadgerTransaction) Size() (int64, error)
- func (t *BadgerTransaction) Sync() error
- type BadgerTxnBatch
- type Batch
- type Item
- type Iterator
- type IteratorOptions
- type KeyBuilder
- func (kb *KeyBuilder) Append(part string) *KeyBuilder
- func (kb *KeyBuilder) Build() []byte
- func (kb *KeyBuilder) Clone() *KeyBuilder
- func (kb *KeyBuilder) Index(indexName string) *KeyBuilder
- func (kb *KeyBuilder) Meta() *KeyBuilder
- func (kb *KeyBuilder) Migration(migrationID string) *KeyBuilder
- func (kb *KeyBuilder) Node(nodeID string) *KeyBuilder
- func (kb *KeyBuilder) Ownership(tableName string) *KeyBuilder
- func (kb *KeyBuilder) Row(rowID string) *KeyBuilder
- func (kb *KeyBuilder) Schema(tableName string) *KeyBuilder
- func (kb *KeyBuilder) String() string
- func (kb *KeyBuilder) Table(tableName string) *KeyBuilder
- type KeyNotFoundError
- type NestedTransactionError
- type Pool
- func (p *Pool) BackgroundMaintenance(ctx context.Context)
- func (p *Pool) Close() error
- func (p *Pool) DataStore() Store
- func (p *Pool) MetaStore() Store
- func (p *Pool) NewDataConnection(ctx context.Context, writable bool) (*StoreConnection, error)
- func (p *Pool) NewMetaConnection(ctx context.Context, writable bool) (*StoreConnection, error)
- func (p *Pool) Size() (dataSize, metaSize int64, err error)
- func (p *Pool) Sync() error
- type Record
- type Store
- type StoreConnection
- type Transaction
- type TypeCode
- type Value
- func DecodeValue(data []byte) (*Value, error)
- func NewBlobValue(data []byte) *Value
- func NewBoolValue(b bool) *Value
- func NewDurationValue(d time.Duration) *Value
- func NewFloatValue(f float64) *Value
- func NewIntValue(i int64) *Value
- func NewJSONValue(data interface{}) *Value
- func NewNullValue() *Value
- func NewStringValue(s string) *Value
- func NewTimeValue(t time.Time) *Value
- func (v *Value) Encode() ([]byte, error)
- func (v *Value) GetBlob() []byte
- func (v *Value) GetBool() bool
- func (v *Value) GetDuration() time.Duration
- func (v *Value) GetFloat() float64
- func (v *Value) GetInt() int64
- func (v *Value) GetString() string
- func (v *Value) GetTime() time.Time
- func (v *Value) IsNull() bool
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = &KeyNotFoundError{}
ErrKeyNotFound is returned when a key doesn't exist
var ErrNestedTransaction = &NestedTransactionError{}
ErrNestedTransaction is returned when attempting to create nested transactions
Functions ¶
func CreatePool ¶
CreatePool initializes the global KV store pool
func ParseTableRowKey ¶
ParseTableRowKey extracts table name and row ID from a table row key
func VersionKey ¶
VersionKey generates keys for versioned data
Types ¶
type BadgerBatch ¶
type BadgerBatch struct {
// contains filtered or unexported fields
}
BadgerBatch implements atomic batch operations
func (*BadgerBatch) Delete ¶
func (b *BadgerBatch) Delete(key []byte) error
func (*BadgerBatch) Flush ¶
func (b *BadgerBatch) Flush() error
func (*BadgerBatch) Reset ¶
func (b *BadgerBatch) Reset()
func (*BadgerBatch) Set ¶
func (b *BadgerBatch) Set(key, value []byte) error
type BadgerItem ¶
type BadgerItem struct {
// contains filtered or unexported fields
}
BadgerItem wraps BadgerDB item
func (*BadgerItem) Key ¶
func (i *BadgerItem) Key() []byte
func (*BadgerItem) KeyCopy ¶
func (i *BadgerItem) KeyCopy() []byte
func (*BadgerItem) Value ¶
func (i *BadgerItem) Value() ([]byte, error)
func (*BadgerItem) ValueCopy ¶
func (i *BadgerItem) ValueCopy() ([]byte, error)
type BadgerIterator ¶
type BadgerIterator struct {
// contains filtered or unexported fields
}
BadgerIterator wraps BadgerDB iterator
func (*BadgerIterator) Close ¶
func (i *BadgerIterator) Close() error
func (*BadgerIterator) Item ¶
func (i *BadgerIterator) Item() Item
func (*BadgerIterator) Next ¶
func (i *BadgerIterator) Next()
func (*BadgerIterator) Rewind ¶
func (i *BadgerIterator) Rewind()
func (*BadgerIterator) Seek ¶
func (i *BadgerIterator) Seek(key []byte)
func (*BadgerIterator) Valid ¶
func (i *BadgerIterator) Valid() bool
type BadgerStore ¶
type BadgerStore struct {
// contains filtered or unexported fields
}
BadgerStore implements Store interface using BadgerDB
func NewBadgerStore ¶
func NewBadgerStore(path string) (*BadgerStore, error)
NewBadgerStore creates a new BadgerDB-backed store
func (*BadgerStore) Begin ¶
func (s *BadgerStore) Begin(writable bool) (Transaction, error)
func (*BadgerStore) Close ¶
func (s *BadgerStore) Close() error
func (*BadgerStore) NewBatch ¶
func (s *BadgerStore) NewBatch() Batch
func (*BadgerStore) NewIterator ¶
func (s *BadgerStore) NewIterator(opts IteratorOptions) Iterator
func (*BadgerStore) Size ¶
func (s *BadgerStore) Size() (int64, error)
func (*BadgerStore) Sync ¶
func (s *BadgerStore) Sync() error
type BadgerTransaction ¶
type BadgerTransaction struct {
// contains filtered or unexported fields
}
BadgerTransaction wraps BadgerDB transaction
func (*BadgerTransaction) Begin ¶
func (t *BadgerTransaction) Begin(writable bool) (Transaction, error)
func (*BadgerTransaction) Close ¶
func (t *BadgerTransaction) Close() error
func (*BadgerTransaction) Commit ¶
func (t *BadgerTransaction) Commit() error
func (*BadgerTransaction) Delete ¶
func (t *BadgerTransaction) Delete(ctx context.Context, key []byte) error
func (*BadgerTransaction) Discard ¶
func (t *BadgerTransaction) Discard()
func (*BadgerTransaction) NewBatch ¶
func (t *BadgerTransaction) NewBatch() Batch
func (*BadgerTransaction) NewIterator ¶
func (t *BadgerTransaction) NewIterator(opts IteratorOptions) Iterator
func (*BadgerTransaction) Put ¶
func (t *BadgerTransaction) Put(ctx context.Context, key, value []byte) error
func (*BadgerTransaction) Size ¶
func (t *BadgerTransaction) Size() (int64, error)
func (*BadgerTransaction) Sync ¶
func (t *BadgerTransaction) Sync() error
type BadgerTxnBatch ¶
type BadgerTxnBatch struct {
// contains filtered or unexported fields
}
BadgerTxnBatch implements batch operations within a transaction
func (*BadgerTxnBatch) Delete ¶
func (b *BadgerTxnBatch) Delete(key []byte) error
func (*BadgerTxnBatch) Flush ¶
func (b *BadgerTxnBatch) Flush() error
func (*BadgerTxnBatch) Reset ¶
func (b *BadgerTxnBatch) Reset()
func (*BadgerTxnBatch) Set ¶
func (b *BadgerTxnBatch) Set(key, value []byte) error
type Batch ¶
type Batch interface {
Set(key, value []byte) error
Delete(key []byte) error
Flush() error
Reset()
}
Batch provides atomic batch operations
type Item ¶
type Item interface {
Key() []byte
KeyCopy() []byte
Value() ([]byte, error)
ValueCopy() ([]byte, error)
}
Item represents a key-value pair during iteration
type Iterator ¶
type Iterator interface {
io.Closer
// Navigation
Rewind()
Seek(key []byte)
Next()
Valid() bool
// Data access
Item() Item
}
Iterator provides ordered key-value iteration
type IteratorOptions ¶
IteratorOptions configures iteration behavior
type KeyBuilder ¶
type KeyBuilder struct {
// contains filtered or unexported fields
}
KeyBuilder helps construct hierarchical keys for different data types
func (*KeyBuilder) Append ¶
func (kb *KeyBuilder) Append(part string) *KeyBuilder
Append adds a custom part to the key
func (*KeyBuilder) Build ¶
func (kb *KeyBuilder) Build() []byte
Build constructs the final key as bytes
func (*KeyBuilder) Clone ¶
func (kb *KeyBuilder) Clone() *KeyBuilder
Clone creates a copy of the KeyBuilder
func (*KeyBuilder) Index ¶
func (kb *KeyBuilder) Index(indexName string) *KeyBuilder
Index adds index information to the key
func (*KeyBuilder) Meta ¶
func (kb *KeyBuilder) Meta() *KeyBuilder
Meta adds metadata namespace to the key
func (*KeyBuilder) Migration ¶
func (kb *KeyBuilder) Migration(migrationID string) *KeyBuilder
Migration adds migration information to the key
func (*KeyBuilder) Node ¶
func (kb *KeyBuilder) Node(nodeID string) *KeyBuilder
Node adds node information to the key
func (*KeyBuilder) Ownership ¶
func (kb *KeyBuilder) Ownership(tableName string) *KeyBuilder
Ownership adds ownership information to the key
func (*KeyBuilder) Row ¶
func (kb *KeyBuilder) Row(rowID string) *KeyBuilder
Row adds a row identifier to the key
func (*KeyBuilder) Schema ¶
func (kb *KeyBuilder) Schema(tableName string) *KeyBuilder
Schema adds schema information to the key
func (*KeyBuilder) String ¶
func (kb *KeyBuilder) String() string
String returns the key as a string (for debugging)
func (*KeyBuilder) Table ¶
func (kb *KeyBuilder) Table(tableName string) *KeyBuilder
Table adds a table namespace to the key
type KeyNotFoundError ¶
type KeyNotFoundError struct{}
func (*KeyNotFoundError) Error ¶
func (e *KeyNotFoundError) Error() string
type NestedTransactionError ¶
type NestedTransactionError struct{}
func (*NestedTransactionError) Error ¶
func (e *NestedTransactionError) Error() string
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages multiple key-value store instances
func (*Pool) BackgroundMaintenance ¶
BackgroundMaintenance runs periodic maintenance tasks
func (*Pool) NewDataConnection ¶
NewDataConnection creates a connection to the data store
func (*Pool) NewMetaConnection ¶
NewMetaConnection creates a connection to the metadata store
type Record ¶
type Record struct {
Fields map[string]*Value `json:"fields"`
Version uint64 `json:"version"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
}
Record represents a collection of named values (equivalent to a SQL row)
func DecodeRecord ¶
DecodeRecord deserializes bytes back to a Record
type Store ¶
type Store interface {
// Basic operations
Get(ctx context.Context, key []byte) ([]byte, error)
Put(ctx context.Context, key, value []byte) error
Delete(ctx context.Context, key []byte) error
// Batch operations for atomic writes
NewBatch() Batch
// Iteration support for range queries
NewIterator(opts IteratorOptions) Iterator
// Transaction support
Begin(writable bool) (Transaction, error)
// Lifecycle
Close() error
// Statistics and maintenance
Size() (int64, error)
Sync() error
}
Store defines the key-value storage interface for Atlas-DB
type StoreConnection ¶
type StoreConnection struct {
// contains filtered or unexported fields
}
StoreConnection represents a connection to a specific store
func (*StoreConnection) Close ¶
func (c *StoreConnection) Close() error
Close discards the transaction (alias for Rollback)
func (*StoreConnection) Commit ¶
func (c *StoreConnection) Commit() error
Commit commits the transaction
func (*StoreConnection) Rollback ¶
func (c *StoreConnection) Rollback()
Rollback discards the transaction
func (*StoreConnection) Store ¶
func (c *StoreConnection) Store() Store
Store returns the underlying store
func (*StoreConnection) Transaction ¶
func (c *StoreConnection) Transaction() Transaction
Transaction returns the active transaction
type Transaction ¶
Transaction provides ACID transaction support
type Value ¶
type Value struct {
Type TypeCode `json:"type"`
Data interface{} `json:"data"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Value represents a typed value that can be stored in the KV store
func DecodeValue ¶
DecodeValue deserializes bytes back to a Value
func NewDurationValue ¶
NewDurationValue creates a duration value
func (*Value) GetDuration ¶
GetDuration returns the value as time.Duration