impl

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(ctx context.Context, s *Store, funcName string) api.Decorator

Count decorator sends success and failure count metrics

func CreateStoreSession

func CreateStoreSession(
	storeConfig *CassandraConn, keySpace string) (*gocql.Session, error)

CreateStoreSession is to create clusters and connections

func Decorate

func Decorate(ef api.FuncType, decorators ...api.Decorator) api.FuncType

Decorate invokes all the decorators on the function, usage: Decorate(aFunc, Instrument(s), Trace(c, "execute"))()

func Safeguard

func Safeguard(s *Store) api.Decorator

Safeguard ensures that the connection is neither closed nor overflooded

func Trace

func Trace(ctx context.Context, funcName string) api.Decorator

Trace decorator starts a new span for the underlying function call

Types

type CASExecutor

type CASExecutor struct {
	WriteExecutor
}

CASExecutor compare and set

func (CASExecutor) Execute

func (c CASExecutor) Execute(ctx context.Context, stmt api.Statement) (api.ResultSet, error)

Execute CAS insert or update

func (CASExecutor) ExecuteBatch

func (c CASExecutor) ExecuteBatch(ctx context.Context, stmts []api.Statement) (api.ResultSet, error)

ExecuteBatch is not supported with CAS

type CASResultSet

type CASResultSet struct {
	ResultSet
	// contains filtered or unexported fields
}

CASResultSet is returned from a Compare-and-Set operation

func (*CASResultSet) All

func (rs *CASResultSet) All(ctx context.Context) ([]map[string]interface{}, error)

All returns a single result for non-applied CAS operations

func (*CASResultSet) Applied

func (rs *CASResultSet) Applied() bool

Applied shows whether a set was done in a compare-and-set operation

func (*CASResultSet) Next

func (rs *CASResultSet) Next(ctx context.Context) (map[string]interface{}, error)

Next returns the result if cas was not applied

func (*CASResultSet) One

func (rs *CASResultSet) One(ctx context.Context, dest ...interface{}) bool

One is deprecated

func (*CASResultSet) PagingState

func (rs *CASResultSet) PagingState() []byte

PagingState has no value for CAS operations

type CassandraConn

type CassandraConn struct {
	ContactPoints      []string      `yaml:"contactPoints"`
	Port               int           `yaml:"port"`
	Username           string        `yaml:"username"`
	Password           string        `yaml:"password"`
	Consistency        string        `yaml:"consistency"`
	ConnectionsPerHost int           `yaml:"connectionsPerHost"`
	Timeout            time.Duration `yaml:"timeout"`
	SocketKeepalive    time.Duration `yaml:"socketKeepalive"`
	ProtoVersion       int           `yaml:"protoVersion"`
	TTL                time.Duration `yaml:"ttl"`
	LocalDCOnly        bool          `yaml:"localDCOnly"` // deprecated
	DataCenter         string        `yaml:"dataCenter"`  // data center filter
	PageSize           int           `yaml:"pageSize"`
	RetryCount         int           `yaml:"retryCount"`
	HostPolicy         string        `yaml:"hostPolicy"`
	TimeoutLimit       int           `yaml:"timeoutLimit"`  // number of timeouts allowed
	CQLVersion         string        `yaml:"cqlVersion"`    // set only on C* 3.x
	MaxGoRoutines      int           `yaml:"maxGoroutines"` // a capacity limit
}

CassandraConn describes the properties to manage a Cassandra connection.

type Executor

type Executor interface {
	Execute(ctx context.Context, stmt api.Statement) (api.ResultSet, error)
	ExecuteBatch(ctx context.Context, stmts []api.Statement) (api.ResultSet, error)
}

Executor interface. execution sequence is Allowed->{Execute, ExecuteBatch}->PostExecute

type ExecutorBase

type ExecutorBase struct {
	// contains filtered or unexported fields
}

ExecutorBase base for all executors

type Metrics

type Metrics struct {
	ExecuteSuccess tally.Counter
	ExecuteFail    tally.Counter

	ExecuteBatchSuccess tally.Counter
	ExecuteBatchFail    tally.Counter
}

Metrics is a struct for tracking execute statement / executeBatch statements failure / success counters

func NewMetrics

func NewMetrics(scope tally.Scope) Metrics

NewMetrics function creates a Metrics struct

type QueryBuilder

type QueryBuilder struct {
}

QueryBuilder is responsible for building queries

func (*QueryBuilder) Delete

func (s *QueryBuilder) Delete(from string) qb.DeleteBuilder

Delete returns a delete query

func (*QueryBuilder) Insert

func (s *QueryBuilder) Insert(into string) qb.InsertBuilder

Insert returns an insert query

func (*QueryBuilder) Select

func (s *QueryBuilder) Select(columns ...string) qb.SelectBuilder

Select returns a select query

func (*QueryBuilder) Update

func (s *QueryBuilder) Update(table string) qb.UpdateBuilder

Update returns a update query

type ReadExecutor

type ReadExecutor struct {
	ExecutorBase
}

ReadExecutor supports select

func (ReadExecutor) Execute

func (r ReadExecutor) Execute(ctx context.Context, stmt api.Statement) (api.ResultSet, error)

Execute a read statement

func (ReadExecutor) ExecuteBatch

func (r ReadExecutor) ExecuteBatch(ctx context.Context, stmts []api.Statement) (api.ResultSet, error)

ExecuteBatch is not supported on Read

type ResultSet

type ResultSet struct {
	// contains filtered or unexported fields
}

ResultSet is the result of a executed query

func (*ResultSet) All

func (rs *ResultSet) All(ctx context.Context) ([]map[string]interface{}, error)

All returns all results in a SliceMap and cleans up itself. Client will not be able to use the ResultSet after this call.

func (*ResultSet) Applied

func (rs *ResultSet) Applied() bool

Applied shows whether a set was done in a compare-and-set operation

func (*ResultSet) Close

func (rs *ResultSet) Close() error

Close closes the iterator and returns any errors that happened during the query or the iteration.

func (*ResultSet) Next

func (rs *ResultSet) Next(ctx context.Context) (map[string]interface{}, error)

Next returns the next row out of the ResultSet. an empty map is returned if there is nothing left.

func (*ResultSet) One

func (rs *ResultSet) One(ctx context.Context, dest ...interface{}) bool

One is deprecated. use Next instead

func (*ResultSet) PagingState

func (rs *ResultSet) PagingState() []byte

PagingState returns the pagination token as opaque bytes so that caller can pass in for future queries.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store represents connections with Cassandra server nodes. the store object is used by multiple go routines. concurrency represents number of active go routines using the store.

func CreateStore

func CreateStore(storeConfig *CassandraConn, keySpace string, scope tally.Scope) (*Store, error)

CreateStore is to create clusters and connections

func (*Store) Execute

func (s *Store) Execute(ctx context.Context, stmt api.Statement) (api.ResultSet, error)

Execute a query and return a ResultSet

func (*Store) ExecuteBatch

func (s *Store) ExecuteBatch(ctx context.Context, stmts []api.Statement) error

ExecuteBatch make a single RPC call for multiple statement execution. It ensures all statements are eventually executed

func (*Store) Name

func (s *Store) Name() string

Name returns the name of this datastore

func (*Store) NewEntity

func (s *Store) NewEntity() api.Table

NewEntity creates a Table object

func (*Store) NewQuery

func (s *Store) NewQuery() api.QueryBuilder

NewQuery creates a QueryBuilder object

func (*Store) String

func (s *Store) String() string

String returns a string representation of the store object

type WriteExecutor

type WriteExecutor struct {
	ExecutorBase
}

WriteExecutor supports insert/update/delete

func (WriteExecutor) Execute

func (w WriteExecutor) Execute(ctx context.Context, stmt api.Statement) (api.ResultSet, error)

Execute a write

func (WriteExecutor) ExecuteBatch

func (w WriteExecutor) ExecuteBatch(ctx context.Context, stmts []api.Statement) (api.ResultSet, error)

ExecuteBatch sends batch of write operations

Jump to

Keyboard shortcuts

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