You are looking at historical revision 23231 of this page. It may differ significantly from its current revision.
hen --- a beanstalk client
beanstalk is a protocol for interfacing with beanstalkd, a "simple, fast work queue."
hen is a simple client for workers and producers
(with-hen (tcp-connect "localhost" 11300) (while #t (hen-ignore "default") (hen-watch "my-tube") (let ([job (hen-reserve)]) ; blocks, optional timeout parameter (my-process-job job) (hen-delete ((compose cdr assoc) 'id job)))))
(with-hen (tcp-connect "localhost" 11300) (hen-use "my-tube") (hen-put "hello worker!"))
Procedures[procedure] (with-hen TCP-CONNECTION &FORMS)
This wrapper procedure is for added convenience. TCP-CONNECTION should be a multi-value as is returned from tcp-connect in tcp6. with-hen is used as in the examples above. It will automatically call hen-quit and return the value of the last form provided to be evaluated.
The following are supported beanstalk commands:[procedure] (hen-put [PRI 2^31 [DELAY 0 [TTR 36000]]] data)
[procedure] (hen-reserve [TIMEOUT #f])
[procedure] (hen-use TUBE)
[procedure] (hen-delete ID)
[procedure] (hen-release ID [PRI 2^31 [DELAY 0]])
[procedure] (hen-bury ID [PRI 2^31])
[procedure] (hen-touch ID)
[procedure] (hen-watch TUBE)
[procedure] (hen-ignore TUBE)
[procedure] (hen-peek ID)
[procedure] (hen-kick bound)
[procedure] (hen-stats-job ID)
[procedure] (hen-stats-tube TUBE)
[procedure] (hen-pause-tube TUBE DELAY)
Most of the commands will return a simple string status. Exceptions are the stats commands, which return an alist, and the reserve command, which returns a pair (job-id . data) if a job is reserved.
- The structure of return values is subject to change.
Source code is available in the eggs repository as well as on github: https://github.com/joseph-gay/cscm-hen
- Initial release
Copyright (C) 2011 by Joseph Gay This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA