Documentation
¶
Overview ¶
Package contains SOP in Redis, Cassandra & Kafka(in_red_c) integration code.
Index ¶
- Variables
- func DeleteService(ctx context.Context)
- func DoDeletedItemsProcessing(ctx context.Context)
- func EnableDeleteService(yes bool)
- func Initialize(cassandraConfig cas.Config, redisConfig redis.Options) error
- func IsInitialized() bool
- 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)
- func SetNodeCacheDuration(duration time.Duration)
- func Shutdown()
- type StoreInterface
- type Transaction
- type TwoPhaseCommitTransaction
Constants ¶
This section is empty.
Variables ¶
var IsDeleteServiceEnabled bool
Enable the delete service(defaults to false) if you want this host to (enqueue &) poll kafka periodically to send/process deleted unused Nodes leftover of transaction.
var Now = time.Now().UnixMilli
Now is a lambda expression that returns the current time in Unix milliseconds.
var ServiceIntervalInHour int = 2
Service interval defaults to 2 hours. That is, process deleted items every two hours.
Functions ¶
func DeleteService ¶
DeleteService runs the DoDeleteItemsProcessing function below periodically, like every 2 hours(default).
func DoDeletedItemsProcessing ¶
Process(issue delete SQL stmt) the deleted items from the kafka queue.
func EnableDeleteService ¶
func EnableDeleteService(yes bool)
Sets the Delete Service to enabled(yes = true) or disabled(yes = false).
func Initialize ¶
Assign the configs & open connections to different sub-systems used by this package. Example, connection to Cassandra, Redis.
func IsInitialized ¶
func IsInitialized() bool
Returns true if components required were initialized, false otherwise.
func NewBtree ¶
func NewBtree[TK btree.Comparable, TV any](ctx context.Context, name string, slotLength int, isUnique bool, isValueDataInNodeSegment bool, leafLoadBalancing bool, desciption string, t Transaction) (btree.BtreeInterface[TK, TV], error)
NewBtree will create a new B-Tree instance with data persisted to backend storage upon commit, e.g. - AWS storage services. Parameters: name - specifies the name of the store/b-tree. slotLength - specifies the number of item slots per node of a b-tree. isUnique - specifies whether the b-tree will enforce key uniqueness(true) or not(false). isValueDataInNodeSegment - specifies whether the b-tree will store the "value" data in the tree's node segment together with
the key, or store it in another (data) segment. Currently not implemented and always stores the data in the node segment.
leafLoadBalancing - true means leaf load balancing feature is enabled, false otherwise. description - (optional) description about the store. t - transaction that the instance will participate in.
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.
func SetNodeCacheDuration ¶
SetNodeCacheDuration allows node cache duration to get set globally.
Types ¶
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, error)
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, error)
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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package Cassandra contains code for integration or inter-operation with Cassandra DB.
|
Package Cassandra contains code for integration or inter-operation with Cassandra DB. |