{"id":13636517,"url":"https://github.com/zhhchen/lua-resty-gearman","last_synced_at":"2025-04-19T08:32:26.549Z","repository":{"id":5744279,"uuid":"6956709","full_name":"zhhchen/lua-resty-gearman","owner":"zhhchen","description":"Lua gearman client driver for the ngx_lua based on the cosocket API ","archived":false,"fork":false,"pushed_at":"2013-11-20T06:08:08.000Z","size":183,"stargazers_count":25,"open_issues_count":2,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-02-14T20:36:22.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhhchen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-01T17:03:21.000Z","updated_at":"2022-04-15T21:20:38.000Z","dependencies_parsed_at":"2022-08-29T14:30:51.260Z","dependency_job_id":null,"html_url":"https://github.com/zhhchen/lua-resty-gearman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhhchen%2Flua-resty-gearman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhhchen%2Flua-resty-gearman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhhchen%2Flua-resty-gearman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhhchen%2Flua-resty-gearman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhhchen","download_url":"https://codeload.github.com/zhhchen/lua-resty-gearman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223795240,"owners_count":17204136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T00:01:02.216Z","updated_at":"2024-11-09T06:30:32.991Z","avatar_url":"https://github.com/zhhchen.png","language":"Lua","funding_links":[],"categories":["Libraries","Third Modules","Rust Modules"],"sub_categories":["C Modules","Lua Modules"],"readme":"Name\n====\n\nlua-resty-gearman - Lua gearman client driver for the ngx_lua based on the cosocket API \n\nStatus\n======\n\nThis library is considered experimental and still under active development.\n\nDescription\n===========\n\nThis Lua library is a Gearman client driver for the ngx_lua nginx module:\n\nhttp://wiki.nginx.org/HttpLuaModule\n\nThis Lua library takes advantage of ngx_lua's cosocket API, which ensures\n100% nonblocking behavior.\n\nNote that at least [ngx_lua 0.5.14](https://github.com/chaoslawful/lua-nginx-module/tags) or [ngx_openresty 1.2.1.14](http://openresty.org/#Download) is required.\n\nSynopsis\n========\n\n    lua_package_path \"/path/to/lua-resty-gearman/lib/?.lua;;\";\n\n    server {\n        location /test {\n            content_by_lua '\n                local gearman = require \"resty.gearman\"\n                local gm = gearman:new()\n\n                gm:set_timeout(1000) -- 1 sec\n\n                local ok, err = gm:connect(\"127.0.0.1\", 4730)\n                if not ok then\n                    ngx.say(\"failed to connect: \", err)\n                    return\n                end\n\n                ok, err = gm:submit_job(\"wc\", \"11111\\n22222\\n33333\")  \n                -- submit_job,submit_job_bg,submit_job_high,submit_job_high_bg,submit_job_low,submit_job_low_bg are supported\n                -- submit_job(function_name, workload[, unique])\n                \n                if not ok then\n                    ngx.say(\"failed to submit job: \", err)\n                    return\n                else\n                    ngx.say(ok)                \n                end\n\n                -- put it into the connection pool of size 100,\n                -- with 0 idle timeout\n                local ok, err = gm:set_keepalive(0, 100)\n                if not ok then\n                    ngx.say(\"failed to set keepalive: \", err)\n                    return\n                end\n\n                -- or just close the connection right away:\n                -- local ok, err = gm:close()\n                -- if not ok then\n                --     ngx.say(\"failed to close: \", err)\n                --     return\n                -- end\n            ';\n        }\n    }\n\n\nMethods\n===========\n\n\nLimitations\n===========\n\n* Now only client tasks(submit_job,submit_job_bg,submit_job_high,submit_job_high_bg,submit_job_low,submit_job_low_bg)\nare supported.\n* This library cannot be used in code contexts like set_by_lua*, log_by_lua*, and\nheader_filter_by_lua* where the ngx_lua cosocket API is not available.\n* The `resty.gearman` object instance cannot be stored in a Lua variable at the Lua module level,\nbecause it will then be shared by all the concurrent requests handled by the same nginx\n worker process (see\nhttp://wiki.nginx.org/HttpLuaModule#Data_Sharing_within_an_Nginx_Worker ) and\nresult in bad race conditions when concurrent requests are trying to use the same `resty.gearman` instance.\nYou should always initiate `resty.gearman` objects in function local\nvariables or in the `ngx.ctx` table. These places all have their own data copies for\neach request.\n\nInstallation\n============\n\nIf you are using the ngx_openresty bundle (http://openresty.org ), then\nyou don't need to do anything because it already includes and enables\nlua-resty-gearman by default. And you can just use it in your Lua code,\nas in\n\n    local gearman = require \"resty.gearman\"\n    ...\n\nIf you're using your own nginx + ngx_lua build, then you need to configure\nthe lua_package_path directive to add the path of your lua-resty-gearman source\ntree to ngx_lua's LUA_PATH search path, as in\n\n    # nginx.conf\n    http {\n        lua_package_path \"/path/to/lua-resty-gearman/lib/?.lua;;\";\n        ...\n    }\n\nTODO\n====\n\nCommunity\n=========\n\nEnglish Mailing List\n--------------------\n\nThe [openresty-en](https://groups.google.com/group/openresty-en) mailing list is for English speakers.\n\nChinese Mailing List\n--------------------\n\nThe [openresty](https://groups.google.com/group/openresty) mailing list is for Chinese speakers.\n\nBugs and Patches\n================\n\nPlease report bugs or submit patches by\n\n1. creating a ticket on the [GitHub Issue Tracker](http://github.com/zhhchen/lua-resty-gearman/issues)\n\nAuthor\n======\n\nZhihua Chen (陈智华) \u003czhhchen@gmail.com\u003e\n\nCopyright and License\n=====================\n\nThis module is licensed under the BSD license.\n\nCopyright (C) 2012, by Zhihua Chen (陈智华) \u003czhhchen@gmail.com\u003e.\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nSee Also\n========\n* the ngx_lua module: http://wiki.nginx.org/HttpLuaModule\n* the gearman protocol specification: http://gearman.org/doku.php?id=protocol\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhhchen%2Flua-resty-gearman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhhchen%2Flua-resty-gearman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhhchen%2Flua-resty-gearman/lists"}