cassandra

package module
v0.0.0-...-edaca3c Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package cassandra provides Cassandra-backed implementations of SOP repositories and logs, including connection/session management and per-API consistency customization.

Package cassandra contains the Cassandra implementation of the Store Repository and Registry.

Package cassandra contains code for integration or inter-operation with SOP's Cassandra DB. This package manages contents in tables like Registry, StoreRepository, and 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()

CloseConnection closes and clears the global connection, if it exists.

func IsConnectionInstantiated

func IsConnectionInstantiated() bool

IsConnectionInstantiated reports whether a global Connection has been created.

func IsNil

func IsNil(id gocql.UUID) bool

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

func NewBlobStore

func NewBlobStore(customConnection *Connection) sop.BlobStore

NewBlobStore instantiates a Cassandra-backed implementation of sop.BlobStore.

func NewRegistry

func NewRegistry(customConnection *Connection, l2Cache sop.L2Cache) sop.Registry

NewRegistry returns a Cassandra-backed implementation of sop.Registry.

func NewStoreRepository

func NewStoreRepository(manageBlobStore sop.ManageStore, customConnection *Connection, cache sop.L2Cache) 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(customConnection *Connection, cache sop.L2Cache) sop.TransactionLog

NewTransactionLog returns a Cassandra-backed implementation of sop.TransactionLog.

func ProcessNewer

func ProcessNewer(ctx context.Context, processor func(tid sop.UUID, payload []sop.RegistryPayload[sop.Handle]) error) error

ProcessNewer iterates over all priority logs newer than 5 mins and invokes the processor callback for each.

Types

type Config

type Config struct {
	// ClusterHosts lists contact points for the Cassandra cluster.
	ClusterHosts []string
	// Keyspace is the keyspace used for SOP tables.
	Keyspace string
	// Consistency is the default consistency level for queries.
	Consistency gocql.Consistency
	// ConnectionTimeout is the session connection timeout.
	ConnectionTimeout time.Duration
	// Authenticator is used when the cluster requires authentication.
	Authenticator gocql.Authenticator
	// ReplicationClause defines the keyspace replication (e.g., SimpleStrategy).
	ReplicationClause string

	// ConsistencyBook allows overriding per-API consistency levels.
	ConsistencyBook ConsistencyBook
}

Config contains configuration for connecting to a Cassandra cluster and SOP keyspace.

type Connection

type Connection struct {
	Session *gocql.Session
	Config
}

Connection wraps a Cassandra session and its configuration.

func GetConnection

func GetConnection(keyspace string) (*Connection, error)

GetConnection returns a connection for the given keyspace, reusing the global session if available.

func GetGlobalConnection

func GetGlobalConnection() (*Connection, error)

GetGlobalConnection returns the global connection using the global configuration.

func NewConnection

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

NewConnection opens a new connection using the provided config. Deprecated: Use OpenConnection instead.

func OpenConnection

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

OpenConnection returns the existing global Connection or opens a new one using the provided config.

func (*Connection) Close

func (c *Connection) Close()

Close closes the 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 levels are only used when the blob backend is Cassandra.
	BlobStoreAdd    gocql.Consistency
	BlobStoreGet    gocql.Consistency
	BlobStoreUpdate gocql.Consistency
	BlobStoreRemove gocql.Consistency
}

ConsistencyBook enumerates per-API consistency levels used by this package.

Jump to

Keyboard shortcuts

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