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!"))
- with-hen TCP-CONNECTION &FORMSprocedure
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:
- (hen-reserve [TIMEOUT #f])procedure
- hen-use TUBEprocedure
- hen-delete IDprocedure
- (hen-bury ID [PRI 2^31])procedure
- hen-touch IDprocedure
- hen-watch TUBEprocedure
- hen-ignore TUBEprocedure
- hen-peek IDprocedure
- hen-kick boundprocedure
- hen-stats-job IDprocedure
- hen-stats-tube TUBEprocedure
- hen-pause-tube TUBE DELAYprocedure
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.
All hen commands also accept keyword arguments #:tcp-in and #:tcp-out to override hen-in and hen-out, which are the default ports, initially unspecified.
- 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
- Bug fixes for default priority on 32 bit systems and for unconsumed response data (Thanks to Tom Danielson)
- Bug fix for hen-list-tubes-watched, fixed egg dependencies
- 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