Documentation
¶
Index ¶
- Variables
- type Bucket
- func (b *Bucket) Call(name string, payload []byte) ([]byte, error)
- func (b *Bucket) CallDirect(name string, payload []byte) ([]byte, error)
- func (b *Bucket) Delete(key []byte) error
- func (b *Bucket) EstimatedKeyCount() uint64
- func (b *Bucket) Get(key []byte) ([]byte, error)
- func (b *Bucket) GetAll() ([]KV, error)
- func (b *Bucket) GetAllSubscriptionIDs(channel string) []int64
- func (b *Bucket) GetKeyFrequency(key []byte) uint64
- func (b *Bucket) GetSubscriptionCount(channel string) int
- func (b *Bucket) Has(key []byte) bool
- func (b *Bucket) Publish(channel string, payload []byte) (int, error)
- func (b *Bucket) RegisterHandler(name string, fn func([]byte) ([]byte, error))
- func (b *Bucket) Scan(fn func(key, value []byte) bool) error
- func (b *Bucket) Set(key, value []byte) error
- func (b *Bucket) Subscribe(channel string, fn func([]byte)) func()
- func (b *Bucket) SubscribeWithID(channel string, fn func([]byte)) (int64, func())
- func (b *Bucket) UnregisterHandler(name string)
- func (b *Bucket) UnsubscribeAll(channel string)
- type Config
- type DB
- func (db *DB) Bucket(name string) *Bucket
- func (db *DB) Call(name string, payload []byte) ([]byte, error)
- func (db *DB) CallDirect(name string, payload []byte) ([]byte, error)
- func (db *DB) Close() error
- func (db *DB) Compact() error
- func (db *DB) CompactIfNeeded() error
- func (db *DB) EstimatedKeyCount() uint64
- func (db *DB) Flush() error
- func (db *DB) GetAllSubscriptionIDs(channel string) []int64
- func (db *DB) GetSubscriptionCount(channel string) int
- func (db *DB) Publish(channel string, payload []byte) (int, error)
- func (db *DB) RegisterHandler(name string, fn func([]byte) ([]byte, error))
- func (db *DB) Size() int64
- func (db *DB) Stats() map[string]interface{}
- func (db *DB) Subscribe(channel string, fn func([]byte)) func()
- func (db *DB) SubscribeWithID(channel string, fn func([]byte)) (int64, func())
- func (db *DB) UnregisterHandler(name string)
- func (db *DB) UnsubscribeAll(channel string)
- type KV
- type Option
- func WithBatchSettings(minSize, maxSize int, timeout time.Duration) Option
- func WithBloomFilter(expectedItems uint, falsePositiveRate float64) Option
- func WithCacheSize(size int) Option
- func WithCardinality(precision uint8) Option
- func WithCompaction(minItems int, fragmentation float64, interval time.Duration) Option
- func WithCompression(threshold int, level int) Option
- func WithDoctor(doctor *jack.Doctor) Option
- func WithFlushTimeout(timeout time.Duration) Option
- func WithFrequency(enable bool) Option
- func WithInitialSize(size int64) Option
- func WithJackPool(pool *jack.Pool) Option
- func WithLifetime(lifetime *jack.Lifetime) Option
- func WithLogger(logger *ll.Logger) Option
- func WithPoolSize(size int) Option
- func WithQueueCapacity(cap int) Option
- func WithShardCount(count int) Option
- func WithWALBufferSize(size int) Option
- func WithWALDisabled(disable bool) Option
- func WithWriterBufferSize(size int) Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("oshodi: database closed") ErrKeyEmpty = errors.New("oshodi: key cannot be empty") )
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket represents a namespaced collection
func (*Bucket) CallDirect ¶
CallDirect invokes a bucket-scoped handler in current goroutine
func (*Bucket) EstimatedKeyCount ¶
EstimatedKeyCount returns estimated unique keys in this bucket
func (*Bucket) GetAllSubscriptionIDs ¶
GetAllSubscriptionIDs returns all subscription IDs on a channel
func (*Bucket) GetKeyFrequency ¶
GetKeyFrequency returns estimated frequency of a key
func (*Bucket) GetSubscriptionCount ¶
GetSubscriptionCount returns number of subscribers on a channel
func (*Bucket) RegisterHandler ¶
RegisterHandler registers a bucket-scoped handler
func (*Bucket) SubscribeWithID ¶
SubscribeWithID registers a callback and returns subscription ID
func (*Bucket) UnregisterHandler ¶
UnregisterHandler removes a bucket-scoped handler
func (*Bucket) UnsubscribeAll ¶
UnsubscribeAll removes all subscribers from a channel
type Config ¶
type Config struct {
// Basic settings
Path string
// Performance tuning
ShardCount int
QueueCapacity int
WriterBufferSize int
InitialFileSize int64
CacheSize int
PoolSize int
// Batching
BatchMinSize int
BatchMaxSize int
BatchTimeout time.Duration
FlushTimeout time.Duration
// Bloom filter
BloomExpectedItems uint
BloomFalsePositiveRate float64
// Compression
EnableCompression bool
CompressionThreshold int
CompressionLevel int
// Compaction
CompactionMinItems int
CompactionFragmentation float64
CompactionInterval time.Duration
// Analytics
EnableCardinality bool
CardinalityPrecision uint8 // 10-16, higher = more accurate
EnableFrequency bool // Enable Count-Min Sketch
// Logging
Logger *ll.Logger
JackPool *jack.Pool
JackDoctor *jack.Doctor
JackLifetime *jack.Lifetime
WALMaxBufSize int
DisableWAL bool
}
Config holds database configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a config with sensible defaults
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the main database handle
func (*DB) CallDirect ¶
CallDirect invokes a handler in current goroutine
func (*DB) CompactIfNeeded ¶
CompactIfNeeded checks and compacts if thresholds are met
func (*DB) EstimatedKeyCount ¶
EstimatedKeyCount returns estimated unique keys in the database
func (*DB) GetAllSubscriptionIDs ¶
GetAllSubscriptionIDs returns all subscription IDs on a channel
func (*DB) GetSubscriptionCount ¶
GetSubscriptionCount returns number of subscribers on a channel
func (*DB) RegisterHandler ¶
RegisterHandler registers a request-response handler
func (*DB) SubscribeWithID ¶
SubscribeWithID registers a callback and returns subscription ID
func (*DB) UnregisterHandler ¶
UnregisterHandler removes a request-response handler
func (*DB) UnsubscribeAll ¶
UnsubscribeAll removes all subscribers from a channel
type Option ¶
type Option func(*Config)
Option is a functional option for configuring the database
func WithBatchSettings ¶
WithBatchSettings configures batching behavior
func WithBloomFilter ¶
WithBloomFilter configures the Bloom filter
func WithCardinality ¶
WithCardinality enables cardinality tracking with HyperLogLog
func WithCompaction ¶
WithCompaction configures compaction thresholds
func WithCompression ¶
WithCompression enables compression
func WithDoctor ¶
WithDoctor injects an existing health monitor
func WithFlushTimeout ¶
WithFlushTimeout sets the flush timeout
func WithFrequency ¶
WithFrequency enables frequency tracking with Count-Min Sketch
func WithInitialSize ¶
WithInitialSize sets the initial file size
func WithJackPool ¶
WithJackPool injects an existing worker pool so the DB doesn't spawn its own
func WithLifetime ¶
WithLifetime injects an existing lifecycle manager for TTLs and background tasks
func WithQueueCapacity ¶
WithQueueCapacity sets the write queue capacity
func WithShardCount ¶
WithShardCount sets the number of shards for concurrency
func WithWALBufferSize ¶
WithWALBufferSize options.go - Add WAL options:
func WithWALDisabled ¶
WithWALDisabled disables the Write-Ahead Log
func WithWriterBufferSize ¶
WithWriterBufferSize sets the writer buffer size