package transaction import ( "git.canoozie.net/jer/go-storage/pkg/engine" ) // TransactionMode defines the transaction access mode (ReadOnly or ReadWrite) type TransactionMode int const ( // ReadOnly transactions only read from the database ReadOnly TransactionMode = iota // ReadWrite transactions can both read and write to the database ReadWrite ) // Transaction represents a database transaction that provides ACID guarantees // It follows an SQLite-inspired concurrency model with reader-writer locks type Transaction interface { // Get retrieves a value for the given key Get(key []byte) ([]byte, error) // Put adds or updates a key-value pair (only for ReadWrite transactions) Put(key, value []byte) error // Delete removes a key (only for ReadWrite transactions) Delete(key []byte) error // NewIterator returns an iterator for all keys in the transaction NewIterator() engine.Iterator // NewRangeIterator returns an iterator limited to the given key range NewRangeIterator(startKey, endKey []byte) engine.Iterator // Commit makes all changes permanent // For ReadOnly transactions, this just releases resources Commit() error // Rollback discards all transaction changes Rollback() error // IsReadOnly returns true if this is a read-only transaction IsReadOnly() bool }