controller

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2016 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownCommand is returned when command was not recognized
	ErrUnknownCommand = &Error{commonError, "Unknown command"}

	// ErrInvalidCommand means command wasn't parsed correcty
	ErrInvalidCommand = &Error{clientError, "Invalid command"}

	// ErrCloseCurrentItemFirst is returned when client attemted
	// to read next item before closing the current one
	ErrCloseCurrentItemFirst = &Error{clientError, "Close current item first"}

	// ErrBadDataChunk is returned when data provided by client has different size
	ErrBadDataChunk = &Error{clientError, "bad data chunk"}

	// ErrInvalidDataSize is returned when data size field is not a number
	ErrInvalidDataSize = &Error{clientError, "Invalid <bytes> number"}
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Name          string
	QueueName     string
	SubCommand    string
	ConsumerGroup string
	FanoutQueues  []string
	DataSize      int
}

Command represents a client command

type Conn

type Conn interface {
	io.Reader
	io.Writer
	SetDeadline(t time.Time) error
}

Conn represents a connection interface

type Controller

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

Controller represents a connection controller

func NewSession

func NewSession(conn Conn, repo *repository.QueueRepository) *Controller

NewSession creates and initializes new controller

func (*Controller) Delete

func (c *Controller) Delete(input []string) error

Delete handles DELETE command Command: DELETE <queue> Response: END

func (*Controller) Dispatch

func (c *Controller) Dispatch() error

Dispatch routes client commands to their respective handlers

func (*Controller) FinishSession

func (c *Controller) FinishSession()

FinishSession aborts unfinished transaction

func (*Controller) Flush

func (c *Controller) Flush(input []string) error

Flush handles FLUSH command Command: FLUSH <queue> Response: END

func (*Controller) FlushAll

func (c *Controller) FlushAll() error

FlushAll handles FLUSH_ALL command. Command: FLUSH_ALL Response: Flushed all queues

func (*Controller) Get

func (c *Controller) Get(input []string) error

Get handles GET command Command: GET <queue> Response: VALUE <queue> 0 <bytes> <data block> END

func (*Controller) ReadFirstMessage

func (c *Controller) ReadFirstMessage() (string, error)

ReadFirstMessage reads initial message from connection buffer

func (*Controller) SendError

func (c *Controller) SendError(err error)

SendError sends an error message to the client

func (*Controller) Set

func (c *Controller) Set(input []string) error

Set handles SET command Command: SET <queue> <not_impl> <not_impl> <bytes> <data block> Response: STORED

func (*Controller) Stats

func (c *Controller) Stats() error

Stats handles STATS command

func (*Controller) UnknownCommand

func (c *Controller) UnknownCommand() error

UnknownCommand reports an error

func (*Controller) Version

func (c *Controller) Version() error

Version handles VERSION command

type Error added in v0.5.1

type Error struct {
	Type string
	Msg  string
}

Error is an error that has a type

func NewError added in v0.5.1

func NewError(kind string, err error) *Error

NewError returns a new error

func (Error) Error added in v0.5.1

func (err Error) Error() string

Jump to

Keyboard shortcuts

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