GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - chadkouse/beanstalk.go: Client library for beanstalkd, written in Go.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

74 Commits
74 Commits

Folders and files

NameName
Last commit message
Last commit date
worker
worker
 
 
.gitignore
.gitignore
 
 
License
License
 
 
Makefile
Makefile
 
 
Readme.md
Readme.md
 
 
beanstalk.go
beanstalk.go
 
 
beanstalk_test.go
beanstalk_test.go
 
 

Repository files navigation

beanstalk.go

beanstalk.go is a client library for the protocol used by beanstalkd.

Installation

No need for that. Just put import "github.com/kr/beanstalk.go.git" at the top of your go package, and install your own package with goinstall.

Overview

To open a connection, do

conn, err := beanstalk.Dial("localhost:11300")

This package provides a simple, blocking interface. Go makes it easy to add asynchrony if you want.

Common Case: To submit a job and get its id, do

id, err := conn.Put(...)

Fire and Forget: If you don't care about the id, no need to wait around:

go conn.Put(...)

Full Asynchrony: If you don't want to wait but still need the id, it's still easy:

go func() {
  id, err := conn.Put(...)
}()

Concurrency and Optimizations

You can perform operations on the queue at will from all goroutines. This package will issue commands to beanstalkd and return results to where they belong. It'll also optimize the commands a bit to reduce network traffic.

For example, the use, watch, and ignore commands are managed entirely by this library, and issued only as necessary.

It also collects as many outbound commands as possible into a single network packet, for efficiency.

In the future, it will manage the order of outgoing commands to further reduce the need for use, watch, and ignore commands, and to prevent reserve commands from stalling other commands unnecessarily.

Complete Example

A producer:

package main

import "github.com/kr/beanstalk.go.git"

func main() {
    conn, err := beanstalk.Dial("localhost:11300")
    conn.Put("hello", 0, 0, 10)
}

And a worker:

package main

import "github.com/kr/beanstalk.go.git"

func main() {
    conn, err := beanstalk.Dial("localhost:11300")
    for {
        j, err := conn.Reserve()
        fmt.Println(j.Body) // prints "hello"
        j.Delete()
    }
}

Contributing

  1. Fix a bug or implement a new feature.
  2. Add tests verifying your change.
  3. Publish your changes in a public git repository. At most one feature or bug fix per commit. Topic branches are preferred, especially for larger changes.
  4. Send me email with the URL of your repository and the branch(es) you want pulled.

Credit Where It's Due

  • spymemcached for the idea of making optimizing transformations on the command stream.

  • Go's standard libraries, especially net and http, for inspiration and guidance.

About

Client library for beanstalkd, written in Go.

kr.github.com/beanstalk.go/

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.