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
- Variables
- func CloseConnection()
- func IsConnectionInstantiated() bool
- func IsNil(id gocql.UUID) bool
- func NewBlobStore(customConnection *Connection) sop.BlobStore
- func NewRegistry(customConnection *Connection, l2Cache sop.L2Cache) sop.Registry
- func NewStoreRepository(manageBlobStore sop.ManageStore, customConnection *Connection, ...) sop.StoreRepository
- func NewTransactionLog(customConnection *Connection, cache sop.L2Cache) sop.TransactionLog
- func ProcessNewer(ctx context.Context, ...) error
- type Config
- type Connection
- type ConsistencyBook
Constants ¶
const (
// DateHourLayout format mask string.
DateHourLayout = "2006-01-02T15"
)
Variables ¶
var NilUUID = gocql.UUID(sop.NilUUID)
NilUUID with gocql.UUID type.
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 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.
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 ¶
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.
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.