Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vislee/lua-resty-wrr
https://github.com/vislee/lua-resty-wrr
lua luajit openresty roundrobin
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vislee/lua-resty-wrr
- Owner: vislee
- License: bsd-2-clause
- Created: 2021-11-20T02:17:49.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-29T11:54:46.000Z (almost 3 years ago)
- Last Synced: 2024-02-14T18:34:22.233Z (9 months ago)
- Topics: lua, luajit, openresty, roundrobin
- Language: Perl
- Homepage:
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-resty - lua-resty-wrr - weight round robin for Openresty. Similar to ngx_http/stream_upstream_round_robin module. (Libraries)
README
# lua-resty-wrr
weight round robin for Openresty. Similar to `ngx_http/stream_upstream_round_robin` module.Table of Contents
=================* [Synopsis](#synopsis)
* [Methods](#methods)
* [new](#new)
* [init](#init)
* [get](#get)
* [free](#free)
* [Author](#author)
* [Copyright and License](#copyright-and-license)Synopsis
========```nginx
http {...
init_by_lua_block {
local wrr = require "resty.wrr"
local servers = {
{addr="192.168.0.1:80",weight=1,max_fails=5,fail_timeout=3,max_conns=1000,},
{addr="192.168.0.2:80",weight=2,max_fails=5,fail_timeout=3,max_conns=2000,},
}
rrp = wrr.new(servers)
}server {
listen 8080;location / {
access_by_lua_block {
local peer = rrp:init()
local s = peer:get()
...
peer:free()
}proxy_pass ups;
}
}
}
```[Back to TOC](#table-of-contents)
Methods
=======new
---
`syntax: rrp, err = wrr.new(servers)`Creates a wrr object by `servers`. the failures, returns `nil` and error.
init
----
`syntax: peer = rrp:init(tries?)`Creates a object for request. the `tries` is max retry times.
`peer.tries`: remaining retry times.
get
---
`syntax: server = peer:get()`Pick a upstream server in peer object. No server is available, returns `nil`.
free
----
`syntax: peer:free(state?)`Free the pick server and report a health failure, the `state` is `wrr.PEER_FAILED`(failed) or 0(OK).
[Back to TOC](#table-of-contents)
Author
======wenqiang li(vislee)
[Back to TOC](#table-of-contents)
Copyright and License
=====================This module is licensed under the BSD license.
Copyright (C) 2021-, by vislee.
All rights reserved.
[Back to TOC](#table-of-contents)