sandra

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 License: Apache-2.0 Imports: 7 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 WaitForTables

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

Types

type Cassandra

type Cassandra interface {
	Query(gocql.Consistency, string, ...interface{}) *gocql.Query
	ExecuteQuery(string, ...interface{}) error
	ExecuteBatch(gocql.BatchType, []string, [][]interface{}) error
	ExecuteUnloggedBatch([]string, [][]interface{}) error
	ScanQuery(string, []interface{}, ...interface{}) error
	ScanCASQuery(string, []interface{}, ...interface{}) (bool, error)
	IterQuery(string, []interface{}, ...interface{}) func() (int, bool, error)
	Close() error
	Config() CassandraConfig
}

func NewCassandra

func NewCassandra(config CassandraConfig) (Cassandra, error)

type CassandraConfig

type CassandraConfig struct {
	// Required Parameters
	Nodes                    []string // addresses for the initial connections
	DataCenter               string   // data center name
	Keyspace                 string   // initial keyspace
	ReadConsistency          string   // consistency for read operations
	WriteConsistency         string   // consistency for write operations
	Timeout                  string   `config:"optional"`                           // connection timeout (default: 600ms)
	ConnectTimeout           string   `config:"optional" yaml:"connect_timeout"`    // initial connection timeout (default: 600ms)
	KeepAlive                string   `config:"optional"`                           // The keepalive period to use default: 0
	NumConns                 int      `config:"optional"`                           // number of connections per host (default: 2)
	Port                     int      `config:"optional"`                           // port to connect to, default: 9042
	NumRetries               int      `config:"optional" yaml:"num_retries"`        // number of retries in case of connection timeout
	DisableInitialHostLookup bool     `config:"optional"`                           // Don't preform ip address discovery on the cluster, just use the Nodes provided
	PreferRPCAddress         bool     `config:"optional" yaml:"prefer_rpc_address"` // Prefer to connect to rpc_addresses during cluster discovery

	// 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 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) ExecuteQuery

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

func (*TestErrorCassandra) ExecuteUnloggedBatch

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

func (*TestErrorCassandra) IterQuery

func (c *TestErrorCassandra) IterQuery(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) ScanCASQuery

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

func (*TestErrorCassandra) ScanQuery

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

Jump to

Keyboard shortcuts

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