kevo/pkg/transaction/creator.go
Jeremy Tregunna 25fe3b1771
Some checks failed
Go Tests / Run Tests (1.24.2) (push) Has been cancelled
chore: i am an idiot, forgot to change the full path parts
2025-04-20 14:53:39 -06:00

34 lines
799 B
Go

package transaction
import (
"github.com/jeremytregunna/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{})
}