Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Go Beanstalkd Client Library

branch: master
Readme.md

gobeanstalk

Go Beanstalkd client library. Read the doc here .

INSTALL

go get github.com/iwanbk/gobeanstalk

USAGE

Producer

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

func main() {
    conn, err := gobeanstalk.Dial("localhost:11300")
    if err != nil {
        log.Fatal(err)
    }
    id, err := conn.Put([]byte("hello"), 0, 0, 10)
    if err != nil {
        log.Fatal(err)
    }

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

Consumer

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

func main() {
    conn, err := gobeanstalk.Dial("localhost:11300")
    if err != nil {
        log.Printf("connect failed")
        log.Fatal(err)
    }
    for {
        j, err := conn.Reserve()
        if err != nil {
            log.Println("reserve failed")
            log.Fatal(err)
        }
        fmt.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:

  • quit

Author

Something went wrong with that request. Please try again.