beanWork

package module
v0.0.0-...-0b0079d Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: MIT Imports: 3 Imported by: 0

README

beanWork Build Status GoDoc

Worker client for beanstalkd. Written in Go by Yaron Sumel.

PR are welcome!

Install

$ go get github.com/yaronsumel/beanWork

Usage


    import "github.com/yaronsumel/beanWork"

	bw := &beanWork.BeanWorker{"tcp4","127.0.0.1:11300"}

	amountOfWorkers := 5
	bw.Worker("mytube",amountOfWorkers,func(job *beanWork.BeanJob) {
		//do some work here
		job.Delete()
	})
	
	bw.Run()

TBD

* Recover from lost connections

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeanJob

type BeanJob struct {
	Id   uint64
	Body []byte
	// contains filtered or unexported fields
}

func (*BeanJob) Bury

func (j *BeanJob) Bury(pri uint32) error

Bury places the given job in a holding area in the job's tube and sets its priority to pri. The job will not be scheduled again until it has been kicked; see also the documentation of Kick.

func (*BeanJob) Delete

func (j *BeanJob) Delete() error

Delete deletes the given job.

func (*BeanJob) Peek

func (j *BeanJob) Peek() (body []byte, err error)

Peek gets a copy of the specified job from the server.

func (*BeanJob) Release

func (j *BeanJob) Release(pri uint32, delay time.Duration) error

Release tells the server to perform the following actions: set the priority of the given job to pri, remove it from the list of jobs reserved by c, wait delay seconds, then place the job in the ready queue, which makes it available for reservation by any client.

func (*BeanJob) StatsJob

func (j *BeanJob) StatsJob() (map[string]string, error)

StatsJob retrieves statistics about the given job.

func (*BeanJob) Touch

func (j *BeanJob) Touch() error

Touch resets the reservation timer for the given job. It is an error if the job isn't currently reserved by c. See the documentation of Reserve for more details.

type BeanWorker

type BeanWorker struct {
	Net     string
	Address string
}

func (*BeanWorker) Run

func (bw *BeanWorker) Run()

run waits for incoming chan messages

func (*BeanWorker) Worker

func (bw *BeanWorker) Worker(tube string, numberOfWorkers int, fn JobHandler)

create number of worker as go routines

type JobHandler

type JobHandler func(*BeanJob)

callback function

Jump to

Keyboard shortcuts

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