kevo/pkg/engine/interfaces/engine.go
Jeremy Tregunna f9e332096c feat: Update client sdk (Go) with smart connection logic
- Client SDK will connect to a node, get node information and decide if
  it needs to connect to a primary for writes, or pick a replica to
  connect to for reads
- Updated service with a GetNodeInfo rpc call which returns information
  about the node to enable the smart selection code in the sdks
2025-04-29 15:03:03 -06:00

63 lines
1.6 KiB
Go

package interfaces
import (
"errors"
"github.com/KevoDB/kevo/pkg/common/iterator"
"github.com/KevoDB/kevo/pkg/stats"
"github.com/KevoDB/kevo/pkg/wal"
)
// Engine defines the core interface for the storage engine
// This is the primary interface clients will interact with
type Engine interface {
// Core operations
Put(key, value []byte) error
Get(key []byte) ([]byte, error)
Delete(key []byte) error
IsDeleted(key []byte) (bool, error)
// Iterator access
GetIterator() (iterator.Iterator, error)
GetRangeIterator(startKey, endKey []byte) (iterator.Iterator, error)
// Batch operations
ApplyBatch(entries []*wal.Entry) error
// Transaction management
BeginTransaction(readOnly bool) (Transaction, error)
// Maintenance operations
FlushImMemTables() error
TriggerCompaction() error
CompactRange(startKey, endKey []byte) error
// Statistics
GetStats() map[string]interface{}
GetCompactionStats() (map[string]interface{}, error)
// Lifecycle management
Close() error
// Read-only mode?
IsReadOnly() bool
}
// Components is a struct containing all the components needed by the engine
// This allows for dependency injection and easier testing
type Components struct {
Storage StorageManager
TransactionMgr TransactionManager
CompactionMgr CompactionManager
StatsCollector stats.Collector
}
// Engine related errors
var (
// ErrEngineClosed is returned when operations are performed on a closed engine
ErrEngineClosed = errors.New("engine is closed")
// ErrKeyNotFound is returned when a key is not found
ErrKeyNotFound = errors.New("key not found")
)