cassandra

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package redis provides implementation of Go API for redis interface

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is a alias of gocql.ErrNotFound.
	ErrNotFound = gocql.ErrNotFound
	// ErrUnavailable is a alias of gocql.ErrUnavailable.
	ErrUnavailable = gocql.ErrUnavailable
	// ErrUnsupported is a alias of gocql.ErrUnsupported.
	ErrUnsupported = gocql.ErrUnsupported
	// ErrTooManyStmts is a alias of gocql.ErrTooManyStmts.
	ErrTooManyStmts = gocql.ErrTooManyStmts
	// ErrUseStmt is a alias of gocql.ErrUseStmt.
	ErrUseStmt = gocql.ErrUseStmt
	// ErrSessionClosed is a alias of gocql.ErrSessionClosed.
	ErrSessionClosed = gocql.ErrSessionClosed
	// ErrNoConnections is a alias of gocql.ErrNoConnections.
	ErrNoConnections = gocql.ErrNoConnections
	// ErrNoKeyspace is a alias of gocql.ErrNoKeyspace.
	ErrNoKeyspace = gocql.ErrNoKeyspace
	// ErrKeyspaceDoesNotExist is a alias of gocql.ErrKeyspaceDoesNotExist.
	ErrKeyspaceDoesNotExist = gocql.ErrKeyspaceDoesNotExist
	// ErrNoMetadata is a alias of gocql.ErrNoMetadata.
	ErrNoMetadata = gocql.ErrNoMetadata
	// ErrNoHosts is a alias of gocql.ErrNoHosts.
	ErrNoHosts = gocql.ErrNoHosts
	// ErrNoConnectionsStarted is a alias of gocql.ErrNoConnectionsStarted.
	ErrNoConnectionsStarted = gocql.ErrNoConnectionsStarted
	// ErrHostQueryFailed is a alias of gocql.ErrHostQueryFailed.
	ErrHostQueryFailed = gocql.ErrHostQueryFailed
)

Functions

func NewConvictionPolicy added in v0.0.27

func NewConvictionPolicy() gocql.ConvictionPolicy

NewConvictionPolicy returns the implementation of gocql.ConvictionPolicy.

func Select

func Select(table string, columns []string, cmps ...Cmp) (stmt string, names []string)

Select build and returns the cql string and the named args.

func WrapErrorWithKeys added in v0.0.26

func WrapErrorWithKeys(err error, keys ...string) error

WrapErrorWithKeys wraps the cassandra error to Vald internal error.

Types

type BatchBuilder

type BatchBuilder = qb.BatchBuilder

BatchBuilder is a alias of qb.BatchBuilder.

func Batch

func Batch() *BatchBuilder

Batch returns the batch builder.

type BatchObserver added in v0.0.50

type BatchObserver = gocql.BatchObserver

type Cassandra

type Cassandra interface {
	Open(ctx context.Context) error
	Close(ctx context.Context) error
	Query(stmt string, names []string) *Queryx
}

Cassandra represent an interface to query on cassandra.

func New

func New(opts ...Option) (Cassandra, error)

New initialize and return the cassandra client, or any error occurred.

type ClusterConfig added in v0.0.63

type ClusterConfig interface {
	CreateSession() (*gocql.Session, error)
}

ClusterConfig represent an interface of cassandra cluster configuation.

type Cmp

type Cmp = qb.Cmp

Cmp is a alias of qb.Cmp.

func Contains

func Contains(column string) Cmp

Contains return the contains comparator.

func Eq

func Eq(column string) Cmp

Eq returns the equal comparator.

func In added in v0.0.26

func In(column string) Cmp

In returns the in comparator.

type ConnectObserver added in v0.0.50

type ConnectObserver = gocql.ConnectObserver

type DeleteBuilder

type DeleteBuilder = qb.DeleteBuilder

DeleteBuilder is a alias of qb.DeleteBuilder.

func Delete

func Delete(table string, cmps ...Cmp) *DeleteBuilder

Delete returns the delete builder.

type Deleter

type Deleter interface {
	DeleteByKeys(keys ...string) ([]string, error)
	DeleteByValues(values ...string) ([]string, error)
}

type DialerMock added in v1.0.5

type DialerMock struct {
	DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
}

func (*DialerMock) DialContext added in v1.0.5

func (dm *DialerMock) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

func (*DialerMock) GetDialer added in v1.0.5

func (dm *DialerMock) GetDialer() func(ctx context.Context, network, addr string) (net.Conn, error)

func (*DialerMock) StartDialerCache added in v1.0.5

func (dm *DialerMock) StartDialerCache(ctx context.Context)

type FrameHeaderObserver added in v0.0.50

type FrameHeaderObserver = gocql.FrameHeaderObserver

type InsertBuilder

type InsertBuilder = qb.InsertBuilder

InsertBuilder is a alias of qb.InsertBuilder.

func Insert

func Insert(table string, columns ...string) *InsertBuilder

Insert returns the insert builder.

type MockClusterConfig added in v0.0.63

type MockClusterConfig struct {
	CreateSessionFunc func() (*gocql.Session, error)
}

func (*MockClusterConfig) CreateSession added in v0.0.63

func (m *MockClusterConfig) CreateSession() (*gocql.Session, error)

type ObservedQuery added in v0.0.50

type ObservedQuery = gocql.ObservedQuery

type Option

type Option func(*client) error

Option represents the functional option for client. It wraps the gocql.ClusterConfig to the function option implementation. Please refer to the following link for more information. https://pkg.go.dev/github.com/gocql/gocql?tab=doc#ClusterConfig

func WithAuthProvider

func WithAuthProvider(authProvider func(h *gocql.HostInfo) (gocql.Authenticator, error)) Option

WithAuthProvider returns the option to set the auth provider.

func WithBatchObserver added in v0.0.50

func WithBatchObserver(obs BatchObserver) Option

WithBatchObserver returns the option to set batch observer.

func WithCQLVersion

func WithCQLVersion(version string) Option

WithCQLVersion returns the option to set the CQL version.

func WithCompressor

func WithCompressor(compressor gocql.Compressor) Option

WithCompressor returns the option to set the compressor.

func WithConnectObserver added in v0.0.50

func WithConnectObserver(obs ConnectObserver) Option

WithConnectObserver returns the option to set connect observer.

func WithConnectTimeout

func WithConnectTimeout(dur string) Option

WithConnectTimeout returns the option to set the cassandra initial connection timeout.

func WithConsistency

func WithConsistency(consistency string) Option

WithConsistency returns the option to set the cassandra consistency level.

func WithDC

func WithDC(name string) Option

WithDC returns the option to set the data center name.

func WithDCAwareRouting added in v0.0.32

func WithDCAwareRouting(dcAwareRouting bool) Option

WithDCAwareRouting returns the option to set the data center aware routing enable flag.

func WithDCHostFilter added in v0.0.34

func WithDCHostFilter(dc string) Option

WithDCHostFilter returns the option to set the DC host filter.

func WithDefaultIdempotence

func WithDefaultIdempotence(defaultIdempotence bool) Option

WithDefaultIdempotence returns the option to set default idempotence flag.

func WithDefaultTimestamp

func WithDefaultTimestamp(defaultTimestamp bool) Option

WithDefaultTimestamp returns the option to set the default timestamp enable flag.

func WithDialer added in v0.0.2

func WithDialer(der net.Dialer) Option

WithDialer returns the option to set the dialer.

func WithDisableInitialHostLookup

func WithDisableInitialHostLookup(disableInitialHostLookup bool) Option

WithDisableInitialHostLookup returns the option to set disable initial host lookup flag.

func WithDisableNodeStatusEvents

func WithDisableNodeStatusEvents(disableNodeStatusEvents bool) Option

WithDisableNodeStatusEvents returns the option to set disable node status events flag.

func WithDisableSchemaEvents

func WithDisableSchemaEvents(disableSchemaEvents bool) Option

WithDisableSchemaEvents returns the option to set disable schema events flag.

func WithDisableSkipMetadata

func WithDisableSkipMetadata(disableSkipMetadata bool) Option

WithDisableSkipMetadata returns the option to set disable skip metadata flag.

func WithDisableTopologyEvents

func WithDisableTopologyEvents(disableTopologyEvents bool) Option

WithDisableTopologyEvents returns the option to set disable topology events flag.

func WithEnableHostVerification

func WithEnableHostVerification(enableHostVerification bool) Option

WithEnableHostVerification returns the option to set the host verification enable flag.

func WithFrameHeaderObserver added in v0.0.50

func WithFrameHeaderObserver(obs FrameHeaderObserver) Option

WithFrameHeaderObserver returns the option to set FrameHeader observer.

func WithHostFilter added in v0.0.34

func WithHostFilter(flg bool) Option

WithHostFilter returns the option to set the host filter enable flag.

func WithHosts

func WithHosts(hosts ...string) Option

WithHosts returns the option to set the hosts.

func WithIgnorePeerAddr

func WithIgnorePeerAddr(ignorePeerAddr bool) Option

WithIgnorePeerAddr returns the option to set ignore peer address flag.

func WithKeyspace

func WithKeyspace(keyspace string) Option

WithKeyspace returns the option to set the keyspace.

func WithMaxPreparedStmts

func WithMaxPreparedStmts(maxPreparedStmts int) Option

WithMaxPreparedStmts returns the option to set the max prepared statement.

func WithMaxRoutingKeyInfo

func WithMaxRoutingKeyInfo(maxRoutingKeyInfo int) Option

WithMaxRoutingKeyInfo returns the option to set the max routing key info.

func WithMaxWaitSchemaAgreement

func WithMaxWaitSchemaAgreement(maxWaitSchemaAgreement string) Option

WithMaxWaitSchemaAgreement returns the option to set the max wait schema agreement.

func WithNonLocalReplicasFallback added in v0.0.32

func WithNonLocalReplicasFallback(nonLocalReplicasFallBack bool) Option

WithNonLocalReplicasFallback returns the option to set the non local replicas fallback enable flag.

func WithNumConns

func WithNumConns(numConns int) Option

WithNumConns returns the option to set the number of connection per host.

func WithPageSize

func WithPageSize(pageSize int) Option

WithPageSize returns the option to set the page size.

func WithPassword

func WithPassword(password string) Option

WithPassword returns the option to set the password.

func WithPort

func WithPort(port int) Option

WithPort returns the option to set the port number.

func WithProtoVersion

func WithProtoVersion(version int) Option

WithProtoVersion returns the option to set the proto version.

func WithQueryObserver added in v0.0.50

func WithQueryObserver(obs QueryObserver) Option

WithQueryObserver returns the option to set query observer.

func WithReconnectInterval

func WithReconnectInterval(reconnectInterval string) Option

WithReconnectInterval returns the option to set the reconnect interval.

func WithReconnectionPolicyInitialInterval

func WithReconnectionPolicyInitialInterval(initialInterval string) Option

WithReconnectionPolicyInitialInterval returns the option to set the reconnect initial interval.

func WithReconnectionPolicyMaxRetries

func WithReconnectionPolicyMaxRetries(maxRetries int) Option

WithReconnectionPolicyMaxRetries returns the option to set the reconnect max retries.

func WithRetryPolicyMaxDuration

func WithRetryPolicyMaxDuration(maxDuration string) Option

WithRetryPolicyMaxDuration returns the option to set the retry max duration.

func WithRetryPolicyMinDuration

func WithRetryPolicyMinDuration(minDuration string) Option

WithRetryPolicyMinDuration returns the option to set the retry min duration.

func WithRetryPolicyNumRetries

func WithRetryPolicyNumRetries(n int) Option

WithRetryPolicyNumRetries returns the option to set the number of retries.

func WithSerialConsistency

func WithSerialConsistency(consistency string) Option

WithSerialConsistency returns the option to set the cassandra serial consistency level.

func WithShuffleReplicas added in v0.0.32

func WithShuffleReplicas(shuffleReplicas bool) Option

WithShuffleReplicas returns the option to set the shuffle replicas enable flag.

func WithSocketKeepalive

func WithSocketKeepalive(socketKeepalive string) Option

WithSocketKeepalive returns the option to set the socket keepalive time.

func WithTLS

func WithTLS(tls *tls.Config) Option

WithTLS returns the option to set the TLS config.

func WithTLSCAPath

func WithTLSCAPath(caPath string) Option

WithTLSCAPath returns the option to set the TLS CA path.

func WithTLSCertPath

func WithTLSCertPath(certPath string) Option

WithTLSCertPath returns the option to set the TLS cert path.

func WithTLSKeyPath

func WithTLSKeyPath(keyPath string) Option

WithTLSKeyPath returns the option to set the TLS key path.

func WithTimeout

func WithTimeout(dur string) Option

WithTimeout returns the option to set the cassandra connect timeout time.

func WithTokenAwareHostPolicy added in v0.0.34

func WithTokenAwareHostPolicy(tokenAwareHostPolicy bool) Option

WithTokenAwareHostPolicy returns the option to set the token aware host policy enable flag.

func WithUsername

func WithUsername(username string) Option

WithUsername returns the option to set the username.

func WithWhiteListHostFilter added in v0.0.34

func WithWhiteListHostFilter(list []string) Option

WithWhiteListHostFilter returns the option to set the white list host filter.

func WithWriteCoalesceWaitTime

func WithWriteCoalesceWaitTime(writeCoalesceWaitTime string) Option

WithWriteCoalesceWaitTime returns the option to set the write coalesce wait time.

type QueryObserver added in v0.0.50

type QueryObserver = gocql.QueryObserver

type Queryx

type Queryx = gocqlx.Queryx

Queryx is a alias of gocqlx.Queryx.

type Session

type Session = gocql.Session

Session is a alias of gocql.Session.

type UpdateBuilder

type UpdateBuilder = qb.UpdateBuilder

UpdateBuilder is a alias of qb.UpdateBuilder.

func Update

func Update(table string) *UpdateBuilder

Update returns the update builder.

Jump to

Keyboard shortcuts

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