bs

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package bs provides a richer and/or more domain-specific layer over github.com/kr/beanstalk, including active-record style Job type.

Index

Constants

View Source
const (
	// deadlineSoonDelay defines a period to sleep between receiving
	// DEADLINE_SOON in response to reserve, and re-attempting the reserve.
	DeadlineSoonDelay = 1 * time.Second
)

Variables

This section is empty.

Functions

func MustReserveWithoutTimeout

func MustReserveWithoutTimeout(ts *beanstalk.TubeSet) (id uint64, body []byte)

reserve-with-timeout until there's a job or something panic-worthy. Handles beanstalk.ErrTimeout by retrying immediately. Handles beanstalk.ErrDeadline by sleeping DeadlineSoonDelay before retry. panics for other errors.

Types

type Job

type Job struct {

	// The numeric beanstalkd-assigned job ID.
	Id uint64

	// The job payload data.
	Body []byte
	// contains filtered or unexported fields
}

Job represents a beanstalkd job, and holds a reference to the connection so that server actions can be taken as methods on the job.

func NewJob

func NewJob(id uint64, body []byte, conn *beanstalk.Conn) Job

Create a Job instance.

func (Job) Bury

func (j Job) Bury() error

Bury the job, with its original priority.

func (Job) Delete

func (j Job) Delete() error

Delete the job.

func (Job) Priority

func (j Job) Priority() (uint32, error)

Priority of the job, zero is most urgent, 4,294,967,295 is least.

func (Job) Release

func (j Job) Release(delay time.Duration) error

Release the job, with its original priority and no delay.

func (Job) Releases

func (j Job) Releases() (uint64, error)

Releases counts how many times the job has been released back to the tube.

func (Job) String

func (j Job) String() string

func (Job) TimeLeft

func (j Job) TimeLeft() (time.Duration, error)

TimeLeft as reported by beanstalkd, as a time.Duration. beanstalkd reports as int(seconds), which defines the (low) precision. Less than 1.0 seconds remaining will be reported as zero.

func (Job) Timeouts

func (j Job) Timeouts() (uint64, error)

Timeouts counts how many times the job has been reserved and reached TTR.

Jump to

Keyboard shortcuts

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