{"id":13777309,"url":"https://github.com/rainingmaster/lua-resty-nsq","last_synced_at":"2025-04-11T14:42:43.991Z","repository":{"id":88266169,"uuid":"140068974","full_name":"rainingmaster/lua-resty-nsq","owner":"rainingmaster","description":"lua-resty-nsq - Lua nsq client driver for the ngx_lua based on the cosocket API","archived":false,"fork":false,"pushed_at":"2020-06-09T03:57:53.000Z","size":12,"stargazers_count":21,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-02-14T20:37:06.138Z","etag":null,"topics":["lua","lua-resty","nsq","openresty"],"latest_commit_sha":null,"homepage":"","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/rainingmaster.png","metadata":{"files":{"readme":"README.markdown","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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-07-07T09:02:30.000Z","updated_at":"2023-08-03T12:23:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"e0442afa-d74c-458d-a802-929a9aa323f2","html_url":"https://github.com/rainingmaster/lua-resty-nsq","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainingmaster%2Flua-resty-nsq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainingmaster%2Flua-resty-nsq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainingmaster%2Flua-resty-nsq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainingmaster%2Flua-resty-nsq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rainingmaster","download_url":"https://codeload.github.com/rainingmaster/lua-resty-nsq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248420285,"owners_count":21100352,"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":["lua","lua-resty","nsq","openresty"],"created_at":"2024-08-03T18:00:41.337Z","updated_at":"2025-04-11T14:42:43.969Z","avatar_url":"https://github.com/rainingmaster.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"Name\n====\n\nlua-resty-nsq - Lua nsq client driver for the ngx_lua based on the cosocket API\n\nTable of Contents\n=================\n\n* [Name](#name)\n* [Status](#status)\n* [Description](#description)\n* [Synopsis](#synopsis)\n* [Modules](#methods)\n    * [resty.nsq.producer](#producer)\n        * [Methods](#methods)\n            * [new](#new)\n            * [pub](#pub)\n            * [nop](#nop)\n            * [close](#close)\n    * [resty.nsq.consumer](#consumer)\n        * [Methods](#methods)\n            * [new](#new)\n            * [sub](#sub)\n            * [rdy](#rdy)\n            * [fin](#fin)\n            * [req](#req)\n            * [close](#close)\n* [NSQ Authentication](#nsq-authentication)\n* [Installation](#installation)\n* [Copyright and License](#copyright-and-license)\n* [See Also](#see-also)\n\nStatus\n======\n\n[![Build Status](https://www.travis-ci.org/rainingmaster/lua-resty-nsq.svg?branch=master)](https://www.travis-ci.org/rainingmaster/lua-resty-nsq)\n\nThis library is developing.\n\nDescription\n===========\n\nThis Lua library is a NSQ client driver for the ngx_lua nginx module:\n\nThis Lua library takes advantage of ngx_lua's cosocket API, which ensures\n100% nonblocking behavior.\n\nSynopsis\n========\n\n```lua\n    lua_package_path \"/path/to/lua-resty-nsq/lib/?.lua;;\";\n\n    server {\n        location /test {\n            content_by_lua_block {\n                local config = {\n                    read_timeout = 3,\n                    heartbeat = 1,\n                }\n                local producer = require \"resty.nsq.producer\"\n                local consumer = require \"resty.nsq.consumer\"\n\n                local cons = consumer:new()\n                local prod = producer:new()\n\n                local ok, err = cons:connect(\"127.0.0.1\", 4150, config)\n                if not ok then\n                    ngx.say(\"failed to connect: \", err)\n                    return\n                end\n\n                local ok, err = prod:connect(\"127.0.0.1\", 4150)\n                if not ok then\n                    ngx.say(\"failed to connect: \", err)\n                    return\n                end\n\n                ok, err = prod:pub(\"new_topic\", \"hellow world!\")\n                if not ok then\n                    ngx.say(\"failed to pub: \", err)\n                    return\n                end\n\n                ok, err = prod:close()\n                if not ok then\n                    ngx.say(\"failed to close: \", err)\n                    return\n                end\n\n                ok, err = cons:sub(\"new_topic\", \"new_channel\")\n                if not ok then\n                    ngx.say(\"failed to sub: \", err)\n                    return\n                end\n\n                local function read(c)\n                    c:rdy(10)\n                    local ret = cons:message()\n                    ngx.say(\"sub success: \", require(\"cjson\").encode(ret))\n                end\n\n                local co = ngx.thread.spawn(read, cons) -- read message in new thread\n                ngx.thread.wait(co)\n\n                ok, err = cons:close()\n                if not ok then\n                    ngx.say(\"failed to close: \", err)\n                    return\n                end\n            }\n        }\n    }\n```\n\n[Back to TOC](#table-of-contents)\n\nModules\n=======\n\n[Back to TOC](#table-of-contents)\n\nresty.nsq.producer\n--------\n\n[Back to TOC](#table-of-contents)\n\n### Methods\n\n[Back to TOC](#table-of-contents)\n\n#### new\n\n[Back to TOC](#table-of-contents)\n\n#### pub\n\n[Back to TOC](#table-of-contents)\n\nresty.nsq.consumer\n--------\n\n[Back to TOC](#table-of-contents)\n\n### Methods\n\n[Back to TOC](#table-of-contents)\n\n#### new\n\n[Back to TOC](#table-of-contents)\n\nInstallation\n====\n\nexport LUA_LIB_DIR=/path/to/lualib \u0026\u0026 make install\n\n[Back to TOC](#table-of-contents)\n\nTODO\n====\n\n[Back to TOC](#table-of-contents)\n\nCopyright and License\n=====================\n\nThis module is licensed under the BSD license.\n\nCopyright (C) 2018-2018, by rainingmaster.\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\n[Back to TOC](#table-of-contents)\n\nSee Also\n========\n* the ngx_lua module: https://github.com/openresty/lua-nginx-module/#readme\n* the nsq wired protocol specification: https://nsq.io/clients/tcp_protocol_spec.html\n* [the semaphore in openresty: ngx.sema](https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/semaphore.md)\n* [the thread in openresty: ngx.thread](https://github.com/openresty/lua-nginx-module#ngxthreadspawn)\n\n[Back to TOC](#table-of-contents)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainingmaster%2Flua-resty-nsq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frainingmaster%2Flua-resty-nsq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainingmaster%2Flua-resty-nsq/lists"}