chickadee » hen

hen --- a beanstalk client

Description

beanstalk is a protocol for interfacing with beanstalkd, a "simple, fast work queue."

hen is a simple client for workers and producers

Author

Joseph Gay

Requirements

dsssl-utils

list-utils

miscmacros

tcp6

Documentation

Examples

Worker:
(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)))))
Producer:
(with-hen (tcp-connect "localhost" 11300)
  (hen-use "my-tube")
  (hen-put "hello worker!"))

Procedures

(with-hen TCP-CONNECTION &FORMS) procedure

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-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-peek-ready) procedure
(hen-peek-delayed) procedure
(hen-peek-buried) procedure
(hen-kick bound) procedure
(hen-stats-job ID) procedure
(hen-stats-tube TUBE) procedure
(hen-stats) procedure
(hen-list-tubes) procedure
(hen-list-tube-used) procedure
(hen-list-tubes-watched) procedure
(hen-quit) procedure
(hen-pause-tube TUBE DELAY) procedure

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.

Notes

Source

Source code is available in the eggs repository as well as on github: https://github.com/joseph-gay/cscm-hen

Version

0.7
Bug fixes for default priority on 32 bit systems and for unconsumed response data (Thanks to Tom Danielson)
0.6
Bug fix for hen-list-tubes-watched, fixed egg dependencies
0.5
Initial release

License

 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

Contents »