Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeType(dt datatype.DataType, version primitive.ProtocolVersion, bytes []byte) (interface{}, error)
- func EncodeType(dt datatype.DataType, version primitive.ProtocolVersion, val interface{}) ([]byte, error)
- func GetOrCreateNopLogger(logger *zap.Logger) *zap.Logger
- func LookupEndpoint(endpoint Endpoint) (string, error)
- func MockDefaultOptionsHandler(_ *MockClient, _ *frame.Frame) message.Message
- func MockDefaultQueryHandler(cl *MockClient, frm *frame.Frame) message.Message
- func MockDefaultRegisterHandler(cl *MockClient, frm *frame.Frame) message.Message
- func MockDefaultStartupHandler(_ *MockClient, _ *frame.Frame) message.Message
- type AddEvent
- type Authenticator
- type BootstrapEvent
- type ClientConn
- func (c *ClientConn) Close() error
- func (c *ClientConn) Closing(err error)
- func (c *ClientConn) Err() error
- func (c *ClientConn) Handshake(ctx context.Context, version primitive.ProtocolVersion, auth Authenticator) (primitive.ProtocolVersion, error)
- func (c *ClientConn) Heartbeats(connectTimeout time.Duration, version primitive.ProtocolVersion, ...)
- func (c *ClientConn) Inflight() int32
- func (c *ClientConn) IsClosed() chan struct{}
- func (c *ClientConn) Query(ctx context.Context, version primitive.ProtocolVersion, query message.Message) (*ResultSet, error)
- func (c *ClientConn) QueryFrame(ctx context.Context, frm *frame.Frame) (*ResultSet, error)
- func (c *ClientConn) Receive(reader io.Reader) error
- func (c *ClientConn) Send(request Request) error
- func (c *ClientConn) SendAndReceive(ctx context.Context, f *frame.Frame) (*frame.Frame, error)
- func (c *ClientConn) SetKeyspace(ctx context.Context, version primitive.ProtocolVersion, keyspace string) error
- type ClientConnConfig
- type Cluster
- type ClusterConfig
- type ClusterInfo
- type ClusterListener
- type ClusterListenerFunc
- type Conn
- type CqlError
- type Endpoint
- type EndpointResolver
- type Event
- type EventHandler
- type EventHandlerFunc
- type Host
- type LoadBalancer
- type MockClient
- func (c *MockClient) Closing(_ error)
- func (c *MockClient) InterceptQuery(hdr *frame.Header, msg *message.Query) message.Message
- func (c MockClient) Keyspace() string
- func (c MockClient) Local() MockHost
- func (c *MockClient) Receive(reader io.Reader) error
- func (c *MockClient) Register(version primitive.ProtocolVersion)
- type MockCluster
- type MockHost
- type MockRequestHandler
- type MockRequestHandlers
- type MockServer
- type PreparedCache
- type PreparedEntry
- type QueryPlan
- type Receiver
- type ReconnectEvent
- type ReconnectPolicy
- type RemoveEvent
- type Request
- type ResultSet
- type Row
- type SchemaChangeEvent
- type Sender
- type SenderFunc
- type Session
- type SessionConfig
- type UnexpectedResponse
- type UpEvent
Constants ¶
View Source
const ( DefaultRefreshWindow = 10 * time.Second DefaultRefreshTimeout = 5 * time.Second )
View Source
const ( MaxMessages = 1024 MaxCoalesceSize = 16 * 1024 // TODO: What's a good value for this? )
View Source
const (
MaxStreams = 2048
)
Variables ¶
View Source
var ( Closed = errors.New("connection closed") AlreadyClosed = errors.New("connection already closed") )
View Source
var ( StreamsExhausted = errors.New("streams exhausted") AuthExpected = errors.New("authentication required, but no authenticator provided") ProtocolNotSupported = errors.New("required protocol version is not supported") )
View Source
var ( ColumnNameNotFound = errors.New("column name not found") ColumnIsNull = errors.New("column is null") )
View Source
var DefaultMockRequestHandlers = MockRequestHandlers{ primitive.OpCodeOptions: MockDefaultOptionsHandler, primitive.OpCodeStartup: MockDefaultStartupHandler, primitive.OpCodeRegister: MockDefaultRegisterHandler, primitive.OpCodeQuery: MockDefaultQueryHandler, }
View Source
var IgnoreEndpoint = errors.New("ignore endpoint")
View Source
var (
NoConnForHost = errors.New("no connection available for host")
)
Functions ¶
func DecodeType ¶
func EncodeType ¶
func LookupEndpoint ¶
func MockDefaultOptionsHandler ¶
func MockDefaultOptionsHandler(_ *MockClient, _ *frame.Frame) message.Message
func MockDefaultQueryHandler ¶
func MockDefaultQueryHandler(cl *MockClient, frm *frame.Frame) message.Message
func MockDefaultRegisterHandler ¶
func MockDefaultRegisterHandler(cl *MockClient, frm *frame.Frame) message.Message
func MockDefaultStartupHandler ¶
func MockDefaultStartupHandler(_ *MockClient, _ *frame.Frame) message.Message
Types ¶
type Authenticator ¶
type Authenticator interface { InitialResponse(authenticator string, c *ClientConn) ([]byte, error) EvaluateChallenge(token []byte) ([]byte, error) Success(token []byte) error }
func NewPasswordAuth ¶
func NewPasswordAuth(username string, password string) Authenticator
type BootstrapEvent ¶
type BootstrapEvent struct {
Hosts []*Host
}
type ClientConn ¶
type ClientConn struct {
// contains filtered or unexported fields
}
func ConnectClient ¶
func ConnectClient(ctx context.Context, endpoint Endpoint, config ClientConnConfig) (*ClientConn, error)
ConnectClient creates a new connection to an endpoint within a downstream cluster using TLS if specified.
func (*ClientConn) Close ¶
func (c *ClientConn) Close() error
func (*ClientConn) Closing ¶
func (c *ClientConn) Closing(err error)
func (*ClientConn) Err ¶
func (c *ClientConn) Err() error
func (*ClientConn) Handshake ¶
func (c *ClientConn) Handshake(ctx context.Context, version primitive.ProtocolVersion, auth Authenticator) (primitive.ProtocolVersion, error)
func (*ClientConn) Heartbeats ¶
func (c *ClientConn) Heartbeats(connectTimeout time.Duration, version primitive.ProtocolVersion, heartbeatInterval time.Duration, idleTimeout time.Duration, logger *zap.Logger)
Heartbeats sends an OPTIONS request to the endpoint in order to keep the connection alive.
func (*ClientConn) Inflight ¶
func (c *ClientConn) Inflight() int32
func (*ClientConn) IsClosed ¶
func (c *ClientConn) IsClosed() chan struct{}
func (*ClientConn) Query ¶
func (c *ClientConn) Query(ctx context.Context, version primitive.ProtocolVersion, query message.Message) (*ResultSet, error)
func (*ClientConn) QueryFrame ¶ added in v0.1.3
func (*ClientConn) Send ¶
func (c *ClientConn) Send(request Request) error
func (*ClientConn) SendAndReceive ¶
func (*ClientConn) SetKeyspace ¶
func (c *ClientConn) SetKeyspace(ctx context.Context, version primitive.ProtocolVersion, keyspace string) error
type ClientConnConfig ¶
type ClientConnConfig struct { PreparedCache PreparedCache Handler EventHandler Logger *zap.Logger }
type Cluster ¶
type Cluster struct { // the following are immutable after start up NegotiatedVersion primitive.ProtocolVersion Info ClusterInfo // contains filtered or unexported fields }
Cluster defines a downstream cluster that is being proxied to.
func ConnectCluster ¶
func ConnectCluster(ctx context.Context, config ClusterConfig) (*Cluster, error)
ConnectCluster establishes control connections to each of the endpoints within a downstream cluster that is being proxied to.
func (*Cluster) Listen ¶
func (c *Cluster) Listen(listener ClusterListener) error
func (*Cluster) OutageDuration ¶ added in v0.1.0
type ClusterConfig ¶
type ClusterConfig struct { Version primitive.ProtocolVersion Auth Authenticator Resolver EndpointResolver ReconnectPolicy ReconnectPolicy RefreshWindow time.Duration HeartBeatInterval time.Duration ConnectTimeout time.Duration RefreshTimeout time.Duration IdleTimeout time.Duration Logger *zap.Logger }
type ClusterInfo ¶
type ClusterListener ¶
type ClusterListener interface {
OnEvent(event Event)
}
type ClusterListenerFunc ¶
type ClusterListenerFunc func(event Event)
func (ClusterListenerFunc) OnEvent ¶
func (f ClusterListenerFunc) OnEvent(event Event)
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func Connect ¶
Connect creates a new connection to a server specified by the endpoint using TLS if specified
func (*Conn) RemoteAddr ¶
func (*Conn) WriteBytes ¶
type Endpoint ¶
type Endpoint interface { fmt.Stringer Addr() string IsResolved() bool TLSConfig() *tls.Config Key() string }
func NewEndpoint ¶
type EndpointResolver ¶
type EndpointResolver interface { Resolve(ctx context.Context) ([]Endpoint, error) NewEndpoint(row Row) (Endpoint, error) }
func NewResolver ¶
func NewResolver(contactPoints ...string) EndpointResolver
func NewResolverWithDefaultPort ¶
func NewResolverWithDefaultPort(contactPoints []string, defaultPort int) EndpointResolver
type EventHandler ¶
type EventHandlerFunc ¶
func (EventHandlerFunc) OnEvent ¶
func (f EventHandlerFunc) OnEvent(frm *frame.Frame)
type LoadBalancer ¶
type LoadBalancer interface { ClusterListener NewQueryPlan() QueryPlan }
func NewRoundRobinLoadBalancer ¶
func NewRoundRobinLoadBalancer() LoadBalancer
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
func (*MockClient) Closing ¶
func (c *MockClient) Closing(_ error)
func (*MockClient) InterceptQuery ¶
func (MockClient) Keyspace ¶
func (c MockClient) Keyspace() string
func (MockClient) Local ¶
func (c MockClient) Local() MockHost
func (*MockClient) Register ¶
func (c *MockClient) Register(version primitive.ProtocolVersion)
type MockCluster ¶
type MockCluster struct { DseVersion string Handlers map[primitive.OpCode]MockRequestHandler // contains filtered or unexported fields }
func NewMockCluster ¶
func NewMockCluster(startIP net.IP, port int) *MockCluster
func (*MockCluster) Remove ¶
func (c *MockCluster) Remove(n int)
func (*MockCluster) Shutdown ¶
func (c *MockCluster) Shutdown()
func (*MockCluster) Stop ¶
func (c *MockCluster) Stop(n int)
type MockRequestHandler ¶
type MockRequestHandler func(client *MockClient, frm *frame.Frame) message.Message
type MockRequestHandlers ¶
type MockRequestHandlers map[primitive.OpCode]MockRequestHandler
func NewMockRequestHandlers ¶
func NewMockRequestHandlers(overrides MockRequestHandlers) MockRequestHandlers
type MockServer ¶
type MockServer struct { DseVersion string Handlers map[primitive.OpCode]MockRequestHandler // contains filtered or unexported fields }
func (*MockServer) Add ¶
func (s *MockServer) Add(host MockHost)
func (*MockServer) Event ¶
func (s *MockServer) Event(evt message.Event)
func (*MockServer) Remove ¶
func (s *MockServer) Remove(host MockHost)
func (*MockServer) Serve ¶
func (s *MockServer) Serve(ctx context.Context, maxVersion primitive.ProtocolVersion, local MockHost, peers []MockHost) error
func (*MockServer) Shutdown ¶
func (s *MockServer) Shutdown()
type PreparedCache ¶
type PreparedCache interface { // Store add an entry to the cache. Store(id string, entry *PreparedEntry) // Load retrieves an entry from the cache. `ok` is true if the entry is present; otherwise it's false. Load(id string) (entry *PreparedEntry, ok bool) }
PreparedCache a thread-safe cache for storing prepared queries.
type PreparedEntry ¶
PreparedEntry is an entry in the prepared cache.
type ReconnectEvent ¶
type ReconnectEvent struct {
Endpoint
}
type ReconnectPolicy ¶
type ReconnectPolicy interface { NextDelay() time.Duration Reset() Clone() ReconnectPolicy }
func NewReconnectPolicy ¶
func NewReconnectPolicy() ReconnectPolicy
func NewReconnectPolicyWithDelays ¶
func NewReconnectPolicyWithDelays(baseDelay, maxDelay time.Duration) ReconnectPolicy
type RemoveEvent ¶
type RemoveEvent struct {
Host *Host
}
type Request ¶
type Request interface { // Frame returns the frame to be executed as part of the request. // This must be idempotent. Frame() interface{} // Execute is called when a request need to be retried. // This is currently only called for executing prepared requests (i.e. `EXECUTE` request frames). If `EXECUTE` // request frames are not expected then the implementation should `panic()`. // // If `next` is false then the request must be retried on the current node; otherwise, it should be retried on // another node which is usually then next node in a query plan. Execute(next bool) // OnClose is called when the underlying connection is closed. // No assumptions should be made about whether the request has been successfully sent; it is possible that // the request has been fully sent and no response was received before OnClose(err error) // OnResult is called when a response frame has been sent back from the connection. OnResult(raw *frame.RawFrame) }
Request represents the data frame and lifecycle of a CQL native protocol request.
type ResultSet ¶
type ResultSet struct {
// contains filtered or unexported fields
}
func NewResultSet ¶
func NewResultSet(rows *message.RowsResult, version primitive.ProtocolVersion) *ResultSet
type SchemaChangeEvent ¶
type SchemaChangeEvent struct {
Message *message.SchemaChangeEvent
}
type SenderFunc ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func ConnectSession ¶
type SessionConfig ¶
type SessionConfig struct { ReconnectPolicy ReconnectPolicy NumConns int Keyspace string Version primitive.ProtocolVersion Auth Authenticator // PreparedCache a global cache share across sessions for storing previously prepared queries PreparedCache PreparedCache ConnectTimeout time.Duration HeartBeatInterval time.Duration IdleTimeout time.Duration Logger *zap.Logger }
type UnexpectedResponse ¶
func (*UnexpectedResponse) Error ¶
func (e *UnexpectedResponse) Error() string
Click to show internal directories.
Click to hide internal directories.