Documentation ¶
Overview ¶
Package common contains all protocol-agnostic types and interfaces, as well as some variables used by multiple other packages in the application. Metrics are useful in many places for tracking bytes written and read. Errors exist here to be the neutral representation of either protocol errors or other application errors that happen all over. Other interfaces and types used by multiple protocols are here so any protocol can be used on the front end as well as the back with the same intermediate representation.
Index ¶
Constants ¶
const VersionString = "Rend 0.1"
Variables ¶
var ( MetricBytesReadRemote = metrics.AddCounter("bytes_read_remote", nil) MetricBytesReadLocal = metrics.AddCounter("bytes_read_local", nil) MetricBytesReadLocalL1 = metrics.AddCounter("bytes_read_local_l1", nil) MetricBytesReadLocalL2 = metrics.AddCounter("bytes_read_local_l2", nil) MetricBytesWrittenRemote = metrics.AddCounter("bytes_written_remote", nil) MetricBytesWrittenLocal = metrics.AddCounter("bytes_written_local", nil) MetricBytesWrittenLocalL1 = metrics.AddCounter("bytes_written_local_l1", nil) MetricBytesWrittenLocalL2 = metrics.AddCounter("bytes_written_local_l2", nil) // Errors used across the application ErrBadRequest = errors.New("CLIENT_ERROR bad request") ErrBadLength = errors.New("CLIENT_ERROR length is not a valid integer") ErrBadFlags = errors.New("CLIENT_ERROR flags is not a valid integer") ErrBadExptime = errors.New("CLIENT_ERROR exptime is not a valid integer") ErrNoError = errors.New("Success") ErrKeyNotFound = errors.New("ERROR Key not found") ErrKeyExists = errors.New("ERROR Key already exists") ErrValueTooBig = errors.New("ERROR Value too big") ErrInvalidArgs = errors.New("ERROR Invalid arguments") ErrItemNotStored = errors.New("ERROR Item not stored") ErrBadIncDecValue = errors.New("ERROR Bad increment/decrement value") ErrAuth = errors.New("ERROR Authentication error") ErrUnknownCmd = errors.New("ERROR Unknown command") ErrNoMem = errors.New("ERROR Out of memory") ErrNotSupported = errors.New("ERROR Not supported") ErrInternal = errors.New("ERROR Internal error") ErrBusy = errors.New("ERROR Busy") ErrTempFailure = errors.New("ERROR Temporary error") )
Common metrics used across packages
Functions ¶
func IsAppError ¶
IsAppError differentiates between protocol-defined errors that are relatively benign and other fatal errors like an IO error because of some socket problem or network issue. Make sure to keep this list in sync with the one above. It should contain all Err* that could come back from memcached itself
Types ¶
type DeleteRequest ¶
DeleteRequest corresponds to common.RequestDelete. It contains all the information required to fulfill a delete request.
func (DeleteRequest) GetOpaque ¶
func (r DeleteRequest) GetOpaque() uint32
func (DeleteRequest) IsQuiet ¶
func (r DeleteRequest) IsQuiet() bool
type GATRequest ¶
GATRequest corresponds to common.RequestGat. It contains all the information required to fulfill a get-and-touch request.
func (GATRequest) GetOpaque ¶
func (r GATRequest) GetOpaque() uint32
func (GATRequest) IsQuiet ¶
func (r GATRequest) IsQuiet() bool
type GetEResponse ¶
type GetEResponse struct { Key []byte Data []byte Opaque uint32 Flags uint32 Exptime uint32 Miss bool Quiet bool }
GetEResponse is used in the GetE protocol extension
type GetRequest ¶
type GetRequest struct { Keys [][]byte Opaques []uint32 Quiet []bool NoopOpaque uint32 NoopEnd bool }
GetRequest corresponds to common.RequestGet. It contains all the information required to fulfill a get requestGets are batch by default, so single gets and batch gets are both represented by the same type.
func (GetRequest) GetOpaque ¶
func (r GetRequest) GetOpaque() uint32
func (GetRequest) IsQuiet ¶
func (r GetRequest) IsQuiet() bool
type GetResponse ¶
GetResponse is used in both RequestGet and RequestGat handling. Both respond in the same manner but with different opcodes. It is binary-protocol specific, but is still a part of the interface of responder to make the handling code more protocol-agnostic.
type NoopRequest ¶
type NoopRequest struct {
Opaque uint32
}
NoopRequest corresponds to common.RequestNoop. It contains all the information required to fulfill a version request.
func (NoopRequest) GetOpaque ¶
func (r NoopRequest) GetOpaque() uint32
func (NoopRequest) IsQuiet ¶
func (r NoopRequest) IsQuiet() bool
type QuitRequest ¶
QuitRequest corresponds to common.RequestQuit. It contains all the information required to fulfill a quit request.
func (QuitRequest) GetOpaque ¶
func (r QuitRequest) GetOpaque() uint32
func (QuitRequest) IsQuiet ¶
func (r QuitRequest) IsQuiet() bool
type RequestType ¶
type RequestType int
RequestType is the protocol-agnostic identifier for the command
const ( // RequestUnknown means the parser doesn't know what the request represents. Valid protocol // parsing but invalid values. RequestUnknown RequestType = iota // RequestGet represents both a single get and a multi-get, which take differen forms in // different protocols. This means it can also be the accumulation of many GETQ commands. RequestGet // RequestGat is a get-and-touch operation that retrieves the information while updating the TTL RequestGat // RequestGetE is a custom get which returns the TTL remaining with the data RequestGetE // RequestSet is to insert a new piece of data unconditionally. What that means is different // depending on L1 / L2 handling. RequestSet // RequestAdd will perform the same operations as set, but only if the key does not exist RequestAdd // RequestReplace will perform the same operations as set, but only if the key already exists RequestReplace // RequestAppend appends data to the end of the already existing data for a given key. Does not // change the flags or TTL values even if they are given. RequestAppend // RequestPrepend appends data to the end of the already existing data for a given key. Does not // change the flags or TTL values even if they are given. RequestPrepend // RequestDelete deletes a piece of data from all levels of cache RequestDelete // RequestTouch updates the TTL for the item specified to a new TTL RequestTouch // RequestNoop does nothing RequestNoop // RequestQuit closes the connection RequestQuit // RequestVersion replies with a string designating the current software version RequestVersion )
type SetRequest ¶
type SetRequest struct { Key []byte Data []byte Flags uint32 Exptime uint32 Opaque uint32 Quiet bool }
SetRequest corresponds to common.RequestSet. It contains all the information required to fulfill a set request.
func (SetRequest) GetOpaque ¶
func (r SetRequest) GetOpaque() uint32
func (SetRequest) IsQuiet ¶
func (r SetRequest) IsQuiet() bool
type TouchRequest ¶
TouchRequest corresponds to common.RequestTouch. It contains all the information required to fulfill a touch request.
func (TouchRequest) GetOpaque ¶
func (r TouchRequest) GetOpaque() uint32
func (TouchRequest) IsQuiet ¶
func (r TouchRequest) IsQuiet() bool
type VersionRequest ¶
type VersionRequest struct {
Opaque uint32
}
VersionRequest corresponds to common.RequestVersion. It contains all the information required to fulfill a version request.
func (VersionRequest) GetOpaque ¶
func (r VersionRequest) GetOpaque() uint32
func (VersionRequest) IsQuiet ¶
func (r VersionRequest) IsQuiet() bool