proxy

package
v0.0.0-...-b1dd49a Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProxyAlreadyConnected = errors.New("proxy already connected")
View Source
var ErrProxyClosed = errors.New("proxy closed")
View Source
var ErrProxyNotConnected = errors.New("proxy not connected")

Functions

func NewDefaultPreparedCache

func NewDefaultPreparedCache(size int) (proxycore.PreparedCache, error)

NewDefaultPreparedCache creates a new default prepared cache capping the max item capacity to `size`.

func PostToStreaming

func PostToStreaming(query string)

func Run

func Run(ctx context.Context, args []string) int

Run starts the proxy command. 'args' shouldn't include the executable (i.e. os.Args[1:]). It returns the exit code for the proxy.

func SingletonStreamingManager

func SingletonStreamingManager(ctx context.Context, config *runConfig, proxy *Proxy) (*streamingManager, error)

Types

type Config

type Config struct {
	Version              primitive.ProtocolVersion
	MaxVersion           primitive.ProtocolVersion
	Auth                 proxycore.Authenticator
	Resolver             proxycore.EndpointResolver
	ReconnectPolicy      proxycore.ReconnectPolicy
	RetryPolicy          RetryPolicy
	IdempotentGraph      bool
	NumConns             int
	Logger               *zap.Logger
	HeartBeatInterval    time.Duration
	IdleTimeout          time.Duration
	RPCAddr              string
	DC                   string
	Tokens               []string
	Peers                []PeerConfig
	TrackUsage           bool
	UsageTrackSystem     bool
	UsageKeyspace        string
	UsageWruBytes        int
	UsageRruBytes        int
	UsageTable           string
	UsageFlushSeconds    int
	UsageHistogramsTable string
	// PreparedCache a cache that stores prepared queries. If not set it uses the default implementation with a max
	// capacity of ~100MB.
	PreparedCache proxycore.PreparedCache
}

type PeerConfig

type PeerConfig struct {
	RPCAddr string   `yaml:"rpc-address"`
	DC      string   `yaml:"data-center,omitempty"`
	Tokens  []string `yaml:"tokens,omitempty"`
}

type ProducerService

type ProducerService struct {
}

type Proxy

type Proxy struct {
	StreamingManager *streamingManager
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(ctx context.Context, config Config) *Proxy

func (*Proxy) Close

func (p *Proxy) Close() error

func (*Proxy) Connect

func (p *Proxy) Connect() error

func (*Proxy) OnEvent

func (p *Proxy) OnEvent(event proxycore.Event)

func (*Proxy) OutageDuration

func (p *Proxy) OutageDuration() time.Duration

func (*Proxy) Ready

func (p *Proxy) Ready() bool

func (*Proxy) Serve

func (p *Proxy) Serve(l net.Listener) (err error)

Serve the proxy using the specified listener. It can be called multiple times with different listeners allowing them to share the same backend clusters.

type RequestResponse

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

type RetryDecision

type RetryDecision int

RetryDecision is a type used for deciding what to do when a request has failed.

const (
	// RetrySame should be returned when a request should be retried on the same host.
	RetrySame RetryDecision = iota
	// RetryNext should be returned when a request should be retried on the next host according to the request's query
	// plan.
	RetryNext
	// ReturnError should be returned when a request's original error should be forwarded along to the client.
	ReturnError
)

func (RetryDecision) String

func (r RetryDecision) String() string

type RetryPolicy

type RetryPolicy interface {
	// OnReadTimeout handles the retry decision for a server-side read timeout error (Read_timeout = 0x1200).
	// This occurs when a replica read request times out during a read query.
	OnReadTimeout(msg *message.ReadTimeout, retryCount int) RetryDecision

	// OnWriteTimeout handles the retry decision for a server-side write timeout error (Write_timeout = 0x1100).
	// This occurs when a replica write request times out during a write query.
	OnWriteTimeout(msg *message.WriteTimeout, retryCount int) RetryDecision

	// OnUnavailable handles the retry decision for a server-side unavailable exception (Unavailable = 0x1000).
	// This occurs when a coordinator determines that there are not enough replicas to handle a query at the requested
	// consistency level.
	OnUnavailable(msg *message.Unavailable, retryCount int) RetryDecision

	// OnErrorResponse handles the retry decision for other potentially recoverable errors.
	// This can be called for the following error types: server error (ServerError = 0x0000),
	// overloaded (Overloaded = 0x1001), truncate error (Truncate_error = 0x1003), read failure (Read_failure = 0x1300),
	// and write failure (Write_failure = 0x1500).
	OnErrorResponse(msg message.Error, retryCount int) RetryDecision
}

RetryPolicy is an interface for defining retry behavior when a server-side error occurs.

func NewDefaultRetryPolicy

func NewDefaultRetryPolicy() RetryPolicy

NewDefaultRetryPolicy creates a new default retry policy. The default retry policy takes a conservative approach to retrying requests. In most cases it retries only once in cases where a retry is likely to succeed.

Jump to

Keyboard shortcuts

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