Skip to content

Latest commit

 

History

History
89 lines (68 loc) · 1.29 KB

Readme.md

File metadata and controls

89 lines (68 loc) · 1.29 KB

#gobeanstalk Go Beanstalkd client library. Read the doc here .

INSTALL

go get github.com/iwanbk/gobeanstalk

USAGE

Producer

import (
	"github.com/iwanbk/gobeanstalk"
	"log"
	"time"
)

func main() {
	conn, err := gobeanstalk.Dial("localhost:11300")
	if err != nil {
		log.Fatal(err)
	}

	id, err := conn.Put([]byte("hello"), 0, 10*time.Second, 30*time.Second)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Job id %d inserted\n", id)
}

Consumer

import (
	"github.com/iwanbk/gobeanstalk"
	"log"
)

func main() {
	conn, err := gobeanstalk.Dial("localhost:11300")
	if err != nil {
		log.Fatal(err)
	}
	for {
		j, err := conn.Reserve()
		if err != nil {
			log.Fatal(err)
		}
		log.Printf("id:%d, body:%s\n", j.ID, string(j.Body))
		err = conn.Delete(j.ID)
		if err != nil {
			log.Fatal(err)
		}
	}
}

Implemented Commands

Producer commands:

  • use
  • put

Worker commands:

  • watch
  • ignore
  • reserve
  • delete
  • touch
  • release
  • bury

Other commands:

  • stats-job
  • quit

Release Notes

Latest release is v0.3 that contains API changes, see release notes here

Author