Some checks failed
Go Tests / Run Tests (1.24.2) (push) Has been cancelled
Adds a complete LSM-based storage engine with these features: - Single-writer based architecture for the storage engine - WAL for durability, and hey it's configurable - MemTable with skip list implementation for fast read/writes - SSTable with block-based structure for on-disk level-based storage - Background compaction with tiered strategy - ACID transactions - Good documentation (I hope)
34 lines
788 B
Go
34 lines
788 B
Go
package transaction
|
|
|
|
import (
|
|
"github.com/jer/kevo/pkg/engine"
|
|
)
|
|
|
|
// TransactionCreatorImpl implements the engine.TransactionCreator interface
|
|
type TransactionCreatorImpl struct{}
|
|
|
|
// CreateTransaction creates a new transaction
|
|
func (tc *TransactionCreatorImpl) CreateTransaction(e interface{}, readOnly bool) (engine.Transaction, error) {
|
|
// Convert the interface to the engine.Engine type
|
|
eng, ok := e.(*engine.Engine)
|
|
if !ok {
|
|
return nil, ErrInvalidEngine
|
|
}
|
|
|
|
// Determine transaction mode
|
|
var mode TransactionMode
|
|
if readOnly {
|
|
mode = ReadOnly
|
|
} else {
|
|
mode = ReadWrite
|
|
}
|
|
|
|
// Create a new transaction
|
|
return NewTransaction(eng, mode)
|
|
}
|
|
|
|
// Register the transaction creator with the engine
|
|
func init() {
|
|
engine.RegisterTransactionCreator(&TransactionCreatorImpl{})
|
|
}
|