rspamd_upstream_list
This module implements upstreams manipulation from LUA API. This functionality can be used for load balancing using different strategies including:
Here is an example of upstreams manipulations:
Functions:
Function | Description |
---|---|
upstream_list.create(cfg, def, [default_port]) |
Create new upstream list from its string definition in form <upstream>,<upstream>;<upstream> . |
Methods:
Method | Description |
---|---|
upstream:get_addr() |
Get ip of upstream. |
upstream:get_name() |
Get name of upstream. |
upstream:get_port() |
Get port of upstream. |
upstream:fail() |
Indicate upstream failure. |
upstream:ok() |
Indicates upstream success. |
upstream_list:get_upstream_by_hash(key) |
Get upstream by hash from key. |
upstream_list:get_upstream_round_robin() |
Get upstream round robin (by current weight). |
upstream_list:get_upstream_master_slave() |
Get upstream master slave order (by static priority). |
upstream_list:all_upstreams() |
Returns all upstreams for this list. |
upstream_list:add_watcher(what, cb) |
Add new watcher to the upstream lists events (table or a string). |
The module rspamd_upstream_list
defines the following functions.
upstream_list.create(cfg, def, [default_port])
Create new upstream list from its string definition in form <upstream>,<upstream>;<upstream>
Parameters:
cfg {rspamd_config}
: configuration referencedef {string}
: upstream list definitiondefault_port {number}
: default port for upstreamsReturns:
{upstream_list}
: upstream list structureBack to module description.
The module rspamd_upstream_list
defines the following methods.
upstream:get_addr()
Get ip of upstream
Parameters:
No parameters
Returns:
{ip}
: ip address objectBack to module description.
upstream:get_name()
Get name of upstream
Parameters:
No parameters
Returns:
{string}
: name of the upstreamBack to module description.
upstream:get_port()
Get port of upstream
Parameters:
No parameters
Returns:
{int}
: port of the upstreamBack to module description.
upstream:fail()
Indicate upstream failure. After certain amount of failures during specified time frame, an upstream is marked as down and does not participate in rotations.
Parameters:
No parameters
Returns:
No return
Back to module description.
upstream:ok()
Indicates upstream success. Resets errors count for an upstream.
Parameters:
No parameters
Returns:
No return
Back to module description.
upstream_list:get_upstream_by_hash(key)
Get upstream by hash from key
Parameters:
key {string}
: a string used as input for stable hash algorithmReturns:
{upstream}
: upstream from a list corresponding to the given keyBack to module description.
upstream_list:get_upstream_round_robin()
Get upstream round robin (by current weight)
Parameters:
No parameters
Returns:
{upstream}
: upstream from a list in round-robin matterBack to module description.
upstream_list:get_upstream_master_slave()
Get upstream master slave order (by static priority)
Parameters:
No parameters
Returns:
{upstream}
: upstream from a list in master-slave orderBack to module description.
upstream_list:all_upstreams()
Returns all upstreams for this list
Parameters:
No parameters
Returns:
{table|upstream}
: all upstreams definedBack to module description.
upstream_list:add_watcher(what, cb)
Add new watcher to the upstream lists events (table or a string):
success
- called whenever upstream successfully usedfailure
- called on upstream erroronline
- called when upstream is being taken online from offlineoffline
- called when upstream is being taken offline from online
Callback is a function: function(what, upstream, cur_errors) … endParameters:
No parameters
Returns:
Back to module description.
Back to top.