{"id":13776851,"url":"https://github.com/vislee/lua-resty-wrr","last_synced_at":"2026-01-17T17:49:41.767Z","repository":{"id":78680462,"uuid":"429987406","full_name":"vislee/lua-resty-wrr","owner":"vislee","description":null,"archived":false,"fork":false,"pushed_at":"2021-11-29T11:54:46.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-02-14T18:34:22.233Z","etag":null,"topics":["lua","luajit","openresty","roundrobin"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vislee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-11-20T02:17:49.000Z","updated_at":"2022-02-09T12:16:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"36b72e40-a8cc-4bfd-8ddb-0a585490c1da","html_url":"https://github.com/vislee/lua-resty-wrr","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/vislee%2Flua-resty-wrr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vislee%2Flua-resty-wrr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vislee%2Flua-resty-wrr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vislee%2Flua-resty-wrr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vislee","download_url":"https://codeload.github.com/vislee/lua-resty-wrr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253551763,"owners_count":21926353,"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","luajit","openresty","roundrobin"],"created_at":"2024-08-03T18:00:33.970Z","updated_at":"2026-01-17T17:49:41.758Z","avatar_url":"https://github.com/vislee.png","language":"Perl","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# lua-resty-wrr\nweight round robin for Openresty. Similar to `ngx_http/stream_upstream_round_robin` module.\n\n\nTable of Contents\n=================\n\n* [Synopsis](#synopsis)\n* [Methods](#methods)\n    * [new](#new)\n    * [init](#init)\n    * [get](#get)\n    * [free](#free)\n* [Author](#author)\n* [Copyright and License](#copyright-and-license)\n\n\nSynopsis\n========\n\n```nginx\nhttp {\n\n    ...\n\n    init_by_lua_block {\n        local wrr = require \"resty.wrr\"\n        local servers = {\n            {addr=\"192.168.0.1:80\",weight=1,max_fails=5,fail_timeout=3,max_conns=1000,},\n            {addr=\"192.168.0.2:80\",weight=2,max_fails=5,fail_timeout=3,max_conns=2000,},\n        }\n        rrp = wrr.new(servers)\n    }\n\n    server {\n        listen 8080;\n\n        location / {\n            access_by_lua_block {\n                local peer = rrp:init()\n                local s = peer:get()\n                ...\n                peer:free()\n            }\n\n            proxy_pass ups;\n        }\n    }\n}\n```\n\n[Back to TOC](#table-of-contents)\n\n\nMethods\n=======\n\nnew\n---\n`syntax: rrp, err = wrr.new(servers)`\n\nCreates a wrr object by `servers`. the failures, returns `nil` and error.\n\n\ninit\n----\n`syntax: peer = rrp:init(tries?)`\n\nCreates a object for request. the `tries` is max retry times.\n\n`peer.tries`: remaining retry times.\n\n\nget\n---\n`syntax: server = peer:get()`\n\nPick a upstream server in peer object. No server is available, returns `nil`.\n\n\nfree\n----\n`syntax: peer:free(state?)`\n\nFree the pick server and report a health failure, the `state` is `wrr.PEER_FAILED`(failed) or 0(OK).\n\n\n[Back to TOC](#table-of-contents)\n\n\n\nAuthor\n======\n\nwenqiang li(vislee)\n\n[Back to TOC](#table-of-contents)\n\n\n\nCopyright and License\n=====================\n\nThis module is licensed under the BSD license.\n\nCopyright (C) 2021-, by vislee.\n\nAll rights reserved.\n\n[Back to TOC](#table-of-contents)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvislee%2Flua-resty-wrr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvislee%2Flua-resty-wrr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvislee%2Flua-resty-wrr/lists"}