sandra

package module
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

sandra

Go library providing some convenience wrappers around gocql.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFound = errors.New("Not found")

Functions

func TableExists deprecated added in v1.2.1

func TableExists(db Cassandra, table string) (bool, error)

Deprecated: TableExists is deprecated. Use TableExistsCtx instead.

func TableExistsCtx added in v1.9.0

func TableExistsCtx(ctx context.Context, db Cassandra, table string) (bool, error)

func WaitForTables deprecated

func WaitForTables(db Cassandra, timeout time.Duration, tables ...string) error

Deprecated: WaitForTables is deprecated. Use WaitForTablesCtx instead.

func WaitForTablesCtx added in v1.9.0

func WaitForTablesCtx(ctx context.Context, db Cassandra, timeout time.Duration, tables ...string) error

Types

type Cassandra

type Cassandra interface {
	QueryCtx(ctx context.Context, consistency gocql.Consistency, queryString string, queryParams ...interface{}) *gocql.Query
	Query(gocql.Consistency, string, ...interface{}) *gocql.Query
	ExecuteQueryCtx(ctx context.Context, queryString string, queryParams ...interface{}) error
	ExecuteQuery(string, ...interface{}) error
	ExecuteBatchCtx(ctx context.Context, batchType gocql.BatchType, queries []string, params [][]interface{}) error
	ExecuteBatch(gocql.BatchType, []string, [][]interface{}) error
	ExecuteUnloggedBatchCtx(ctx context.Context, queries []string, params [][]interface{}) error
	ExecuteUnloggedBatch([]string, [][]interface{}) error
	ScanQueryCtx(ctx context.Context, queryString string, queryParams []interface{}, outParams ...interface{}) error
	ScanQuery(string, []interface{}, ...interface{}) error
	ScanCASQueryCtx(ctx context.Context, queryString string, queryParams []interface{}, outParams ...interface{}) (applied bool, err error)
	ScanCASQuery(string, []interface{}, ...interface{}) (bool, error)
	IterQueryCtx(ctx context.Context, queryString string, queryParams []interface{}, outParams ...interface{}) func() (idx int, hasNext bool, err error)
	IterQuery(string, []interface{}, ...interface{}) func() (int, bool, error)
	Close() error
	Config() CassandraConfig
	Session() *gocql.Session
}

func NewCassandra

func NewCassandra(config CassandraConfig) (Cassandra, error)

type CassandraConfig

type CassandraConfig struct {
	// Required Parameters
	Nodes                    []string         `json:"nodes"`                        // addresses for the initial connections
	DataCenter               string           `json:"datacenter" config:"optional"` // data center name
	Keyspace                 string           `json:"keyspace"`                     // initial keyspace
	ReadConsistency          string           `json:"readconsistency"`              // consistency for read operations
	WriteConsistency         string           `json:"writeconsistency"`             // consistency for write operations
	SessionConsistency       string           `json:"session_consistency"`          // consistency that applies to all operations if no read or write consistency is set
	Timeout                  string           `json:"timeout"`                      // connection timeout (default: 600ms)
	ConnectTimeout           string           `json:"connect_timeout"`              // initial connection timeout (default: 600ms)
	KeepAlive                string           `json:"keepalive"`                    // The keepalive period to use default: 0
	NumConns                 int              `json:"numconns"`                     // number of connections per host (default: 2)
	Port                     int              `json:"port"`                         // port to connect to, default: 9042
	NumRetries               int              `json:"num_retries"`                  // number of retries in case of connection timeout
	DisableInitialHostLookup bool             `json:"disableinitialhostlookup"`     // Don't preform ip address discovery on the cluster, just use the Nodes provided
	PreferRPCAddress         bool             `json:"prefer_rpc_address"`           // Prefer to connect to rpc_addresses during cluster discovery
	PoolConfig               gocql.PoolConfig `json:""`
	// Authentication
	Username string `json:"username"`
	Password string `json:"password"`

	// SSL Options
	Ssl CassandraSslConfig `json:"ssl"` // ssl options cert/key/ca ...

	// TestMode affects whether a keyspace creation will be attempted on Cassandra initialization.
	TestMode bool `config:"optional"`
}

CassandraConfig is a json and yaml friendly configuration struct

func (CassandraConfig) String

func (c CassandraConfig) String() string

type CassandraSslConfig added in v1.3.0

type CassandraSslConfig struct {
	Enabled bool
	Options *gocql.SslOptions
}

type TestErrorCassandra

type TestErrorCassandra struct{}

func (*TestErrorCassandra) Close

func (c *TestErrorCassandra) Close() error

func (*TestErrorCassandra) Config

func (c *TestErrorCassandra) Config() CassandraConfig

func (*TestErrorCassandra) ExecuteBatch

func (c *TestErrorCassandra) ExecuteBatch(batchType gocql.BatchType, queries []string, params [][]interface{}) error

func (*TestErrorCassandra) ExecuteBatchCtx added in v1.9.0

func (c *TestErrorCassandra) ExecuteBatchCtx(_ context.Context, batchType gocql.BatchType, queries []string, params [][]interface{}) error

func (*TestErrorCassandra) ExecuteQuery

func (c *TestErrorCassandra) ExecuteQuery(queryString string, queryParams ...interface{}) error

func (*TestErrorCassandra) ExecuteQueryCtx added in v1.6.0

func (c *TestErrorCassandra) ExecuteQueryCtx(_ context.Context, queryString string, queryParams ...interface{}) error

func (*TestErrorCassandra) ExecuteUnloggedBatch

func (c *TestErrorCassandra) ExecuteUnloggedBatch(queries []string, params [][]interface{}) error

func (*TestErrorCassandra) ExecuteUnloggedBatchCtx added in v1.9.0

func (c *TestErrorCassandra) ExecuteUnloggedBatchCtx(_ context.Context, queries []string, params [][]interface{}) error

func (*TestErrorCassandra) IterQuery

func (c *TestErrorCassandra) IterQuery(queryString string, queryParams []interface{}, outParams ...interface{}) func() (int, bool, error)

func (*TestErrorCassandra) IterQueryCtx added in v1.9.0

func (c *TestErrorCassandra) IterQueryCtx(_ context.Context, queryString string, queryParams []interface{}, outParams ...interface{}) func() (int, bool, error)

func (*TestErrorCassandra) Query

func (c *TestErrorCassandra) Query(consistency gocql.Consistency, queryString string, queryParams ...interface{}) *gocql.Query

func (*TestErrorCassandra) QueryCtx added in v1.9.0

func (c *TestErrorCassandra) QueryCtx(_ context.Context, consistency gocql.Consistency, queryString string, queryParams ...interface{}) *gocql.Query

func (*TestErrorCassandra) ScanCASQuery

func (c *TestErrorCassandra) ScanCASQuery(queryString string, queryParams []interface{}, outParams ...interface{}) (bool, error)

func (*TestErrorCassandra) ScanCASQueryCtx added in v1.9.0

func (c *TestErrorCassandra) ScanCASQueryCtx(_ context.Context, queryString string, queryParams []interface{}, outParams ...interface{}) (bool, error)

func (*TestErrorCassandra) ScanQuery

func (c *TestErrorCassandra) ScanQuery(queryString string, queryParams []interface{}, outParams ...interface{}) error

func (*TestErrorCassandra) ScanQueryCtx added in v1.8.0

func (c *TestErrorCassandra) ScanQueryCtx(_ context.Context, queryString string, queryParams []interface{}, outParams ...interface{}) error

func (*TestErrorCassandra) Session added in v1.2.1

func (c *TestErrorCassandra) Session() *gocql.Session

Jump to

Keyboard shortcuts

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