in_red_ck

package
v1.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package contains SOP in Redis, Cassandra & Kafka(in_red_c) integration code.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
var Now = time.Now().UnixMilli

Now is a lambda expression that returns the current time in Unix milliseconds.

View Source
var ServiceIntervalInHour int = 2

Service interval defaults to 2 hours. That is, process deleted items every two hours.

Functions

func DeleteService

func DeleteService(ctx context.Context)

DeleteService runs the DoDeleteItemsProcessing function below periodically, like every 2 hours(default).

func DoDeletedItemsProcessing

func DoDeletedItemsProcessing(ctx context.Context)

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

func Initialize(cassandraConfig cas.Config, redisConfig redis.Options) error

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

func SetNodeCacheDuration(duration time.Duration)

SetNodeCacheDuration allows node cache duration to get set globally.

func Shutdown

func Shutdown()

Shutdown or closes all connections used in this package.

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL