message

package
v0.0.0-...-cacfd1a Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

message contains utilities for proxying the sending out of a memcached request and receiving a memcached response

Index

Constants

View Source
const END_LINE_LENGTH = 5 // END\r\n

Variables

View Source
var RESPONSE_ERROR_UNEXPECTED_TYPE = NewResponseError([]byte("SERVER_ERROR multiget fail\r\n"))
View Source
var RESPONSE_ERROR_UNKNOWN_COMMAND = NewResponseError([]byte("SERVER_ERROR unknown command\r\n"))

Functions

This section is empty.

Types

type FragmentedMessage

type FragmentedMessage struct {
	MessageLinkedListEntry
	// Pointers to 2 or more non-null messages
	Fragments []SingleMessage
}

A message that affects multiple keys, possibly on different backends. Currently just memcache multigets.

func (*FragmentedMessage) AwaitResponseBytes

func (message *FragmentedMessage) AwaitResponseBytes() ([]byte, *ResponseError)

type Message

type Message interface {
	AwaitResponseBytes() ([]byte, *ResponseError)
}

Message is the representation of a well-formed request for 1 or more keys

type MessageLinkedListEntry

type MessageLinkedListEntry struct {
	NextOutgoingResponse Message
}

type RequestType

type RequestType uint8
const (
	REQUEST_MC_UNKNOWN RequestType = 1
	REQUEST_MC_GET     RequestType = 2
	REQUEST_MC_GETS    RequestType = 3
	REQUEST_MC_SET     RequestType = 4
	REQUEST_MC_DELETE  RequestType = 5
	REQUEST_MC_INCR    RequestType = 6
	REQUEST_MC_CAS     RequestType = 7
)

type ResponseError

type ResponseError struct {
	ErrorBytes []byte
}

func CombineMemcacheMultiget

func CombineMemcacheMultiget(fragments []SingleMessage) ([]byte, *ResponseError)

Combine the VALUE key\r\n

func NewResponseError

func NewResponseError(message []byte) *ResponseError

func (*ResponseError) Error

func (error *ResponseError) Error() string

type ResponseType

type ResponseType uint8
const (
	RESPONSE_MC_PROTOCOLERROR ResponseType = 0
	RESPONSE_MC_VALUE         ResponseType = 1
	RESPONSE_MC_END           ResponseType = 2
	RESPONSE_MC_STORED        ResponseType = 3
	RESPONSE_MC_NOT_STORED    ResponseType = 4
	RESPONSE_MC_EXISTS        ResponseType = 5
	RESPONSE_MC_NOT_FOUND     ResponseType = 6
	RESPONSE_MC_DELETED       ResponseType = 7
	RESPONSE_MC_TOUCHED       ResponseType = 8
	RESPONSE_MC_OK            ResponseType = 8
	RESPONSE_MC_NUMBER        ResponseType = 9
)

type SingleMessage

type SingleMessage struct {
	MessageLinkedListEntry
	// Mutex is locked by the creator of the message and released after succeeding or failing at receiving a result.
	Mutex         sync.Mutex
	RequestData   []byte
	ResponseData  []byte
	ResponseError *ResponseError
	Key           []byte
	ResponseType  ResponseType
	RequestType   RequestType
}

func (*SingleMessage) AwaitResponseBytes

func (message *SingleMessage) AwaitResponseBytes() ([]byte, *ResponseError)

func (*SingleMessage) HandleReceiveError

func (message *SingleMessage) HandleReceiveError(err error)

func (*SingleMessage) HandleReceiveResponse

func (message *SingleMessage) HandleReceiveResponse(data []byte, responseType ResponseType)

func (*SingleMessage) HandleSendRequest

func (message *SingleMessage) HandleSendRequest(data []byte, key []byte, requestType RequestType)

Jump to

Keyboard shortcuts

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