hello, All!

i wrote a non-blocking beantalkd client lib (lua_rest-beanstalkd) for
ngx_lua, url: https://github.com/smallfish/lua-resty-beanstalkd
ngx_lua is 3rd module for nginx. just like "embed the lua power of nginx"
http://wiki.nginx.org/HttpLuaModule

the lua-resty-beanstalkd like other lua-resty-xx, example: memcached/redis,
etc...

test system: MacOS10.8/Ubuntu10.10/ngx_openresty1.2.3.8/1.0.11.28

example:

location /test {
        content_by_lua '

            local beanstalkd = require 'resty.beanstalkd'

            -- new and connect
            local bean, err = beanstalkd:new()
            if not bean then
                ngx.say("failed to init beanstalkd:", err)
                return
            end
            ngx.say("initialized ok")

            local ok, err = bean:connect()
            if not ok then
                ngx.say("failed to connect beanstalkd:", err)
                return
            end
            ngx.say("connect ok")

            -- use tube
            local ok, err = bean:use("smallfish")
            if not ok then
                ngx.say("failed to use tube:", err)
            end
            ngx.say("use smallfish tube ok")

            -- put job
            local id, err = bean:put("hello")
            if not id then
                ngx.say("failed to put hello to smallfish tube, error:", err)
            end
            ngx.say("put hello to smallfish tube, id:", id)

            -- watch tube
            local ok, err = bean:watch("smallfish")
            if not ok then
                ngx.say("failed to watch tube smallfish, error:", err)
                return
            end
            ngx.say("watch smallfish tube ok, tube size:", ok)

            -- reserve job
            local id, data = bean:reserve()
            if not id then
                ngx.say("reserve hello failed, error:", id, data)
            else
                ngx.say("reserve hello ok, id:", id, "data:", data)
                -- delete job
                local ok, err = bean:delete(id)
                if ok then
                    ngx.say("delete ok, id:", id)
                else
                    ngx.say("delete failed, id:", id, ok, err)
                end
            end

            -- close
            bean:close()
       ';
    }



--
smallfish http://chenxiaoyu.org

-- 
You received this message because you are subscribed to the Google Groups 
"beanstalk-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/beanstalk-talk?hl=en.

Reply via email to