# Io Reference

Networking / Beanstalk / Beanstalk

beanstalkd is a fast, distributed, in-memory workqueue service. See http://xph.us/software/beanstalkd/
An example from http://xph.us/software/beanstalkd/:
First, have one process put a job into the queue:

    producer := Beanstalk clone connect("127.0.0.1:11300")
    producer put("hello")

Then start another process to take jobs out of the queue and run them:

    worker := Beanstalk clone connect("127.0.0.1:11300")
    loop(
    	job := worker reserve
    	job body println # prints "hello"
    	job delete
    )

See Beanstalk.io code and protocol description (http://github.com/kr/beanstalkd/tree/master/doc/protocol.txt) for details. Both are short and easy to read.
Stat commands depend on YAML.

bury(id, pri)

Puts a job into the "buried" state
connect(address)

Connects to a beanstalk server. address is a "host:port" string, e.g., "127.0.0.1:11300"
delete(id)

Removes a job with a given id from the server, entirely
put(body, pri, delay, ttr)

Inserts a job into the queue.
pri - priority, an integer < 2**32. Jobs with smaller priority values will be scheduled before jobs with larger priorities. The most urgent priority is 0; the least urgent priority is 4294967295.
delay - an integer number of seconds to wait before putting the job in the ready queue. The job will be in the "delayed" state during this time.
ttr - time to run, an integer number of seconds to allow a worker to run this job.
release(id)

Puts a reserved job back into the ready queue
reserve(timeout)

Returns and reserves a job (waits until one becomes available if necessary)
touch(id)

Allows a worker to request more time to work on a job.