Documentation ¶
Index ¶
- Constants
- Variables
- func RandomShardPort(si ShardInfo) uint16
- func ShardPortIterator(si ShardInfo) func() uint16
- func WrapTLS(ctx context.Context, conn *net.TCPConn, cfg *tls.Config) (net.Conn, error)
- type Cluster
- func (c *Cluster) Close()
- func (c *Cluster) Closed() bool
- func (c *Cluster) NewControl(ctx context.Context) (*Conn, error)
- func (c *Cluster) NewQueryInfo() QueryInfo
- func (c *Cluster) NewTokenAwareQueryInfo(t Token, ks string) (QueryInfo, error)
- func (c *Cluster) RequestRefresh()
- func (c *Cluster) RequestReopenControl()
- func (c *Cluster) Topology() *topology
- type Conn
- func OpenConn(ctx context.Context, addr string, localAddr *net.TCPAddr, cfg ConnConfig) (*Conn, error)
- func OpenLocalPortConn(ctx context.Context, addr string, localPort uint16, cfg ConnConfig) (*Conn, error)
- func OpenShardConn(ctx context.Context, addr string, si ShardInfo, cfg ConnConfig) (*Conn, error)
- func WrapConn(ctx context.Context, conn net.Conn, cfg ConnConfig) (*Conn, error)
- func (c *Conn) AsyncExecute(ctx context.Context, s Statement, pagingState frame.Bytes, h ResponseHandler)
- func (c *Conn) AsyncQuery(ctx context.Context, s Statement, pagingState frame.Bytes, h ResponseHandler)
- func (c *Conn) AuthResponse(ctx context.Context, a *Authenticate) error
- func (c *Conn) Close()
- func (c *Conn) Event() ConnEvent
- func (c *Conn) Execute(ctx context.Context, s Statement, pagingState frame.Bytes) (QueryResult, error)
- func (c *Conn) Prepare(ctx context.Context, s Statement) (Statement, error)
- func (c *Conn) Query(ctx context.Context, s Statement, pagingState frame.Bytes) (QueryResult, error)
- func (c *Conn) RegisterEventHandler(ctx context.Context, h func(context.Context, response), e ...frame.EventType) error
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) Shard() int
- func (c *Conn) Startup(ctx context.Context, options frame.StartupOptions) error
- func (c *Conn) String() string
- func (c *Conn) Supported(ctx context.Context) (*Supported, error)
- func (c *Conn) UseKeyspace(ctx context.Context, ks string) error
- func (c *Conn) Waiting() int
- type ConnConfig
- type ConnEvent
- type ConnObserver
- type ConnPool
- type ConnectEvent
- type DebugLogger
- type DefaultLogger
- type DefaultRetryDecider
- type DefaultRetryPolicy
- type FallthroughRetryDecider
- type FallthroughRetryPolicy
- type HostSelectionPolicy
- type Logger
- type LoggingConnObserver
- type Node
- func (n *Node) Close()
- func (n *Node) Conn(qi QueryInfo) (*Conn, error)
- func (n *Node) FetchSchemaVersion(ctx context.Context) (frame.UUID, error)
- func (n *Node) Init(ctx context.Context, cfg ConnConfig)
- func (n *Node) IsUp() bool
- func (n *Node) LeastBusyConn() (*Conn, error)
- func (n *Node) Prepare(ctx context.Context, s Statement) (Statement, error)
- type PoolRefiller
- type QueryInfo
- type QueryResult
- type ResponseHandler
- type RetryDecider
- type RetryDecision
- type RetryInfo
- type RetryPolicy
- type Ring
- type RingEntry
- type ShardInfo
- type Statement
- type Token
- type TokenAwarePolicy
Constants ¶
const UnknownShard = uint16(1<<16 - 1)
Variables ¶
var ( ErrComprCorrupt = errors.New("compression: corrupt input") ErrComprUnknown = errors.New("compression: unknown algorithm") )
var Now = time.Now
Functions ¶
func RandomShardPort ¶
RandomShardPort returns randomly generated port that can be used to establish connection to a specific shard on scylla node.
func ShardPortIterator ¶
ShardPortIterator returns iterator for consecutive ports that are mapped to a specific shard on scylla node.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func NewCluster ¶
func NewCluster(ctx context.Context, cfg ConnConfig, p HostSelectionPolicy, e []frame.EventType, hosts ...string) (*Cluster, error)
NewCluster also creates control connection and starts handling events and refreshing topology.
func (*Cluster) NewQueryInfo ¶
func (*Cluster) NewTokenAwareQueryInfo ¶
func (*Cluster) RequestRefresh ¶
func (c *Cluster) RequestRefresh()
func (*Cluster) RequestReopenControl ¶
func (c *Cluster) RequestReopenControl()
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func OpenConn ¶
func OpenConn(ctx context.Context, addr string, localAddr *net.TCPAddr, cfg ConnConfig) (*Conn, error)
OpenConn opens connection with specific local address. In case lAddr is nil, random local address is used.
If error and connection are returned the connection is not valid and must be closed by the caller.
func OpenLocalPortConn ¶
func OpenLocalPortConn(ctx context.Context, addr string, localPort uint16, cfg ConnConfig) (*Conn, error)
OpenLocalPortConn opens connection on a given local port.
If error and connection are returned the connection is not valid and must be closed by the caller.
func OpenShardConn ¶
OpenShardConn opens connection mapped to a specific shard on Scylla node.
func WrapConn ¶
WrapConn transforms tcp connection to a working Scylla connection. If error and connection are returned the connection is not valid and must be closed by the caller.
func (*Conn) AsyncExecute ¶
func (*Conn) AsyncQuery ¶
func (*Conn) Close ¶
func (c *Conn) Close()
Close closes connection and terminates reader and writer go routines.
func (*Conn) RegisterEventHandler ¶
func (*Conn) RemoteAddr ¶ added in v0.1.5
type ConnConfig ¶
type ConnConfig struct { Username string Password string Keyspace string TCPNoDelay bool Timeout time.Duration // If not nil, all connections will use TLS according to TLSConfig, // please note that the default port (9042) may not support TLS. TLSConfig *tls.Config DefaultConsistency frame.Consistency DefaultPort string Compression frame.Compression ComprBufferSize int ConnObserver ConnObserver Logger Logger WriteCoalesceWaitTime time.Duration }
func DefaultConnConfig ¶
func DefaultConnConfig(keyspace string) ConnConfig
type ConnObserver ¶
type ConnObserver interface { OnConnect(ev ConnectEvent) OnPickReplacedWithLessBusyConn(ev ConnEvent) }
type ConnPool ¶
type ConnPool struct {
// contains filtered or unexported fields
}
func NewConnPool ¶
func (*ConnPool) LeastBusyConn ¶
type ConnectEvent ¶
type DebugLogger ¶
type DebugLogger struct{}
func (DebugLogger) Print ¶
func (n DebugLogger) Print(v ...any)
func (DebugLogger) Printf ¶
func (n DebugLogger) Printf(format string, v ...any)
func (DebugLogger) Println ¶
func (n DebugLogger) Println(v ...any)
type DefaultLogger ¶
type DefaultLogger struct{}
func (DefaultLogger) Print ¶
func (n DefaultLogger) Print(_ ...any)
func (DefaultLogger) Printf ¶
func (n DefaultLogger) Printf(_ string, _ ...any)
func (DefaultLogger) Println ¶
func (n DefaultLogger) Println(_ ...any)
type DefaultRetryDecider ¶
type DefaultRetryDecider struct {
// contains filtered or unexported fields
}
func (*DefaultRetryDecider) Decide ¶
func (d *DefaultRetryDecider) Decide(ri RetryInfo) RetryDecision
func (*DefaultRetryDecider) Reset ¶
func (d *DefaultRetryDecider) Reset()
type DefaultRetryPolicy ¶
type DefaultRetryPolicy struct{}
func (*DefaultRetryPolicy) NewRetryDecider ¶
func (*DefaultRetryPolicy) NewRetryDecider() RetryDecider
type FallthroughRetryDecider ¶
type FallthroughRetryDecider struct{}
func (FallthroughRetryDecider) Decide ¶
func (FallthroughRetryDecider) Decide(_ RetryInfo) RetryDecision
func (FallthroughRetryDecider) Reset ¶
func (FallthroughRetryDecider) Reset()
type FallthroughRetryPolicy ¶
type FallthroughRetryPolicy struct{}
func (*FallthroughRetryPolicy) NewRetryDecider ¶
func (*FallthroughRetryPolicy) NewRetryDecider() RetryDecider
type HostSelectionPolicy ¶
type HostSelectionPolicy interface { // Returns i-th node of the host selection plan, returns nil after going through the whole plan. Node(QueryInfo, int) *Node }
HostSelectionPolicy decides which node the query should be routed to.
type LoggingConnObserver ¶
type LoggingConnObserver struct {
// contains filtered or unexported fields
}
func (LoggingConnObserver) OnConnect ¶
func (o LoggingConnObserver) OnConnect(ev ConnectEvent)
func (LoggingConnObserver) OnPickReplacedWithLessBusyConn ¶
func (o LoggingConnObserver) OnPickReplacedWithLessBusyConn(ev ConnEvent)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) FetchSchemaVersion ¶ added in v0.1.5
func (*Node) LeastBusyConn ¶
type PoolRefiller ¶
type PoolRefiller struct {
// contains filtered or unexported fields
}
type QueryInfo ¶
type QueryInfo struct {
// contains filtered or unexported fields
}
QueryInfo represents data required for host selection policy to create query plan. Token and strategy are only necessary for token aware policies.
type QueryResult ¶
type QueryResult struct { Rows []frame.Row Warnings []string TracingID frame.UUID HasMorePages bool PagingState frame.Bytes ColSpec []frame.ColumnSpec SchemaChange *SchemaChange }
func MakeQueryResult ¶
func MakeQueryResult(res frame.Response, meta *frame.ResultMetadata) (QueryResult, error)
type ResponseHandler ¶
type ResponseHandler chan response
func MakeResponseHandler ¶
func MakeResponseHandler() ResponseHandler
func MakeResponseHandlerWithError ¶
func MakeResponseHandlerWithError(err error) ResponseHandler
type RetryDecider ¶
type RetryDecider interface { Decide(RetryInfo) RetryDecision Reset() }
RetryDecider should be used for just one query that we want to retry. After that it should be discarded or reset.
type RetryDecision ¶
type RetryDecision byte
const ( RetrySameNode RetryDecision = iota RetryNextNode DontRetry )
type RetryInfo ¶
type RetryInfo struct { Error error // Failed query error. Idempotent bool // Is set to true only if we are sure that the query is idempotent. Consistency frame.Consistency // Failed query consistency. }
type RetryPolicy ¶
type RetryPolicy interface {
NewRetryDecider() RetryDecider
}
func NewDefaultRetryPolicy ¶
func NewDefaultRetryPolicy() RetryPolicy
func NewFallthroughRetryPolicy ¶
func NewFallthroughRetryPolicy() RetryPolicy
type Statement ¶
type Token ¶
type Token int64
Token is used to identify both nodes and partitions, it's value is hashed partition key.
func MurmurToken ¶
MurmurToken is a function which given partition key hashes it, using Murmurhash3.
type TokenAwarePolicy ¶
type TokenAwarePolicy struct {
// contains filtered or unexported fields
}
func NewTokenAwarePolicy ¶
func NewTokenAwarePolicy(localDC string) *TokenAwarePolicy