beanstalk

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 13 Imported by: 0

README

Go Beanstalk

Build Status codecov Go Reference

Go client for beanstalkd.

Installation

go get github.com/IvanLutokhin/go-beanstalk

Quick Start

Producer
c, err := beanstalk.Dial("tcp", "127.0.0.1:11300")
if err != nil {
	panic(err)
}

id, err := c.Put(1, 0, 5*time.Second, []byte("example"))
if err != nil {
	panic(err)
}

fmt.Println(id) // output job id
Consumer
c, err := beanstalk.Dial("tcp", "127.0.0.1:11300")
if err != nil {
	panic(err)
}

job, err := c.Reserve()
if err != nil {
	panic(err)
}

fmt.Println(job.ID) // output job id
fmt.Println(job.Data) // output job data
Pool
p := beanstalk.NewPool(&beanstalk.PoolOptions{
	Dialer: func () (*beanstalk.Client, error) { return beanstalk.Dial("127.0.0.1:11300") },
	Logger: beanstalk.NopLogger,
	Capacity: 5,
	MaxAge: 0,
	IdleTimeout: 0,
})

// establish connections
if err = p.Open(); err != nil {
	panic(err)
}

// retrieve client
c, err := p.Get()
if err != nil {
	panic(err)
}

// use client
stats, err := c.Stats()
if err != nil {
	panic(err)
}

// return client
if err = p.Put(c); err != nil {
	panic(err)
}

// close connections
if err = p.Close(); err != nil {
	panic(err)
}
HTTP Handler
// Handler
type Handler interface {
    ServeHTTP(client *beanstalk.Client, writer http.ResponseWriter, request *http.Request)
}

type HandlerFunc func(client *beanstalk.Client, writer http.ResponseWriter, request *http.Request)

func (f HandlerFunc) ServeHTTP(client *beanstalk.Client, writer http.ResponseWriter, request *http.Request) {
    f(client, writer, request)
}

// Adapter
type HTTPHandlerAdapter struct {
    pool    *beanstalk.Pool
    handler Handler
}

func NewHTTPHandlerAdapter(pool *beanstalk.Pool, handler Handler) *HTTPHandlerAdapter {
    return &HTTPHandlerAdapter{
        pool:    pool,
        handler: handler,
    }
}

func (a HTTPHandlerAdapter) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
    client, err := a.pool.Get()
    if err != nil {
        panic(err)
    }

    defer a.pool.Put(client)

    a.handler.ServeHTTP(client, writer, request)
}

func GetServerStats() Handler {
	return HandlerFunc(func(c *beanstalk.Client, w http.ResponseWriter, r *http.Request) {
		stats, err := c.Stats()
		if err != nil {
			panic(err)
		}
		
		bytes, err := json.Marshal(v)
		if err != nil {
			panic(err)
		}
		
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusOK)
		w.Write(bytes)
	})
}

func main() {
    p := beanstalk.NewPool(&beanstalk.PoolOptions{
        Dialer: func () (*beanstalk.Client, error) { return beanstalk.Dial("127.0.0.1:11300") },
        Logger: beanstalk.NopLogger,
        Capacity: 5,
        MaxAge: 0,
        IdleTimeout: 0,
    })

    if err := p.Open(); err != nil {
        panic(err)
    }
	
    http.Handle("/stats", NewHTTPHandlerAdapter(p, GetServerStats()))
    http.ListenAndServe(":8090", nil)	
}

License

The MIT License (MIT)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadFormat          = errors.New("beanstalk: bad format")
	ErrBuried             = errors.New("beanstalk: buried")
	ErrDeadlineSoon       = errors.New("beanstalk: deadline soon")
	ErrDraining           = errors.New("beanstalk: draining")
	ErrExpectedCRLF       = errors.New("beanstalk: expected CRLF")
	ErrInternalError      = errors.New("beanstalk: internal error")
	ErrJobTooBig          = errors.New("beanstalk: job too big")
	ErrNotFound           = errors.New("beanstalk: not found")
	ErrNotIgnored         = errors.New("beanstalk: not ignored")
	ErrOutOfMemory        = errors.New("beanstalk: out of memory")
	ErrTimedOut           = errors.New("beanstalk: timed out")
	ErrUnknownCommand     = errors.New("beanstalk: unknown command")
	ErrMalformedCommand   = errors.New("beanstalk: malformed command")
	ErrUnexpectedResponse = errors.New("beanstalk: unexpected response")
)
View Source
var (
	ErrAlreadyOpenedPool  = errors.New("beanstalk: pool: already opened")
	ErrClosedPool         = errors.New("beanstalk: pool: closed")
	ErrDialerNotSpecified = errors.New("beanstalk: pool: dialer not specified")
)
View Source
var NopLogger = &nopLogger{}

Functions

This section is empty.

Types

type BuryCommand

type BuryCommand struct {
	ID       int
	Priority uint32
}

func (BuryCommand) Body

func (c BuryCommand) Body() []byte

func (BuryCommand) BuildResponse

func (c BuryCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (BuryCommand) CommandLine

func (c BuryCommand) CommandLine() string

func (BuryCommand) HasResponseBody

func (c BuryCommand) HasResponseBody() bool

type BuryCommandResponse

type BuryCommandResponse struct{}

type Client

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

func Dial

func Dial(address string) (*Client, error)

func NewClient

func NewClient(conn io.ReadWriteCloser) *Client

func (*Client) Bury

func (c *Client) Bury(id int, priority uint32) error

func (*Client) Check added in v0.7.0

func (c *Client) Check() error

func (*Client) Close

func (c *Client) Close() error

func (*Client) ClosedAt added in v0.7.0

func (c *Client) ClosedAt() time.Time

func (*Client) CreatedAt added in v0.7.0

func (c *Client) CreatedAt() time.Time

func (*Client) Delete

func (c *Client) Delete(id int) error

func (*Client) ExecuteCommand

func (c *Client) ExecuteCommand(command Command) (CommandResponse, error)

func (*Client) Ignore

func (c *Client) Ignore(tube string) (int, error)

func (*Client) Kick

func (c *Client) Kick(bound int) (int, error)

func (*Client) KickJob

func (c *Client) KickJob(id int) error

func (*Client) ListTubeUsed

func (c *Client) ListTubeUsed() (string, error)

func (*Client) ListTubes

func (c *Client) ListTubes() ([]string, error)

func (*Client) ListTubesWatched

func (c *Client) ListTubesWatched() ([]string, error)

func (*Client) PauseTube

func (c *Client) PauseTube(tube string, delay time.Duration) error

func (*Client) Peek

func (c *Client) Peek(id int) (*Job, error)

func (*Client) PeekBuried

func (c *Client) PeekBuried() (*Job, error)

func (*Client) PeekDelayed

func (c *Client) PeekDelayed() (*Job, error)

func (*Client) PeekReady

func (c *Client) PeekReady() (*Job, error)

func (*Client) Put

func (c *Client) Put(priority uint32, delay, ttr time.Duration, data []byte) (int, error)

func (*Client) Release

func (c *Client) Release(id int, priority uint32, delay time.Duration) error

func (*Client) Reserve

func (c *Client) Reserve() (*Job, error)

func (*Client) ReserveJob

func (c *Client) ReserveJob(id int) (*Job, error)

func (*Client) ReserveWithTimeout

func (c *Client) ReserveWithTimeout(timeout time.Duration) (*Job, error)

func (*Client) Stats

func (c *Client) Stats() (*Stats, error)

func (*Client) StatsJob

func (c *Client) StatsJob(id int) (*StatsJob, error)

func (*Client) StatsTube

func (c *Client) StatsTube(tube string) (*StatsTube, error)

func (*Client) Touch

func (c *Client) Touch(id int) error

func (*Client) Use

func (c *Client) Use(tube string) (string, error)

func (*Client) UsedAt added in v0.7.0

func (c *Client) UsedAt() time.Time

func (*Client) Watch

func (c *Client) Watch(tube string) (int, error)

type Command

type Command interface {
	CommandLine() string
	Body() []byte
	HasResponseBody() bool
}

type CommandResponse

type CommandResponse interface{}

type CommandResponseBuilder

type CommandResponseBuilder interface {
	BuildResponse(responseLine string, data []byte) (CommandResponse, error)
}

type DeleteCommand

type DeleteCommand struct {
	ID int
}

func (DeleteCommand) Body

func (c DeleteCommand) Body() []byte

func (DeleteCommand) BuildResponse

func (c DeleteCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (DeleteCommand) CommandLine

func (c DeleteCommand) CommandLine() string

func (DeleteCommand) HasResponseBody

func (c DeleteCommand) HasResponseBody() bool

type DeleteCommandResponse

type DeleteCommandResponse struct{}

type IgnoreCommand

type IgnoreCommand struct {
	Tube string
}

func (IgnoreCommand) Body

func (c IgnoreCommand) Body() []byte

func (IgnoreCommand) BuildResponse

func (c IgnoreCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (IgnoreCommand) CommandLine

func (c IgnoreCommand) CommandLine() string

func (IgnoreCommand) HasResponseBody

func (c IgnoreCommand) HasResponseBody() bool

type IgnoreCommandResponse

type IgnoreCommandResponse struct {
	Count int
}

type Job

type Job struct {
	ID   int
	Data []byte
}

type KickCommand

type KickCommand struct {
	Bound int
}

func (KickCommand) Body

func (c KickCommand) Body() []byte

func (KickCommand) BuildResponse

func (c KickCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (KickCommand) CommandLine

func (c KickCommand) CommandLine() string

func (KickCommand) HasResponseBody

func (c KickCommand) HasResponseBody() bool

type KickCommandResponse

type KickCommandResponse struct {
	Count int
}

type KickJobCommand

type KickJobCommand struct {
	ID int
}

func (KickJobCommand) Body

func (c KickJobCommand) Body() []byte

func (KickJobCommand) BuildResponse

func (c KickJobCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (KickJobCommand) CommandLine

func (c KickJobCommand) CommandLine() string

func (KickJobCommand) HasResponseBody

func (c KickJobCommand) HasResponseBody() bool

type KickJobCommandResponse

type KickJobCommandResponse struct{}

type ListTubeUsedCommand

type ListTubeUsedCommand struct{}

func (ListTubeUsedCommand) Body

func (c ListTubeUsedCommand) Body() []byte

func (ListTubeUsedCommand) BuildResponse

func (c ListTubeUsedCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (ListTubeUsedCommand) CommandLine

func (c ListTubeUsedCommand) CommandLine() string

func (ListTubeUsedCommand) HasResponseBody

func (c ListTubeUsedCommand) HasResponseBody() bool

type ListTubeUsedCommandResponse

type ListTubeUsedCommandResponse struct {
	Tube string
}

type ListTubesCommand

type ListTubesCommand struct{}

func (ListTubesCommand) Body

func (c ListTubesCommand) Body() []byte

func (ListTubesCommand) BuildResponse

func (c ListTubesCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (ListTubesCommand) CommandLine

func (c ListTubesCommand) CommandLine() string

func (ListTubesCommand) HasResponseBody

func (c ListTubesCommand) HasResponseBody() bool

type ListTubesCommandResponse

type ListTubesCommandResponse struct {
	Data []byte
}

type ListTubesWatchedCommand

type ListTubesWatchedCommand struct{}

func (ListTubesWatchedCommand) Body

func (c ListTubesWatchedCommand) Body() []byte

func (ListTubesWatchedCommand) BuildResponse

func (c ListTubesWatchedCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (ListTubesWatchedCommand) CommandLine

func (c ListTubesWatchedCommand) CommandLine() string

func (ListTubesWatchedCommand) HasResponseBody

func (c ListTubesWatchedCommand) HasResponseBody() bool

type ListTubesWatchedCommandResponse

type ListTubesWatchedCommandResponse struct {
	Data []byte
}

type LogLevel added in v0.7.0

type LogLevel int
const (
	DebugLogLevel LogLevel = iota + 1
	InfoLogLevel
	WarningLogLevel
	ErrorLogLevel
	PanicLogLevel
	FatalLogLevel
)

func (LogLevel) String added in v0.7.0

func (l LogLevel) String() string

type Logger added in v0.7.0

type Logger interface {
	Log(level LogLevel, msg string, args map[string]interface{})
}

type PauseTubeCommand

type PauseTubeCommand struct {
	Tube  string
	Delay time.Duration
}

func (PauseTubeCommand) Body

func (c PauseTubeCommand) Body() []byte

func (PauseTubeCommand) BuildResponse

func (c PauseTubeCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (PauseTubeCommand) CommandLine

func (c PauseTubeCommand) CommandLine() string

func (PauseTubeCommand) HasResponseBody

func (c PauseTubeCommand) HasResponseBody() bool

type PauseTubeCommandResponse

type PauseTubeCommandResponse struct{}

type PeekBuriedCommand

type PeekBuriedCommand struct{}

func (PeekBuriedCommand) Body

func (c PeekBuriedCommand) Body() []byte

func (PeekBuriedCommand) BuildResponse

func (c PeekBuriedCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (PeekBuriedCommand) CommandLine

func (c PeekBuriedCommand) CommandLine() string

func (PeekBuriedCommand) HasResponseBody

func (c PeekBuriedCommand) HasResponseBody() bool

type PeekBuriedCommandResponse

type PeekBuriedCommandResponse struct {
	ID   int
	Data []byte
}

type PeekCommand

type PeekCommand struct {
	ID int
}

func (PeekCommand) Body

func (c PeekCommand) Body() []byte

func (PeekCommand) BuildResponse

func (c PeekCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (PeekCommand) CommandLine

func (c PeekCommand) CommandLine() string

func (PeekCommand) HasResponseBody

func (c PeekCommand) HasResponseBody() bool

type PeekCommandResponse

type PeekCommandResponse struct {
	ID   int
	Data []byte
}

type PeekDelayedCommand

type PeekDelayedCommand struct{}

func (PeekDelayedCommand) Body

func (c PeekDelayedCommand) Body() []byte

func (PeekDelayedCommand) BuildResponse

func (c PeekDelayedCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (PeekDelayedCommand) CommandLine

func (c PeekDelayedCommand) CommandLine() string

func (PeekDelayedCommand) HasResponseBody

func (c PeekDelayedCommand) HasResponseBody() bool

type PeekDelayedCommandResponse

type PeekDelayedCommandResponse struct {
	ID   int
	Data []byte
}

type PeekReadyCommand

type PeekReadyCommand struct{}

func (PeekReadyCommand) Body

func (c PeekReadyCommand) Body() []byte

func (PeekReadyCommand) BuildResponse

func (c PeekReadyCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (PeekReadyCommand) CommandLine

func (c PeekReadyCommand) CommandLine() string

func (PeekReadyCommand) HasResponseBody

func (c PeekReadyCommand) HasResponseBody() bool

type PeekReadyCommandResponse

type PeekReadyCommandResponse struct {
	ID   int
	Data []byte
}

type Pool

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

func NewDefaultPool

func NewDefaultPool(options *PoolOptions) *Pool

func (*Pool) Close

func (p *Pool) Close(ctx context.Context) error

func (*Pool) Get

func (p *Pool) Get() (*Client, error)

func (*Pool) Len

func (p *Pool) Len() int

func (*Pool) Open added in v0.2.0

func (p *Pool) Open(ctx context.Context) error

func (*Pool) Put

func (p *Pool) Put(client *Client) error

type PoolOptions added in v0.7.0

type PoolOptions struct {
	Dialer      func() (*Client, error)
	Logger      Logger
	Capacity    int
	MaxAge      time.Duration
	IdleTimeout time.Duration
}

type PutCommand

type PutCommand struct {
	Priority uint32
	Delay    time.Duration
	TTR      time.Duration
	Data     []byte
}

func (PutCommand) Body

func (c PutCommand) Body() []byte

func (PutCommand) BuildResponse

func (c PutCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (PutCommand) CommandLine

func (c PutCommand) CommandLine() string

func (PutCommand) HasResponseBody

func (c PutCommand) HasResponseBody() bool

type PutCommandResponse

type PutCommandResponse struct {
	ID int
}

type ReleaseCommand

type ReleaseCommand struct {
	ID       int
	Priority uint32
	Delay    time.Duration
}

func (ReleaseCommand) Body

func (c ReleaseCommand) Body() []byte

func (ReleaseCommand) BuildResponse

func (c ReleaseCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (ReleaseCommand) CommandLine

func (c ReleaseCommand) CommandLine() string

func (ReleaseCommand) HasResponseBody

func (c ReleaseCommand) HasResponseBody() bool

type ReleaseCommandResponse

type ReleaseCommandResponse struct{}

type ReserveCommand

type ReserveCommand struct{}

func (ReserveCommand) Body

func (c ReserveCommand) Body() []byte

func (ReserveCommand) BuildResponse

func (c ReserveCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (ReserveCommand) CommandLine

func (c ReserveCommand) CommandLine() string

func (ReserveCommand) HasResponseBody

func (c ReserveCommand) HasResponseBody() bool

type ReserveCommandResponse

type ReserveCommandResponse struct {
	ID   int
	Data []byte
}

type ReserveJobCommand

type ReserveJobCommand struct {
	ID int
}

func (ReserveJobCommand) Body

func (c ReserveJobCommand) Body() []byte

func (ReserveJobCommand) BuildResponse

func (c ReserveJobCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (ReserveJobCommand) CommandLine

func (c ReserveJobCommand) CommandLine() string

func (ReserveJobCommand) HasResponseBody

func (c ReserveJobCommand) HasResponseBody() bool

type ReserveJobCommandResponse

type ReserveJobCommandResponse struct {
	ID   int
	Data []byte
}

type ReserveWithTimeoutCommand

type ReserveWithTimeoutCommand struct {
	Timeout time.Duration
}

func (ReserveWithTimeoutCommand) Body

func (c ReserveWithTimeoutCommand) Body() []byte

func (ReserveWithTimeoutCommand) BuildResponse

func (c ReserveWithTimeoutCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (ReserveWithTimeoutCommand) CommandLine

func (c ReserveWithTimeoutCommand) CommandLine() string

func (ReserveWithTimeoutCommand) HasResponseBody

func (c ReserveWithTimeoutCommand) HasResponseBody() bool

type ReserveWithTimeoutCommandResponse

type ReserveWithTimeoutCommandResponse struct {
	ID   int
	Data []byte
}

type Stats

type Stats struct {
	// is the number of ready jobs with priority < 1024
	CurrentJobsUrgent int `json:"currentJobsUrgent" yaml:"current-jobs-urgent"`
	// is the number of jobs in the ready queue
	CurrentJobsReady int `json:"currentJobsReady" yaml:"current-jobs-ready"`
	// is the number of jobs reserved by all clients
	CurrentJobsReserved int `json:"currentJobsReserved" yaml:"current-jobs-reserved"`
	// is the number of delayed jobs
	CurrentJobsDelayed int `json:"currentJobsDelayed" yaml:"current-jobs-delayed"`
	// is the number of buried jobs
	CurrentJobsBuried int `json:"currentJobsBuried" yaml:"current-jobs-buried"`
	// is the cumulative number of put commands
	CmdPut int `json:"cmdPut" yaml:"cmd-put"`
	// is the cumulative number of peek commands
	CmdPeek int `json:"cmdPeek" yaml:"cmd-peek"`
	// is the cumulative number of peek-ready commands
	CmdPeekReady int `json:"cmdPeekReady" yaml:"cmd-peek-ready"`
	// is the cumulative number of peek-delayed commands
	CmdPeekDelayed int `json:"cmdPeekDelayed" yaml:"cmd-peek-delayed"`
	// is the cumulative number of peek-buried commands
	CmdPeekBuried int `json:"cmdPeekBuried" yaml:"cmd-peek-buried"`
	// is the cumulative number of reserve commands
	CmdReserve int `json:"cmdReserve" yaml:"cmd-reserve"`
	// is the cumulative number of use commands
	CmdUse int `json:"cmdUse" yaml:"cmd-use"`
	// is the cumulative number of watch commands
	CmdWatch int `json:"cmdWatch" yaml:"cmd-watch"`
	// is the cumulative number of ignore commands
	CmdIgnore int `json:"cmdIgnore" yaml:"cmd-ignore"`
	// is the cumulative number of delete commands
	CmdDelete int `json:"cmdDelete" yaml:"cmd-delete"`
	// is the cumulative number of release commands
	CmdRelease int `json:"cmdRelease" yaml:"cmd-release"`
	// is the cumulative number of bury commands
	CmdBury int `json:"cmdBury" yaml:"cmd-bury"`
	// is the cumulative number of kick commands
	CmdKick int `json:"cmdKick" yaml:"cmd-kick"`
	// is the cumulative number of touch commands
	CmdTouch int `json:"cmdTouch" yaml:"cmd-touch"`
	// is the cumulative number of stats commands
	CmdStats int `json:"cmdStats" yaml:"cmd-stats"`
	// is the cumulative number of stats-job commands
	CmdStatsJob int `json:"cmdStatsJob" yaml:"cmd-stats-job"`
	// is the cumulative number of stats-tube commands
	CmdStatsTube int `json:"cmdStatsTube" yaml:"cmd-stats-tube"`
	// is the cumulative number of list-tubes commands
	CmdListTubes int `json:"cmdListTubes" yaml:"cmd-list-tubes"`
	// is the cumulative number of list-tube-used commands
	CmdListTubeUsed int `json:"cmdListTubeUsed" yaml:"cmd-list-tube-used"`
	// is the cumulative number of list-tubes-watched commands
	CmdListTubesWatched int `json:"cmdListTubesWatched" yaml:"cmd-list-tubes-watched"`
	// is the cumulative number of pause-tube command
	CmdPauseTube int `json:"cmdPauseTube" yaml:"cmd-pause-tube"`
	// is the cumulative count of times a job has timed out
	JobTimeouts int `json:"jobTimeouts" yaml:"job-timeouts"`
	// is the cumulative count of jobs created
	TotalJobs int `json:"totalJobs" yaml:"total-jobs"`
	// is the maximum number of bytes in a job
	MaxJobSize int `json:"maxJobSize" yaml:"max-job-size"`
	// is the number of currently-existing tubes
	CurrentTubes int `json:"currentTubes" yaml:"current-tubes"`
	// is the number of currently open connections
	CurrentConnections int `json:"currentConnections" yaml:"current-connections"`
	// is the number of open connections that have each issued at least one put command
	CurrentProducers int `json:"currentProducers" yaml:"current-producers"`
	// is the number of open connections that have each issued at least one reserve command
	CurrentWorkers int `json:"currentWorkers" yaml:"current-workers"`
	// is the number of open connections that have issued a reserve command but not yet received a response
	CurrentWaiting int `json:"currentWaiting" yaml:"current-waiting"`
	// is the cumulative count of connections
	TotalConnections int `json:"totalConnections" yaml:"total-connections"`
	// is the process id of the server
	PID int `json:"pid" yaml:"pid"`
	// is the version string of the server
	Version string `json:"version" yaml:"version"`
	// is the cumulative user CPU time of this process in seconds and microseconds
	RUsageUTime float64 `json:"rUsageUTime" yaml:"rusage-utime"`
	// is the cumulative system CPU time of this process in seconds and microseconds
	RUsageSTime float64 `json:"rUsageSTime" yaml:"rusage-stime"`
	// is the number of seconds since this server process started running
	Uptime int `json:"uptime" yaml:"uptime"`
	// is the index of the oldest binlog file needed to store the current jobs
	BinlogOldestIndex int `json:"binlogOldestIndex" yaml:"binlog-oldest-index"`
	// is the index of the current binlog file being written to. If binlog is not active this value will be 0
	BinlogCurrentIndex int `json:"binlogCurrentIndex" yaml:"binlog-current-index"`
	// is the maximum size in bytes a binlog file is allowed to get before a new binlog file is opened
	BinlogMaxSize int `json:"binlogMaxSize" yaml:"binlog-max-size"`
	// is the cumulative number of records written to the binlog
	BinlogRecordsWritten int `json:"binlogRecordsWritten" yaml:"binlog-records-written"`
	// is the cumulative number of records written as part of compaction
	BinlogRecordsMigrated int `json:"binlogRecordsMigrated" yaml:"binlog-records-migrated"`
	// is set to "true" if the server is in drain mode, "false" otherwise
	Draining bool `json:"draining" yaml:"draining"`
	// is a random id string for this server process, generated every time beanstalkd process starts
	ID string `json:"id" yaml:"id"`
	// is the hostname of the machine as determined by uname
	Hostname string `json:"hostname" yaml:"hostname"`
	// is the OS version as determined by uname
	OS string `json:"os" yaml:"os"`
	// is the machine architecture as determined by uname
	Platform string `json:"platform" yaml:"platform"`
}

type StatsCommand

type StatsCommand struct{}

func (StatsCommand) Body

func (c StatsCommand) Body() []byte

func (StatsCommand) BuildResponse

func (c StatsCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (StatsCommand) CommandLine

func (c StatsCommand) CommandLine() string

func (StatsCommand) HasResponseBody

func (c StatsCommand) HasResponseBody() bool

type StatsCommandResponse

type StatsCommandResponse struct {
	Data []byte
}

type StatsJob

type StatsJob struct {
	// is the job id
	ID int `json:"id" yaml:"id"`
	// is the name of the tube that contains this job
	Tube string `json:"tube" yaml:"tube"`
	// is "ready" or "delayed" or "reserved" or "buried"
	State string `json:"state" yaml:"state"`
	// is the priority value set by the put, release, or bury commands
	Priority int `json:"priority" yaml:"pri"`
	// is the time in seconds since the put command that created this job
	Age int `json:"age" yaml:"age"`
	// is the integer number of seconds to wait before putting this job in the ready queue
	Delay int `json:"delay" yaml:"delay"`
	// time to run -- is the integer number of seconds a worker is allowed to run this job
	TTR int `json:"ttr" yaml:"ttr"`
	// is the number of seconds left until the server puts this job into the ready queue
	TimeLeft int `json:"timeLeft" yaml:"time-left"`
	// is the number of the earliest binlog file containing this job
	File int `json:"file" yaml:"file"`
	// is the number of times this job has been reserved
	Reserves int `json:"reserves" yaml:"reserves"`
	// is the number of times this job has timed out during a reservation
	Timeouts int `json:"timeouts" yaml:"timeouts"`
	// is the number of times a client has released this job from a reservation
	Releases int `json:"releases" yaml:"releases"`
	// is the number of times this job has been buried
	Buries int `json:"buries" yaml:"buries"`
	// is the number of times this job has been kicked
	Kicks int `json:"kicks" yaml:"kicks"`
}

type StatsJobCommand

type StatsJobCommand struct {
	ID int
}

func (StatsJobCommand) Body

func (c StatsJobCommand) Body() []byte

func (StatsJobCommand) BuildResponse

func (c StatsJobCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (StatsJobCommand) CommandLine

func (c StatsJobCommand) CommandLine() string

func (StatsJobCommand) HasResponseBody

func (c StatsJobCommand) HasResponseBody() bool

type StatsJobCommandResponse

type StatsJobCommandResponse struct {
	Data []byte
}

type StatsTube

type StatsTube struct {
	// is the tube's name
	Name string `json:"name" yaml:"name"`
	// is the number of ready jobs with priority < 1024
	CurrentJobsUrgent int `json:"currentJobsUrgent" yaml:"current-jobs-urgent"`
	// is the number of jobs in the ready queue in this tube
	CurrentJobsReady int `json:"currentJobsReady" yaml:"current-jobs-ready"`
	// is the number of jobs reserved by all clients in this tube
	CurrentJobsReserved int `json:"currentJobsReserved" yaml:"current-jobs-reserved"`
	// is the number of delayed jobs in this tube
	CurrentJobsDelayed int `json:"currentJobsDelayed" yaml:"current-jobs-delayed"`
	// is the number of buried jobs in this tube
	CurrentJobsBuried int `json:"currentJobsBuried" yaml:"current-jobs-buried"`
	// is the cumulative count of jobs created in this tube in the current beanstalkd process
	TotalJobs int `json:"totalJobs" yaml:"total-jobs"`
	// is the number of open connections that are currently using this tube
	CurrentUsing int `json:"currentUsing" yaml:"current-using"`
	// is the number of open connections that have issued a reserve command while watching this tube but not yet received a response
	CurrentWaiting int `json:"currentWaiting" yaml:"current-waiting"`
	// is the number of open connections that are currently watching this tube
	CurrentWatching int `json:"currentWatching" yaml:"current-watching"`
	// is the number of seconds the tube has been paused for
	Pause int `json:"pause" yaml:"pause"`
	// is the cumulative number of delete commands for this tube
	CmdDelete int `json:"cmdDelete" yaml:"cmd-delete"`
	// is the cumulative number of pause-tube commands for this tube
	CmdPauseTube int `json:"cmdPauseTube" yaml:"cmd-pause-tube"`
	// is the number of seconds until the tube is un-paused
	PauseTimeLeft int `json:"pauseTimeLeft" yaml:"pause-time-left"`
}

type StatsTubeCommand

type StatsTubeCommand struct {
	Tube string
}

func (StatsTubeCommand) Body

func (c StatsTubeCommand) Body() []byte

func (StatsTubeCommand) BuildResponse

func (c StatsTubeCommand) BuildResponse(responseLine string, body []byte) (CommandResponse, error)

func (StatsTubeCommand) CommandLine

func (c StatsTubeCommand) CommandLine() string

func (StatsTubeCommand) HasResponseBody

func (c StatsTubeCommand) HasResponseBody() bool

type StatsTubeCommandResponse

type StatsTubeCommandResponse struct {
	Data []byte
}

type TouchCommand

type TouchCommand struct {
	ID int
}

func (TouchCommand) Body

func (c TouchCommand) Body() []byte

func (TouchCommand) BuildResponse

func (c TouchCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (TouchCommand) CommandLine

func (c TouchCommand) CommandLine() string

func (TouchCommand) HasResponseBody

func (c TouchCommand) HasResponseBody() bool

type TouchCommandResponse

type TouchCommandResponse struct{}

type UseCommand

type UseCommand struct {
	Tube string
}

func (UseCommand) Body

func (c UseCommand) Body() []byte

func (UseCommand) BuildResponse

func (c UseCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (UseCommand) CommandLine

func (c UseCommand) CommandLine() string

func (UseCommand) HasResponseBody

func (c UseCommand) HasResponseBody() bool

type UseCommandResponse

type UseCommandResponse struct {
	Tube string
}

type WatchCommand

type WatchCommand struct {
	Tube string
}

func (WatchCommand) Body

func (c WatchCommand) Body() []byte

func (WatchCommand) BuildResponse

func (c WatchCommand) BuildResponse(responseLine string, _ []byte) (CommandResponse, error)

func (WatchCommand) CommandLine

func (c WatchCommand) CommandLine() string

func (WatchCommand) HasResponseBody

func (c WatchCommand) HasResponseBody() bool

type WatchCommandResponse

type WatchCommandResponse struct {
	Count int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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