Documentation
¶
Index ¶
- Constants
- Variables
- func NewBtree[TK btree.Comparable, TV any](ctx context.Context, name string, slotLength int, isUnique bool, ...) (btree.BtreeInterface[TK, TV], error)
- func OpenBtree[TK btree.Comparable, TV any](ctx context.Context, name string, t Transaction) (btree.BtreeInterface[TK, TV], error)
- type QueueItem
- type QueueItemType
- type StoreInterface
- type Transaction
- type TwoPhaseCommitTransaction
Constants ¶
const ( Unknown = iota BtreeNode ItemValue )
Variables ¶
var Now = time.Now().UnixMilli
Now is a lambda expression that returns the current time in Unix milliseconds.
Functions ¶
func NewBtree ¶
func NewBtree[TK btree.Comparable, TV any](ctx context.Context, name string, slotLength int, isUnique bool, isValueDataInNodeSegment bool, t Transaction) (btree.BtreeInterface[TK, TV], error)
NewBtree will create a new B-Tree instance with data persisted in backend store, e.g. - AWS storage services. The created B-Tree is a permanent action, it is outside of the transaction, thus, even if the passed in transaction rolls back, the created tree sticks.
func OpenBtree ¶
func OpenBtree[TK btree.Comparable, TV any](ctx context.Context, name string, t Transaction) (btree.BtreeInterface[TK, TV], error)
OpenBtree will open an existing B-Tree instance it for use in a transaction.
Types ¶
type QueueItem ¶
type QueueItem struct {
ItemType QueueItemType
ItemId btree.UUID
}
type QueueItemType ¶
type QueueItemType int
type StoreInterface ¶
type StoreInterface[TK btree.Comparable, TV any] struct { btree.StoreInterface[TK, TV] // contains filtered or unexported fields }
StoreInterface contains different repositories needed/used by B-Tree to manage/access its data/objects.
type Transaction ¶
type Transaction interface {
// Begin the transaction.
Begin() error
// Commit the transaction.
Commit(ctx context.Context) error
// Rollback the transaction.
Rollback(ctx context.Context) error
// Returns true if transaction has begun, false otherwise.
HasBegun() bool
// Returns the two phased commit transaction object. Useful for integration with your application
// "other" database transactions. Returned transaction object will allow your code to call the
// two phases commit of SOP.
GetPhasedTransaction() TwoPhaseCommitTransaction
// Add your two phases commit implementation for managing your/3rd party database transaction.
AddPhasedTransaction(otherTransaction ...TwoPhaseCommitTransaction)
}
Transaction interface defines the "enduser facing" transaction methods.
func NewTransaction ¶
func NewTransaction(forWriting bool, maxTime time.Duration) Transaction
NewTransaction creates an enduser facing transaction object.
type TwoPhaseCommitTransaction ¶
type TwoPhaseCommitTransaction interface {
// Begin the transaction.
Begin() error
// Phase1Commit of the transaction.
Phase1Commit(ctx context.Context) error
// Phase2Commit of the transaction.
Phase2Commit(ctx context.Context) error
// Rollback the transaction.
Rollback(ctx context.Context) error
// Returns true if transaction has begun, false otherwise.
HasBegun() bool
}
TwoPhaseCommitTransaction interface defines the "infrastructure facing" transaction methods.
func NewTwoPhaseCommitTransaction ¶
func NewTwoPhaseCommitTransaction(forWriting bool, maxTime time.Duration) TwoPhaseCommitTransaction
NewTwoPhaseCommitTransaction will instantiate a transaction object for writing(forWriting=true) or for reading(forWriting=false). Pass in -1 on maxTime to default to 15 minutes of session duration.