scylla

package module
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

Scylla Go driver

Experimental high performance Scylla driver in Go.

Documentation

Index

Constants

View Source
const (
	// ErrCodeServer indicates unexpected error on server-side.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1051-L1052
	ErrCodeServer frame.ErrorCode = 0x0000

	// ErrCodeProtocol indicates a protocol violation by some client message.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1053-L1055
	ErrCodeProtocol frame.ErrorCode = 0x000A

	// ErrCodeCredentials indicates missing required authentication.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1056-L1059
	ErrCodeCredentials frame.ErrorCode = 0x0100

	// ErrCodeUnavailable indicates unavailable error.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1060-L1070
	ErrCodeUnavailable frame.ErrorCode = 0x1000

	// ErrCodeOverloaded returned in case of request on overloaded node coordinator.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1071-L1072
	ErrCodeOverloaded frame.ErrorCode = 0x1001

	// ErrCodeBootstrapping returned from the coordinator node in bootstrapping phase.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1073-L1074
	ErrCodeBootstrapping frame.ErrorCode = 0x1002

	// ErrCodeTruncate indicates truncation exception.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1075
	ErrCodeTruncate frame.ErrorCode = 0x1003

	// ErrCodeWriteTimeout returned in case of timeout during the request write.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1076-L1107
	ErrCodeWriteTimeout frame.ErrorCode = 0x1100

	// ErrCodeReadTimeout returned in case of timeout during the request read.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1108-L1124
	ErrCodeReadTimeout frame.ErrorCode = 0x1200

	// ErrCodeReadFailure indicates request read error which is not covered by ErrCodeReadTimeout.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1125-L1139
	ErrCodeReadFailure frame.ErrorCode = 0x1300

	// ErrCodeFunctionFailure indicates an error in user-defined function.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1140-L1146
	ErrCodeFunctionFailure frame.ErrorCode = 0x1400

	// ErrCodeWriteFailure indicates request write error which is not covered by ErrCodeWriteTimeout.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1147-L1180
	ErrCodeWriteFailure frame.ErrorCode = 0x1500

	// ErrCodeSyntax indicates the syntax error in the query.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1182
	ErrCodeSyntax frame.ErrorCode = 0x2000

	// ErrCodeUnauthorized indicates access rights violation by user on performed operation.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1183-L1184
	ErrCodeUnauthorized frame.ErrorCode = 0x2100

	// ErrCodeInvalid indicates invalid query error which is not covered by ErrCodeSyntax.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1185
	ErrCodeInvalid frame.ErrorCode = 0x2200

	// ErrCodeConfig indicates the configuration error.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1186
	ErrCodeConfig frame.ErrorCode = 0x2300

	// ErrCodeAlreadyExists is returned for the requests creating the existing keyspace/table.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1187-L1196
	ErrCodeAlreadyExists frame.ErrorCode = 0x2400

	// ErrCodeUnprepared returned from the host for prepared statement which is unknown.
	// See https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1197-L1200
	ErrCodeUnprepared frame.ErrorCode = 0x2500
)

See CQL Binary Protocol v4, section 9 for more details. https://github.com/apache/cassandra/blob/adcff3f630c0d07d1ba33bf23fcb11a6db1b9af1/doc/native_protocol_v4.spec#L1046-L1200

Variables

View Source
var (
	ErrClosedIter = fmt.Errorf("iter is closed")
	ErrNoMoreRows = fmt.Errorf("no more rows left")
)
View Source
var (
	ErrNoHosts   = fmt.Errorf("error in session config: no hosts given")
	ErrEventType = fmt.Errorf("error in session config: invalid event\npossible events:\n" +
		"TopologyChange EventType = \"TOPOLOGY_CHANGE\"\n" +
		"StatusChange   EventType = \"STATUS_CHANGE\"\n" +
		"SchemaChange   EventType = \"SCHEMA_CHANGE\"")
	ErrConsistency = fmt.Errorf("error in session config: invalid consistency\npossible consistencies are:\n" +
		"ANY         Consistency = 0x0000\n" +
		"ONE         Consistency = 0x0001\n" +
		"TWO         Consistency = 0x0002\n" +
		"THREE       Consistency = 0x0003\n" +
		"QUORUM      Consistency = 0x0004\n" +
		"ALL         Consistency = 0x0005\n" +
		"LOCALQUORUM Consistency = 0x0006\n" +
		"EACHQUORUM  Consistency = 0x0007\n" +
		"SERIAL      Consistency = 0x0008\n" +
		"LOCALSERIAL Consistency = 0x0009\n" +
		"LOCALONE    Consistency = 0x000A")
)
View Source
var ErrNoQueryResults = fmt.Errorf("no query results to be fetched")

Functions

This section is empty.

Types

type Compression

type Compression = frame.Compression
var (
	Snappy Compression = frame.Snappy
	Lz4    Compression = frame.Lz4
)

type Consistency

type Consistency = uint16
const (
	ANY         Consistency = 0x0000
	ONE         Consistency = 0x0001
	TWO         Consistency = 0x0002
	THREE       Consistency = 0x0003
	QUORUM      Consistency = 0x0004
	ALL         Consistency = 0x0005
	LOCALQUORUM Consistency = 0x0006
	EACHQUORUM  Consistency = 0x0007
	SERIAL      Consistency = 0x0008
	LOCALSERIAL Consistency = 0x0009
	LOCALONE    Consistency = 0x000A
)

type DebugLogger

type DebugLogger = transport.DebugLogger

type DefaultLogger

type DefaultLogger = transport.DefaultLogger

type EventType

type EventType = string
const (
	TopologyChange EventType = "TOPOLOGY_CHANGE"
	StatusChange   EventType = "STATUS_CHANGE"
	SchemaChange   EventType = "SCHEMA_CHANGE"
)

type Iter

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

func (*Iter) Close

func (it *Iter) Close() error

func (*Iter) Columns

func (it *Iter) Columns() []frame.ColumnSpec

func (*Iter) Next

func (it *Iter) Next() (frame.Row, error)

func (*Iter) NumRows

func (it *Iter) NumRows() int

func (*Iter) PageState

func (it *Iter) PageState() []byte

type Query

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

func (*Query) AsyncExec

func (q *Query) AsyncExec(ctx context.Context)

func (*Query) Bind

func (q *Query) Bind(pos int, v Serializable) *Query

BindAny allows binding any value to the bind marker at given pos in query, it shouldn't be used on non-prepared queries, as it will always result in query execution error later.

func (*Query) BindInt64

func (q *Query) BindInt64(pos int, v int64) *Query

func (*Query) Compression

func (q *Query) Compression() bool

func (*Query) Exec

func (q *Query) Exec(ctx context.Context) (Result, error)

func (*Query) Fetch

func (q *Query) Fetch() (Result, error)

Fetch returns results in the same order they were queried.

func (*Query) Idempotent added in v0.1.5

func (q *Query) Idempotent() bool

func (*Query) Iter

func (q *Query) Iter(ctx context.Context) Iter

func (*Query) NoSkipMetadata

func (q *Query) NoSkipMetadata() *Query

func (*Query) PageSize

func (q *Query) PageSize() int32

func (*Query) PageState

func (q *Query) PageState() []byte

func (*Query) Prepare

func (q *Query) Prepare(ctx context.Context) error

func (*Query) RetryPolicy added in v0.1.9

func (q *Query) RetryPolicy() transport.RetryPolicy

func (*Query) SerialConsistency

func (q *Query) SerialConsistency(v frame.Consistency) frame.Consistency

func (*Query) SetCompression

func (q *Query) SetCompression(v bool)

func (*Query) SetIdempotent added in v0.1.5

func (q *Query) SetIdempotent(v bool)

func (*Query) SetPageSize

func (q *Query) SetPageSize(v int32)

func (*Query) SetPageState

func (q *Query) SetPageState(v []byte)

func (*Query) SetRetryPolicy added in v0.1.9

func (q *Query) SetRetryPolicy(v transport.RetryPolicy) *Query

func (*Query) SetSerialConsistency

func (q *Query) SetSerialConsistency(v frame.Consistency)

type Result

type Result transport.QueryResult

type Serializable

type Serializable interface {
	Serialize(*frame.Option) (n int32, bytes []byte, err error)
}

type Session

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

func NewSession

func NewSession(ctx context.Context, cfg SessionConfig) (*Session, error)

func (*Session) AwaitSchemaAgreement added in v0.1.5

func (s *Session) AwaitSchemaAgreement(ctx context.Context, timeout time.Duration) error

func (*Session) CheckSchemaAgreement added in v0.1.5

func (s *Session) CheckSchemaAgreement(ctx context.Context) (bool, error)

func (*Session) Close

func (s *Session) Close()

func (*Session) Closed added in v0.1.6

func (s *Session) Closed() bool

func (*Session) NewTokenAwareDCAwarePolicy

func (s *Session) NewTokenAwareDCAwarePolicy(localDC string) transport.HostSelectionPolicy

func (*Session) NewTokenAwarePolicy

func (s *Session) NewTokenAwarePolicy() transport.HostSelectionPolicy

func (*Session) Prepare

func (s *Session) Prepare(ctx context.Context, content string) (Query, error)

func (*Session) Query

func (s *Session) Query(content string) Query

type SessionConfig

type SessionConfig struct {
	Hosts               []string
	Events              []EventType
	HostSelectionPolicy transport.HostSelectionPolicy
	RetryPolicy         transport.RetryPolicy

	SchemaAgreementInterval time.Duration
	// Controls the timeout for the automatic wait for schema agreement after sending a schema-altering statement.
	// If less or equal to 0, the automatic schema agreement is disabled.
	AutoAwaitSchemaAgreementTimeout time.Duration

	transport.ConnConfig
}

func DefaultSessionConfig

func DefaultSessionConfig(keyspace string, hosts ...string) SessionConfig

func (SessionConfig) Clone

func (cfg SessionConfig) Clone() SessionConfig

func (*SessionConfig) Validate

func (cfg *SessionConfig) Validate() error

Directories

Path Synopsis
experiments

Jump to

Keyboard shortcuts

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