beanstalk.go is a client library for the protocol used by beanstalkd.
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.
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(...)
}()
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.
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()
}
}
- Fix a bug or implement a new feature.
- Add tests verifying your change.
- 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.
- Send me email with the URL of your repository and the branch(es) you want pulled.
-
spymemcached for the idea of making optimizing transformations on the command stream.
-
Go's standard libraries, especially net and http, for inspiration and guidance.
beanstalk.go's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.