cassandra

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package Cassandra contains code for integration or inter-operation with Cassandra DB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClusterHosts []string
	// Keyspace to be used when doing I/O to cassandra.
	Keyspace string
	// Consistency
	Consistency gocql.Consistency
}

type Connection

type Connection struct {
	Session *gocql.Session
	Config
}

func GetConnection

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

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

type StoreRepository

type StoreRepository interface {
	// Fetch store info with name.
	Get(context.Context, ...string) ([]btree.StoreInfo, error)
	// Add store info. Add all or nothing.
	Add(context.Context, ...btree.StoreInfo) error
	// Update store info. Update all or nothing.
	// Update should also merge the Count of items between the incoming store info
	// and the target store info on the backend, as they may differ. It should use
	// StoreInfo.CountDelta to reconcile the two.
	Update(context.Context, ...btree.StoreInfo) error
	// Remove store info with name. Remove all or nothing.
	Remove(context.Context, ...string) error
}

StoreRepository interface specifies the store repository. Stores are readonly after creation, thus, no update method.

func NewStoreRepository

func NewStoreRepository() StoreRepository

NewStoreRepository manages the StoreInfo in Cassandra table.

type VirtualIdRegistry

type VirtualIdRegistry interface {
	Get(context.Context, ...btree.UUID) ([]sop.Handle, error)
	Add(context.Context, ...sop.Handle) error
	Update(context.Context, ...sop.Handle) error
	Remove(context.Context, ...btree.UUID) error
}

Virtual Id registry is essential in our support for all or nothing (sub)feature, which is essential in "fault tolerant" & "self healing" feature.

All methods are taking in a set of items and need to be implemented to do all or nothing feature, e.g. wrapped in transaction in Cassandra.

func NewVirtualIdRegistry

func NewVirtualIdRegistry() VirtualIdRegistry

TODO: NewVirtualIdRegistry manages the Handle in Cassandra table, cached in Redis.

Jump to

Keyboard shortcuts

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