cassandra

package
v1.8.8-0...-e322ba7 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package Cassandra contains code for integration or inter-operation with SOP's Cassandra DB. This package manage contents on tables like Registry, StoreRepository, Transaction Log.

Index

Constants

View Source
const (
	// DateHourLayout format mask string.
	DateHourLayout = "2006-01-02T15"
)

Variables

View Source
var NilUUID = gocql.UUID(sop.NilUUID)

NilUUID with gocql.UUID type.

View Source
var Now = time.Now

Now lambda to allow unit test to inject replayable time.Now.

Functions

func CloseConnection

func CloseConnection()

Close the singleton connection if open.

func IsConnectionInstantiated

func IsConnectionInstantiated() bool

Returns true if connection instance is valid.

func IsNil

func IsNil(id gocql.UUID) bool

Returns true if id is nil or empty UUID, otherwise false.

func NewBlobStore

func NewBlobStore() sop.BlobStore

NewBlobStore instantiates a new BlobStore instance.

func NewRegistry

func NewRegistry() sop.Registry

NewRegistry manages the Handle in the store's Cassandra registry table.

func NewStoreRepository

func NewStoreRepository(manageBlobStore sop.ManageStore) sop.StoreRepository

NewStoreRepository manages the StoreInfo in Cassandra table. Passing in nil to "managedBlobStore" will use default implementation in StoreRepository itself for managing Blob Store table in Cassandra.

func NewTransactionLog

func NewTransactionLog() sop.TransactionLog

NewBlobStore instantiates a new BlobStore instance.

Types

type Config

type Config struct {
	// Cassandra hosts cluster.
	ClusterHosts []string
	// Keyspace to be used when doing I/O to cassandra.
	Keyspace string
	// Default Consistency level.
	Consistency gocql.Consistency
	// Connection Timeout.
	ConnectionTimeout time.Duration
	// Authenticator.
	Authenticator gocql.Authenticator
	// Defaults to "simple strategy & replication factor of 1".
	ReplicationClause string

	// ConsistencyBook should be used to specify consistency level to use for a given
	// API, e.g. one for RegistryAdd, another for StoreAdd, etc... if you so choose to.
	//
	// You can leave it default and the API will use the default Consistency level
	// for the cluster (defaults to local quorum).
	ConsistencyBook ConsistencyBook
}

Config contains the this Cassandra package configuration or configurable variables.

type Connection

type Connection struct {
	Session *gocql.Session
	Config
}

Connection has the Session and the config used to open/create a session.

func OpenConnection

func OpenConnection(config Config) (*Connection, error)

OpenConnection will create(& return) a new Connection to Cassandra if there is not one yet, otherwise, will just return existing singleton connection.

type ConsistencyBook

type ConsistencyBook struct {
	RegistryAdd    gocql.Consistency
	RegistryUpdate gocql.Consistency
	RegistryGet    gocql.Consistency
	RegistryRemove gocql.Consistency
	StoreAdd       gocql.Consistency
	StoreUpdate    gocql.Consistency
	StoreGet       gocql.Consistency
	StoreRemove    gocql.Consistency

	// Blob Store Consistency configs are only used if Blob Store backend is Cassandra,
	// not used in others like File System.
	BlobStoreAdd    gocql.Consistency
	BlobStoreGet    gocql.Consistency
	BlobStoreUpdate gocql.Consistency
	BlobStoreRemove gocql.Consistency
}

Lists all the available API's consistency level that are settable in this package.

Jump to

Keyboard shortcuts

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