batched

package
v0.0.0-...-d3db570 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MetricBatchNumBatches           = metrics.AddCounter("batch_num_batches", nil)
	MetricBatchFullBatches          = metrics.AddCounter("batch_full_batches", nil)
	MetricBatchTimedoutBatches      = metrics.AddCounter("batch_timedout_batches", nil)
	MetricBatchWriteError           = metrics.AddCounter("batch_write_error", nil)
	MetricBatchReaderProtocolErrors = metrics.AddCounter("batch_reader_proto_errors", nil)
)
View Source
var (
	MetricBatchRelaysCreated         = metrics.AddCounter("batch_relay_created", nil)
	MetricBatchMonitorRuns           = metrics.AddCounter("batch_monitor_runs", nil)
	MetricBatchConnectionsCreated    = metrics.AddCounter("batch_connections_created", nil)
	MetricBatchConnectionFailure     = metrics.AddCounter("batch_connection_failure", nil)
	MetricBatchExpandLoadFactor      = metrics.AddCounter("batch_expand_load_factor", nil)
	MetricBatchExpandOverloadedRatio = metrics.AddCounter("batch_expand_overloaded_ratio", nil)

	MetricBatchPoolSize       = metrics.AddIntGauge("batch_pool_size", nil)
	MetricBatchLastLoadFactor = metrics.AddFloatGauge("batch_last_load_factor", nil)
)

Functions

This section is empty.

Types

type Handler

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

Handler implements the handlers.Handler interface. It is an implementation of the interface that defers all requests to a connection pool to the backend. This is done in order to decrease the number of syscalls that the process has to make by batching requests as much as possible per connection. The connection pool is a grow-only style where more connections may be added as needed but they are never torn down.

func NewHandler

func NewHandler(sock string, opts Opts) Handler

NewHandler creates a new handler with the given unix socket as the connected backend. The first time this method is called it creates a background monitor that will add connections as needed for the given domain socket. The Opts parameter can exclude any settings in order to take the defaults. Any setting that is at the 0 value or negative will take the default.

Default values are:

BatchSize: 10, BatchDelayMicros: 250, ReadBufSize: 1 << 16, // 64k WriteBufSize: 1 << 16, // 64k EvaluationIntervalSec: 2, LoadFactorExpandRatio: 0.75, OverloadedConnRatio: 0.2,

func (Handler) Add

func (h Handler) Add(cmd common.SetRequest) error

Add performs an add operation on the backend. It only sets the value if it does not already exist.

func (Handler) Append

func (h Handler) Append(cmd common.SetRequest) error

Append performs an append operation on the backend. It will append the data to the value only if it already exists.

func (Handler) Close

func (h Handler) Close() error

Close does nothing for this Handler as the connections are pooled behind it and are not explicitly controlled.

func (Handler) Delete

func (h Handler) Delete(cmd common.DeleteRequest) error

Delete performs a delete operation on the backend. It will unconditionally remove the value.

func (Handler) GAT

GAT performs a get-and-touch on the backend for the given key. It will retrieve the value while updating the TTL to the one supplied.

func (Handler) Get

func (h Handler) Get(cmd common.GetRequest) (<-chan common.GetResponse, <-chan error)

Get performs a get operation on the backend. It retrieves the whole of the batch of keys given as a group and returns them one at a time over the request channel.

func (Handler) GetE

func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error)

GetE performs a get-with-expiration on the backend. It is a custom command only implemented in Rend. It retrieves the whole batch of keys given as a group and returns them one at a time over the request channel.

func (Handler) Prepend

func (h Handler) Prepend(cmd common.SetRequest) error

Prepend performs a prepend operation on the backend. It will prepend the data to the value only if it already exists.

func (Handler) Replace

func (h Handler) Replace(cmd common.SetRequest) error

Replace performs a replace operation on the backend. It only sets the value if it already exists.

func (Handler) Set

func (h Handler) Set(cmd common.SetRequest) error

Set performs a set operation on the backend. It unconditionally sets a key to a value.

func (Handler) Touch

func (h Handler) Touch(cmd common.TouchRequest) error

Touch performs a touch operation on the backend. It will overwrite the expiration time with a new one.

type Opts

type Opts struct {
	BatchSize             uint32
	BatchDelayMicros      uint32
	ReadBufSize           uint32
	WriteBufSize          uint32
	EvaluationIntervalSec uint32
	LoadFactorExpandRatio float64
	OverloadedConnRatio   float64
}

Opts is the set of tuning options for the batched handler.

Jump to

Keyboard shortcuts

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