DOC: lua: restore 80 char limitation
Restore 80 char limitation throughout the file for easier reading on the cli, and fix some raw formatting issues without altering html rendering.
This commit is contained in:
parent
096b383e16
commit
2dac67af7d
@ -150,8 +150,8 @@ Core class
|
|||||||
.. js:class:: core
|
.. js:class:: core
|
||||||
|
|
||||||
The "core" class contains all the HAProxy core functions. These function are
|
The "core" class contains all the HAProxy core functions. These function are
|
||||||
useful for the controlling of the execution flow, registering hooks, manipulating
|
useful for the controlling of the execution flow, registering hooks,
|
||||||
global maps or ACL, ...
|
manipulating global maps or ACL, ...
|
||||||
|
|
||||||
"core" class is basically provided with HAProxy. No `require` line is
|
"core" class is basically provided with HAProxy. No `require` line is
|
||||||
required to uses these function.
|
required to uses these function.
|
||||||
@ -163,49 +163,57 @@ Core class
|
|||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "emergency" (0).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"emergency" (0).
|
||||||
|
|
||||||
.. js:attribute:: core.alert
|
.. js:attribute:: core.alert
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "alert" (1).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"alert" (1).
|
||||||
|
|
||||||
.. js:attribute:: core.crit
|
.. js:attribute:: core.crit
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "critical" (2).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"critical" (2).
|
||||||
|
|
||||||
.. js:attribute:: core.err
|
.. js:attribute:: core.err
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "error" (3).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"error" (3).
|
||||||
|
|
||||||
.. js:attribute:: core.warning
|
.. js:attribute:: core.warning
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "warning" (4).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"warning" (4).
|
||||||
|
|
||||||
.. js:attribute:: core.notice
|
.. js:attribute:: core.notice
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "notice" (5).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"notice" (5).
|
||||||
|
|
||||||
.. js:attribute:: core.info
|
.. js:attribute:: core.info
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "info" (6).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"info" (6).
|
||||||
|
|
||||||
.. js:attribute:: core.debug
|
.. js:attribute:: core.debug
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
This attribute is an integer, it contains the value of the loglevel "debug" (7).
|
This attribute is an integer, it contains the value of the loglevel
|
||||||
|
"debug" (7).
|
||||||
|
|
||||||
.. js:attribute:: core.proxies
|
.. js:attribute:: core.proxies
|
||||||
|
|
||||||
@ -474,8 +482,8 @@ Core class
|
|||||||
|
|
||||||
:param string name: is the name of the converter.
|
:param string name: is the name of the converter.
|
||||||
:param table actions: is a table of string describing the HAProxy actions who
|
:param table actions: is a table of string describing the HAProxy actions who
|
||||||
want to register to. The expected actions are 'tcp-req',
|
want to register to. The expected actions are 'tcp-req', 'tcp-res', 'http-req'
|
||||||
'tcp-res', 'http-req' or 'http-res'.
|
or 'http-res'.
|
||||||
:param function func: is the Lua function called to work as converter.
|
:param function func: is the Lua function called to work as converter.
|
||||||
:param integer nb_args: is the expected number of argument for the action.
|
:param integer nb_args: is the expected number of argument for the action.
|
||||||
By default the value is 0.
|
By default the value is 0.
|
||||||
@ -582,8 +590,8 @@ Core class
|
|||||||
string function(txn, [p1 [, p2 [, ... [, p5]]]])
|
string function(txn, [p1 [, p2 [, ... [, p5]]]])
|
||||||
..
|
..
|
||||||
|
|
||||||
* **txn** (:ref:`txn_class`): this is the txn object associated with the current
|
* **txn** (:ref:`txn_class`): this is the txn object associated with the
|
||||||
request.
|
current request.
|
||||||
* **p1** .. **p5** (*string*): this is a list of string arguments declared in
|
* **p1** .. **p5** (*string*): this is a list of string arguments declared in
|
||||||
the HAProxy configuration file. The number of arguments doesn't exceed 5.
|
the HAProxy configuration file. The number of arguments doesn't exceed 5.
|
||||||
The order and the nature of these is conventionally chosen by the
|
The order and the nature of these is conventionally chosen by the
|
||||||
@ -659,9 +667,9 @@ Core class
|
|||||||
|
|
||||||
**context**: body
|
**context**: body
|
||||||
|
|
||||||
Register a Lua function executed as a service. All the registered services can
|
Register a Lua function executed as a service. All the registered services
|
||||||
be used in HAProxy with the prefix "lua.". A service gets an object class as
|
can be used in HAProxy with the prefix "lua.". A service gets an object class
|
||||||
input according with the required mode.
|
as input according with the required mode.
|
||||||
|
|
||||||
:param string name: is the name of the service.
|
:param string name: is the name of the service.
|
||||||
:param string mode: is string describing the required mode. Only 'tcp' or
|
:param string mode: is string describing the required mode. Only 'tcp' or
|
||||||
@ -687,8 +695,8 @@ Core class
|
|||||||
a HTTP applet from a proxy in tcp mode. Applets of type 'tcp' can be
|
a HTTP applet from a proxy in tcp mode. Applets of type 'tcp' can be
|
||||||
called from anywhere.
|
called from anywhere.
|
||||||
|
|
||||||
Here, an example of service registration. The service just send an 'Hello world'
|
Here, an example of service registration. The service just send an
|
||||||
as an http response.
|
'Hello world' as an http response.
|
||||||
|
|
||||||
.. code-block:: lua
|
.. code-block:: lua
|
||||||
|
|
||||||
@ -737,8 +745,8 @@ Core class
|
|||||||
|
|
||||||
:param function func: is the Lua function called to work as an async task.
|
:param function func: is the Lua function called to work as an async task.
|
||||||
|
|
||||||
Up to 4 optional arguments (all types supported) may be passed to the function.
|
Up to 4 optional arguments (all types supported) may be passed to the
|
||||||
(They will be passed as-is to the task function)
|
function. (They will be passed as-is to the task function)
|
||||||
|
|
||||||
The prototype of the Lua function used as argument is:
|
The prototype of the Lua function used as argument is:
|
||||||
|
|
||||||
@ -747,7 +755,8 @@ Core class
|
|||||||
function([arg1[, arg2[, ...[, arg4]]]])
|
function([arg1[, arg2[, ...[, arg4]]]])
|
||||||
..
|
..
|
||||||
|
|
||||||
It takes up to 4 optional arguments (provided when registering), and no output is expected.
|
It takes up to 4 optional arguments (provided when registering), and no
|
||||||
|
output is expected.
|
||||||
|
|
||||||
.. js:function:: core.register_cli([path], usage, func)
|
.. js:function:: core.register_cli([path], usage, func)
|
||||||
|
|
||||||
@ -785,7 +794,8 @@ Core class
|
|||||||
> show ssl stats all
|
> show ssl stats all
|
||||||
..
|
..
|
||||||
|
|
||||||
Then, arg1, arg2 and arg3 will contains respectively "show", "ssl" and "stats".
|
Then, arg1, arg2 and arg3 will contains respectively "show", "ssl" and
|
||||||
|
"stats".
|
||||||
arg4 will contain "all". arg5 contains nil.
|
arg4 will contain "all". arg5 contains nil.
|
||||||
|
|
||||||
.. js:function:: core.set_nice(nice)
|
.. js:function:: core.set_nice(nice)
|
||||||
@ -878,8 +888,8 @@ Core class
|
|||||||
:returns: boolean, true if the network of the addresses match, else returns
|
:returns: boolean, true if the network of the addresses match, else returns
|
||||||
false.
|
false.
|
||||||
|
|
||||||
Match two networks. For example "127.0.0.1/32" matches "127.0.0.0/8". The order
|
Match two networks. For example "127.0.0.1/32" matches "127.0.0.0/8". The
|
||||||
of network is not important.
|
order of network is not important.
|
||||||
|
|
||||||
.. js:function:: core.tokenize(str, separators [, noblank])
|
.. js:function:: core.tokenize(str, separators [, noblank])
|
||||||
|
|
||||||
@ -921,8 +931,10 @@ Core class
|
|||||||
|
|
||||||
Register a function that will be called on specific system events.
|
Register a function that will be called on specific system events.
|
||||||
|
|
||||||
:param array event_types: array of string containing the event types you want to subscribe to
|
:param array event_types: array of string containing the event types you want
|
||||||
:param function func: is the Lua function called when one of the subscribed events occur.
|
to subscribe to
|
||||||
|
:param function func: is the Lua function called when one of the subscribed
|
||||||
|
events occur.
|
||||||
:returns: A :ref:`event_sub_class` object.
|
:returns: A :ref:`event_sub_class` object.
|
||||||
:see: :js:func:`Server.event_sub()`.
|
:see: :js:func:`Server.event_sub()`.
|
||||||
|
|
||||||
@ -936,7 +948,8 @@ Core class
|
|||||||
* **SERVER_UP**: when a server state goes from DOWN to UP
|
* **SERVER_UP**: when a server state goes from DOWN to UP
|
||||||
|
|
||||||
.. Note::
|
.. Note::
|
||||||
You may also use **SERVER** in **event_types** to subscribe to all server events types at once.
|
You may also use **SERVER** in **event_types** to subscribe to all server
|
||||||
|
events types at once.
|
||||||
|
|
||||||
The prototype of the Lua function used as argument is:
|
The prototype of the Lua function used as argument is:
|
||||||
|
|
||||||
@ -945,9 +958,12 @@ Core class
|
|||||||
function(event, event_data, sub, when)
|
function(event, event_data, sub, when)
|
||||||
..
|
..
|
||||||
|
|
||||||
* **event** (*string*): the event type (one of the **event_types** you specified when subscribing)
|
* **event** (*string*): the event type (one of the **event_types** specified
|
||||||
* **event_data**: specific to each event family (For **SERVER** family, a :ref:`server_event_class` object)
|
when subscribing)
|
||||||
* **sub**: class to manage the subscription from within the event (a :ref:`event_sub_class` object)
|
* **event_data**: specific to each event family (For **SERVER** family,
|
||||||
|
a :ref:`server_event_class` object)
|
||||||
|
* **sub**: class to manage the subscription from within the event
|
||||||
|
(a :ref:`event_sub_class` object)
|
||||||
* **when**: timestamp corresponding to the date when the event was generated.
|
* **when**: timestamp corresponding to the date when the event was generated.
|
||||||
It is an integer representing the number of seconds elapsed since Epoch.
|
It is an integer representing the number of seconds elapsed since Epoch.
|
||||||
It may be provided as optional argument to `os.date()` lua function to
|
It may be provided as optional argument to `os.date()` lua function to
|
||||||
@ -957,32 +973,34 @@ Core class
|
|||||||
The callback function will only be scheduled on the very same thread that
|
The callback function will only be scheduled on the very same thread that
|
||||||
performed the subscription.
|
performed the subscription.
|
||||||
|
|
||||||
Moreover, each thread treats events sequentially. It means that if you have,
|
Moreover, each thread treats events sequentially. It means that if you
|
||||||
let's say SERVER_UP followed by a SERVER_DOWN in a short timelapse, then
|
have, let's say SERVER_UP followed by a SERVER_DOWN in a short timelapse,
|
||||||
the cb function will first be called with SERVER_UP, and once it's done
|
then the cb function will first be called with SERVER_UP, and once it's
|
||||||
handling the event, the cb function will be called again with SERVER_DOWN.
|
done handling the event, the cb function will be called again with
|
||||||
|
SERVER_DOWN.
|
||||||
|
|
||||||
This is to ensure event consistency when it comes to logging / triggering logic
|
This is to ensure event consistency when it comes to logging / triggering
|
||||||
from lua.
|
logic from lua.
|
||||||
|
|
||||||
Your lua cb function may yield if needed, but you're pleased to process the
|
Your lua cb function may yield if needed, but you're pleased to process the
|
||||||
event as fast as possible to prevent the event queue from growing up, depending
|
event as fast as possible to prevent the event queue from growing up,
|
||||||
on the event flow that is expected for the given subscription.
|
depending on the event flow that is expected for the given subscription.
|
||||||
|
|
||||||
To prevent abuses, if the event queue for the current subscription goes over
|
To prevent abuses, if the event queue for the current subscription goes
|
||||||
a certain amount of unconsumed events, the subscription will pause itself
|
over a certain amount of unconsumed events, the subscription will pause
|
||||||
automatically for as long as it takes for your handler to catch up. This would
|
itself automatically for as long as it takes for your handler to catch up.
|
||||||
lead to events being missed, so an error will be reported in the logs to warn
|
This would lead to events being missed, so an error will be reported in the
|
||||||
you about that.
|
logs to warn you about that.
|
||||||
This is not something you want to let happen too often, it may indicate that
|
This is not something you want to let happen too often, it may indicate
|
||||||
you subscribed to an event that is occurring too frequently or/and that your
|
that you subscribed to an event that is occurring too frequently or/and
|
||||||
callback function is too slow to keep up the pace and you should review it.
|
that your callback function is too slow to keep up the pace and you should
|
||||||
|
review it.
|
||||||
|
|
||||||
If you want to do some parallel processing because your callback functions are
|
If you want to do some parallel processing because your callback functions
|
||||||
slow: you might want to create subtasks from lua using
|
are slow: you might want to create subtasks from lua using
|
||||||
:js:func:`core.register_task()` from within your callback function to perform
|
:js:func:`core.register_task()` from within your callback function to
|
||||||
the heavy job in a dedicated task and allow remaining events to be processed
|
perform the heavy job in a dedicated task and allow remaining events to be
|
||||||
more quickly.
|
processed more quickly.
|
||||||
|
|
||||||
.. _proxy_class:
|
.. _proxy_class:
|
||||||
|
|
||||||
@ -1419,7 +1437,8 @@ ServerEvent class
|
|||||||
|
|
||||||
.. Warning::
|
.. Warning::
|
||||||
Not available if the server was removed in the meantime.
|
Not available if the server was removed in the meantime.
|
||||||
(Will never be set for SERVER_DEL event since the server does not exist anymore)
|
(Will never be set for SERVER_DEL event since the server does not exist
|
||||||
|
anymore)
|
||||||
|
|
||||||
.. _concat_class:
|
.. _concat_class:
|
||||||
|
|
||||||
@ -1624,11 +1643,10 @@ Channel class
|
|||||||
|
|
||||||
:param class_channel channel: The manipulated Channel.
|
:param class_channel channel: The manipulated Channel.
|
||||||
:param integer offset: *optional* The offset in incoming data to start to get
|
:param integer offset: *optional* The offset in incoming data to start to get
|
||||||
data. 0 by default. May be negative to be relative to
|
data. 0 by default. May be negative to be relative to the end of incoming
|
||||||
the end of incoming data.
|
data.
|
||||||
:param integer length: *optional* The expected length of data to retrieve. All
|
:param integer length: *optional* The expected length of data to retrieve. All
|
||||||
incoming data by default. May be set to -1 to get a
|
incoming data by default. May be set to -1 to get a maximum of data.
|
||||||
maximum of data.
|
|
||||||
:returns: a string containing the data found or nil.
|
:returns: a string containing the data found or nil.
|
||||||
|
|
||||||
.. js:function:: Channel.forward(channel, length)
|
.. js:function:: Channel.forward(channel, length)
|
||||||
@ -1662,8 +1680,8 @@ Channel class
|
|||||||
:param class_channel channel: The manipulated Channel.
|
:param class_channel channel: The manipulated Channel.
|
||||||
:param string string: The data to copy into incoming data.
|
:param string string: The data to copy into incoming data.
|
||||||
:param integer offset: *optional* The offset in incoming data where to copy
|
:param integer offset: *optional* The offset in incoming data where to copy
|
||||||
data. 0 by default. May be negative to be relative to
|
data. 0 by default. May be negative to be relative to the end of incoming
|
||||||
the end of incoming data.
|
data.
|
||||||
:returns: an integer containing the amount of bytes copied or -1.
|
:returns: an integer containing the amount of bytes copied or -1.
|
||||||
|
|
||||||
.. js:function:: Channel.is_full(channel)
|
.. js:function:: Channel.is_full(channel)
|
||||||
@ -1684,8 +1702,8 @@ Channel class
|
|||||||
|
|
||||||
This function parses **length** bytes of incoming data of the channel buffer,
|
This function parses **length** bytes of incoming data of the channel buffer,
|
||||||
starting at offset **offset**, and returns the first line found, including the
|
starting at offset **offset**, and returns the first line found, including the
|
||||||
'\\n'. The data are not removed from the buffer. If no line is found, all data
|
'\\n'. The data are not removed from the buffer. If no line is found, all
|
||||||
are returned.
|
data are returned.
|
||||||
|
|
||||||
By default, if no length is provided, all incoming data, starting at the given
|
By default, if no length is provided, all incoming data, starting at the given
|
||||||
offset, are evaluated. If **length** is set to -1, the function tries to
|
offset, are evaluated. If **length** is set to -1, the function tries to
|
||||||
@ -1700,11 +1718,10 @@ Channel class
|
|||||||
|
|
||||||
:param class_channel channel: The manipulated Channel.
|
:param class_channel channel: The manipulated Channel.
|
||||||
:param integer offset: *optional* The offset in incoming data to start to
|
:param integer offset: *optional* The offset in incoming data to start to
|
||||||
parse data. 0 by default. May be negative to be
|
parse data. 0 by default. May be negative to be relative to the end of
|
||||||
relative to the end of incoming data.
|
incoming data.
|
||||||
:param integer length: *optional* The length of data to parse. All incoming
|
:param integer length: *optional* The length of data to parse. All incoming
|
||||||
data by default. May be set to -1 to get a maximum of
|
data by default. May be set to -1 to get a maximum of data.
|
||||||
data.
|
|
||||||
:returns: a string containing the line found or nil.
|
:returns: a string containing the line found or nil.
|
||||||
|
|
||||||
.. js:function:: Channel.may_recv(channel)
|
.. js:function:: Channel.may_recv(channel)
|
||||||
@ -1747,8 +1764,8 @@ Channel class
|
|||||||
|
|
||||||
:param class_channel channel: The manipulated Channel.
|
:param class_channel channel: The manipulated Channel.
|
||||||
:param integer offset: *optional* The offset in incoming data where to start
|
:param integer offset: *optional* The offset in incoming data where to start
|
||||||
to remove data. 0 by default. May be negative to
|
to remove data. 0 by default. May be negative to be relative to the end of
|
||||||
be relative to the end of incoming data.
|
incoming data.
|
||||||
:param integer length: *optional* The length of data to remove. All incoming
|
:param integer length: *optional* The length of data to remove. All incoming
|
||||||
data by default.
|
data by default.
|
||||||
:returns: an integer containing the amount of bytes removed.
|
:returns: an integer containing the amount of bytes removed.
|
||||||
@ -1766,9 +1783,9 @@ Channel class
|
|||||||
|
|
||||||
.. js:function:: Channel.set(channel, string [, offset [, length]])
|
.. js:function:: Channel.set(channel, string [, offset [, length]])
|
||||||
|
|
||||||
This function replaces **length** bytes of incoming data of the channel buffer,
|
This function replaces **length** bytes of incoming data of the channel
|
||||||
starting at offset **offset**, by the string **string**. The function returns
|
buffer, starting at offset **offset**, by the string **string**. The function
|
||||||
the copied length on success or -1 if data cannot be copied.
|
returns the copied length on success or -1 if data cannot be copied.
|
||||||
|
|
||||||
By default, if no length is provided, all incoming data, starting at the given
|
By default, if no length is provided, all incoming data, starting at the given
|
||||||
offset, are replaced. Not providing an offset is the same as setting it
|
offset, are replaced. Not providing an offset is the same as setting it
|
||||||
@ -1778,8 +1795,8 @@ Channel class
|
|||||||
:param class_channel channel: The manipulated Channel.
|
:param class_channel channel: The manipulated Channel.
|
||||||
:param string string: The data to copy into incoming data.
|
:param string string: The data to copy into incoming data.
|
||||||
:param integer offset: *optional* The offset in incoming data where to start
|
:param integer offset: *optional* The offset in incoming data where to start
|
||||||
the data replacement. 0 by default. May be negative to
|
the data replacement. 0 by default. May be negative to be relative to the
|
||||||
be relative to the end of incoming data.
|
end of incoming data.
|
||||||
:param integer length: *optional* The length of data to replace. All incoming
|
:param integer length: *optional* The length of data to replace. All incoming
|
||||||
data by default.
|
data by default.
|
||||||
:returns: an integer containing the amount of bytes copied or -1.
|
:returns: an integer containing the amount of bytes copied or -1.
|
||||||
@ -2082,20 +2099,28 @@ HTTPClient class
|
|||||||
.. js:function:: HTTPClient.post(httpclient, request)
|
.. js:function:: HTTPClient.post(httpclient, request)
|
||||||
.. js:function:: HTTPClient.delete(httpclient, request)
|
.. js:function:: HTTPClient.delete(httpclient, request)
|
||||||
|
|
||||||
Send a HTTP request and wait for a response. GET, HEAD PUT, POST and DELETE methods can be used.
|
Send a HTTP request and wait for a response. GET, HEAD PUT, POST and DELETE
|
||||||
The HTTPClient will send asynchronously the data and is able to send and receive more than HAProxy bufsize.
|
methods can be used.
|
||||||
|
The HTTPClient will send asynchronously the data and is able to send and
|
||||||
|
receive more than HAProxy bufsize.
|
||||||
|
|
||||||
The HTTPClient interface is not able to decompress responses, it is not
|
The HTTPClient interface is not able to decompress responses, it is not
|
||||||
recommended to send an Accept-Encoding in the request so the response is
|
recommended to send an Accept-Encoding in the request so the response is
|
||||||
received uncompressed.
|
received uncompressed.
|
||||||
|
|
||||||
:param class httpclient: Is the manipulated HTTPClient.
|
:param class httpclient: Is the manipulated HTTPClient.
|
||||||
:param table request: Is a table containing the parameters of the request that will be send.
|
:param table request: Is a table containing the parameters of the request
|
||||||
:param string request.url: Is a mandatory parameter for the request that contains the URL.
|
that will be send.
|
||||||
:param string request.body: Is an optional parameter for the request that contains the body to send.
|
:param string request.url: Is a mandatory parameter for the request that
|
||||||
:param table request.headers: Is an optional parameter for the request that contains the headers to send.
|
contains the URL.
|
||||||
:param string request.dst: Is an optional parameter for the destination in haproxy address format.
|
:param string request.body: Is an optional parameter for the request that
|
||||||
:param integer request.timeout: Optional timeout parameter, set a "timeout server" on the connections.
|
contains the body to send.
|
||||||
|
:param table request.headers: Is an optional parameter for the request that
|
||||||
|
contains the headers to send.
|
||||||
|
:param string request.dst: Is an optional parameter for the destination in
|
||||||
|
haproxy address format.
|
||||||
|
:param integer request.timeout: Optional timeout parameter, set a
|
||||||
|
"timeout server" on the connections.
|
||||||
:returns: Lua table containing the response
|
:returns: Lua table containing the response
|
||||||
|
|
||||||
|
|
||||||
@ -2205,8 +2230,8 @@ TXN class
|
|||||||
the stderr if it is allowed.
|
the stderr if it is allowed.
|
||||||
|
|
||||||
:param class_txn txn: The class txn object containing the data.
|
:param class_txn txn: The class txn object containing the data.
|
||||||
:param integer loglevel: Is the log level associated with the message. It is a
|
:param integer loglevel: Is the log level associated with the message. It is
|
||||||
number between 0 and 7.
|
a number between 0 and 7.
|
||||||
:param string msg: The log content.
|
:param string msg: The log content.
|
||||||
:see: :js:attr:`core.emerg`, :js:attr:`core.alert`, :js:attr:`core.crit`,
|
:see: :js:attr:`core.emerg`, :js:attr:`core.alert`, :js:attr:`core.crit`,
|
||||||
:js:attr:`core.err`, :js:attr:`core.warning`, :js:attr:`core.notice`,
|
:js:attr:`core.err`, :js:attr:`core.warning`, :js:attr:`core.notice`,
|
||||||
@ -2308,28 +2333,30 @@ TXN class
|
|||||||
Converts a Lua type in a HAProxy type and store it in a variable <var>.
|
Converts a Lua type in a HAProxy type and store it in a variable <var>.
|
||||||
|
|
||||||
:param class_txn txn: The class txn object containing the data.
|
:param class_txn txn: The class txn object containing the data.
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
:param type value: The value associated to the variable. The type can be string or
|
syntax.
|
||||||
integer.
|
:param type value: The value associated to the variable. The type can be
|
||||||
:param boolean ifexist: If this parameter is set to true the variable
|
string or integer.
|
||||||
will only be set if it was defined elsewhere (i.e. used
|
:param boolean ifexist: If this parameter is set to true the variable will
|
||||||
within the configuration). For global variables (using the
|
only be set if it was defined elsewhere (i.e. used within the configuration).
|
||||||
"proc" scope), they will only be updated and never created.
|
For global variables (using the "proc" scope), they will only be updated and
|
||||||
It is highly recommended to always set this to true.
|
never created. It is highly recommended to always set this to true.
|
||||||
|
|
||||||
.. js:function:: TXN.unset_var(TXN, var)
|
.. js:function:: TXN.unset_var(TXN, var)
|
||||||
|
|
||||||
Unset the variable <var>.
|
Unset the variable <var>.
|
||||||
|
|
||||||
:param class_txn txn: The class txn object containing the data.
|
:param class_txn txn: The class txn object containing the data.
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
|
syntax.
|
||||||
|
|
||||||
.. js:function:: TXN.get_var(TXN, var)
|
.. js:function:: TXN.get_var(TXN, var)
|
||||||
|
|
||||||
Returns data stored in the variable <var> converter in Lua type.
|
Returns data stored in the variable <var> converter in Lua type.
|
||||||
|
|
||||||
:param class_txn txn: The class txn object containing the data.
|
:param class_txn txn: The class txn object containing the data.
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
|
syntax.
|
||||||
|
|
||||||
.. js:function:: TXN.reply([reply])
|
.. js:function:: TXN.reply([reply])
|
||||||
|
|
||||||
@ -2409,8 +2436,8 @@ TXN class
|
|||||||
..
|
..
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
It does not make sense to call this function from sample-fetches. In this case
|
It does not make sense to call this function from sample-fetches. In this
|
||||||
the behavior is the same than core.done(): it finishes the Lua
|
case the behavior is the same than core.done(): it finishes the Lua
|
||||||
execution. The transaction is really aborted only from an action registered
|
execution. The transaction is really aborted only from an action registered
|
||||||
function.
|
function.
|
||||||
|
|
||||||
@ -2775,7 +2802,8 @@ Regex class
|
|||||||
:param string regex: The regular expression according with the libc or pcre
|
:param string regex: The regular expression according with the libc or pcre
|
||||||
standard
|
standard
|
||||||
:param boolean case_sensitive: Match is case sensitive or not.
|
:param boolean case_sensitive: Match is case sensitive or not.
|
||||||
:returns: boolean status and :ref:`regex_class` or string containing fail reason.
|
:returns: boolean status and :ref:`regex_class` or string containing fail
|
||||||
|
reason.
|
||||||
|
|
||||||
.. js:function:: Regex.exec(regex, str)
|
.. js:function:: Regex.exec(regex, str)
|
||||||
|
|
||||||
@ -3057,8 +3085,8 @@ AppletHTTP class
|
|||||||
|
|
||||||
This function adds a header in the response. Duplicated headers are not
|
This function adds a header in the response. Duplicated headers are not
|
||||||
collapsed. The special header *content-length* is used to determinate the
|
collapsed. The special header *content-length* is used to determinate the
|
||||||
response length. If it does not exist, a *transfer-encoding: chunked* is set, and
|
response length. If it does not exist, a *transfer-encoding: chunked* is set,
|
||||||
all the write from the function *AppletHTTP:send()* become a chunk.
|
and all the write from the function *AppletHTTP:send()* become a chunk.
|
||||||
|
|
||||||
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
||||||
:param string name: the header name
|
:param string name: the header name
|
||||||
@ -3125,14 +3153,14 @@ AppletHTTP class
|
|||||||
Converts a Lua type in a HAProxy type and store it in a variable <var>.
|
Converts a Lua type in a HAProxy type and store it in a variable <var>.
|
||||||
|
|
||||||
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
:param type value: The value associated to the variable. The type ca be string or
|
syntax.
|
||||||
integer.
|
:param type value: The value associated to the variable. The type ca be string
|
||||||
:param boolean ifexist: If this parameter is set to true the variable
|
or integer.
|
||||||
will only be set if it was defined elsewhere (i.e. used
|
:param boolean ifexist: If this parameter is set to true the variable will
|
||||||
within the configuration). For global variables (using the
|
only be set if it was defined elsewhere (i.e. used within the configuration).
|
||||||
"proc" scope), they will only be updated and never created.
|
For global variables (using the "proc" scope), they will only be updated and
|
||||||
It is highly recommended to always set this to true.
|
never created. It is highly recommended to always set this to true.
|
||||||
|
|
||||||
:see: :js:func:`AppletHTTP.unset_var`
|
:see: :js:func:`AppletHTTP.unset_var`
|
||||||
:see: :js:func:`AppletHTTP.get_var`
|
:see: :js:func:`AppletHTTP.get_var`
|
||||||
@ -3142,7 +3170,8 @@ AppletHTTP class
|
|||||||
Unset the variable <var>.
|
Unset the variable <var>.
|
||||||
|
|
||||||
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
|
syntax.
|
||||||
:see: :js:func:`AppletHTTP.set_var`
|
:see: :js:func:`AppletHTTP.set_var`
|
||||||
:see: :js:func:`AppletHTTP.get_var`
|
:see: :js:func:`AppletHTTP.get_var`
|
||||||
|
|
||||||
@ -3151,7 +3180,8 @@ AppletHTTP class
|
|||||||
Returns data stored in the variable <var> converter in Lua type.
|
Returns data stored in the variable <var> converter in Lua type.
|
||||||
|
|
||||||
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
:param class_AppletHTTP applet: An :ref:`applethttp_class`
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
|
syntax.
|
||||||
:see: :js:func:`AppletHTTP.set_var`
|
:see: :js:func:`AppletHTTP.set_var`
|
||||||
:see: :js:func:`AppletHTTP.unset_var`
|
:see: :js:func:`AppletHTTP.unset_var`
|
||||||
|
|
||||||
@ -3242,14 +3272,14 @@ AppletTCP class
|
|||||||
Converts a Lua type in a HAProxy type and stores it in a variable <var>.
|
Converts a Lua type in a HAProxy type and stores it in a variable <var>.
|
||||||
|
|
||||||
:param class_AppletTCP applet: An :ref:`applettcp_class`
|
:param class_AppletTCP applet: An :ref:`applettcp_class`
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
:param type value: The value associated to the variable. The type can be string or
|
syntax.
|
||||||
integer.
|
:param type value: The value associated to the variable. The type can be
|
||||||
:param boolean ifexist: If this parameter is set to true the variable
|
string or integer.
|
||||||
will only be set if it was defined elsewhere (i.e. used
|
:param boolean ifexist: If this parameter is set to true the variable will
|
||||||
within the configuration). For global variables (using the
|
only be set if it was defined elsewhere (i.e. used within the configuration).
|
||||||
"proc" scope), they will only be updated and never created.
|
For global variables (using the "proc" scope), they will only be updated and
|
||||||
It is highly recommended to always set this to true.
|
never created. It is highly recommended to always set this to true.
|
||||||
|
|
||||||
:see: :js:func:`AppletTCP.unset_var`
|
:see: :js:func:`AppletTCP.unset_var`
|
||||||
:see: :js:func:`AppletTCP.get_var`
|
:see: :js:func:`AppletTCP.get_var`
|
||||||
@ -3259,7 +3289,8 @@ AppletTCP class
|
|||||||
Unsets the variable <var>.
|
Unsets the variable <var>.
|
||||||
|
|
||||||
:param class_AppletTCP applet: An :ref:`applettcp_class`
|
:param class_AppletTCP applet: An :ref:`applettcp_class`
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
|
syntax.
|
||||||
:see: :js:func:`AppletTCP.unset_var`
|
:see: :js:func:`AppletTCP.unset_var`
|
||||||
:see: :js:func:`AppletTCP.set_var`
|
:see: :js:func:`AppletTCP.set_var`
|
||||||
|
|
||||||
@ -3268,7 +3299,8 @@ AppletTCP class
|
|||||||
Returns data stored in the variable <var> converter in Lua type.
|
Returns data stored in the variable <var> converter in Lua type.
|
||||||
|
|
||||||
:param class_AppletTCP applet: An :ref:`applettcp_class`
|
:param class_AppletTCP applet: An :ref:`applettcp_class`
|
||||||
:param string var: The variable name according with the HAProxy variable syntax.
|
:param string var: The variable name according with the HAProxy variable
|
||||||
|
syntax.
|
||||||
:see: :js:func:`AppletTCP.unset_var`
|
:see: :js:func:`AppletTCP.unset_var`
|
||||||
:see: :js:func:`AppletTCP.set_var`
|
:see: :js:func:`AppletTCP.set_var`
|
||||||
|
|
||||||
@ -3360,9 +3392,9 @@ Action class
|
|||||||
..
|
..
|
||||||
.. js:attribute:: act.CONTINUE
|
.. js:attribute:: act.CONTINUE
|
||||||
|
|
||||||
This attribute is an integer (0). It instructs HAProxy to continue the current
|
This attribute is an integer (0). It instructs HAProxy to continue the
|
||||||
ruleset processing on the message. It is the default return code for a lua
|
current ruleset processing on the message. It is the default return code
|
||||||
action.
|
for a lua action.
|
||||||
|
|
||||||
:returns: integer
|
:returns: integer
|
||||||
|
|
||||||
@ -3508,7 +3540,8 @@ attributes:
|
|||||||
* id: The filter identifier. It is a string that identifies the filter and is
|
* id: The filter identifier. It is a string that identifies the filter and is
|
||||||
optional.
|
optional.
|
||||||
|
|
||||||
* flags: The filter flags. Only :js:attr:`filter.FLT_CFG_FL_HTX` may be set for now.
|
* flags: The filter flags. Only :js:attr:`filter.FLT_CFG_FL_HTX` may be set
|
||||||
|
for now.
|
||||||
|
|
||||||
Such filter class must also define all required callback functions in the
|
Such filter class must also define all required callback functions in the
|
||||||
following list. Note that :js:func:`Filter.new()` must be defined otherwise the
|
following list. Note that :js:func:`Filter.new()` must be defined otherwise the
|
||||||
@ -3662,16 +3695,15 @@ HTTPMessage class
|
|||||||
positive offset is relative to the beginning of incoming data of the
|
positive offset is relative to the beginning of incoming data of the
|
||||||
http_message buffer while negative offset is relative to their end.
|
http_message buffer while negative offset is relative to their end.
|
||||||
|
|
||||||
If there is no incoming data and the HTTP message can't receive more data, a 'nil'
|
If there is no incoming data and the HTTP message can't receive more data,
|
||||||
value is returned.
|
a 'nil' value is returned.
|
||||||
|
|
||||||
:param class_httpmessage http_msg: The manipulated HTTP message.
|
:param class_httpmessage http_msg: The manipulated HTTP message.
|
||||||
:param integer offset: *optional* The offset in incoming data to start to get
|
:param integer offset: *optional* The offset in incoming data to start to get
|
||||||
data. 0 by default. May be negative to be relative to
|
data. 0 by default. May be negative to be relative to the end of incoming
|
||||||
the end of incoming data.
|
data.
|
||||||
:param integer length: *optional* The expected length of data to retrieve. All
|
:param integer length: *optional* The expected length of data to retrieve.
|
||||||
incoming data by default. May be set to -1 to get a
|
All incoming data by default. May be set to -1 to get a maximum of data.
|
||||||
maximum of data.
|
|
||||||
:returns: a string containing the data found or nil.
|
:returns: a string containing the data found or nil.
|
||||||
|
|
||||||
.. js:function:: HTTPMessage.eom(http_msg)
|
.. js:function:: HTTPMessage.eom(http_msg)
|
||||||
@ -3760,8 +3792,8 @@ HTTPMessage class
|
|||||||
:param class_httpmessage http_msg: The manipulated HTTP message.
|
:param class_httpmessage http_msg: The manipulated HTTP message.
|
||||||
:param string string: The data to copy into incoming data.
|
:param string string: The data to copy into incoming data.
|
||||||
:param integer offset: *optional* The offset in incoming data where to copy
|
:param integer offset: *optional* The offset in incoming data where to copy
|
||||||
data. 0 by default. May be negative to be relative to
|
data. 0 by default. May be negative to be relative to the end of incoming
|
||||||
the end of incoming data.
|
data.
|
||||||
:returns: an integer containing the amount of bytes copied or -1.
|
:returns: an integer containing the amount of bytes copied or -1.
|
||||||
|
|
||||||
.. js:function:: HTTPMessage.is_full(http_msg)
|
.. js:function:: HTTPMessage.is_full(http_msg)
|
||||||
@ -3820,8 +3852,8 @@ HTTPMessage class
|
|||||||
|
|
||||||
:param class_httpmessage http_msg: The manipulated HTTP message.
|
:param class_httpmessage http_msg: The manipulated HTTP message.
|
||||||
:param integer offset: *optional* The offset in incoming data where to start
|
:param integer offset: *optional* The offset in incoming data where to start
|
||||||
to remove data. 0 by default. May be negative to
|
to remove data. 0 by default. May be negative to be relative to the end of
|
||||||
be relative to the end of incoming data.
|
incoming data.
|
||||||
:param integer length: *optional* The length of data to remove. All incoming
|
:param integer length: *optional* The length of data to remove. All incoming
|
||||||
data by default.
|
data by default.
|
||||||
:returns: an integer containing the amount of bytes removed.
|
:returns: an integer containing the amount of bytes removed.
|
||||||
@ -3876,8 +3908,8 @@ HTTPMessage class
|
|||||||
:param class_httpmessage http_msg: The manipulated HTTP message.
|
:param class_httpmessage http_msg: The manipulated HTTP message.
|
||||||
:param string string: The data to copy into incoming data.
|
:param string string: The data to copy into incoming data.
|
||||||
:param integer offset: *optional* The offset in incoming data where to start
|
:param integer offset: *optional* The offset in incoming data where to start
|
||||||
the data replacement. 0 by default. May be negative to
|
the data replacement. 0 by default. May be negative to be relative to the
|
||||||
be relative to the end of incoming data.
|
end of incoming data.
|
||||||
:param integer length: *optional* The length of data to replace. All incoming
|
:param integer length: *optional* The length of data to replace. All incoming
|
||||||
data by default.
|
data by default.
|
||||||
:returns: an integer containing the amount of bytes copied or -1.
|
:returns: an integer containing the amount of bytes copied or -1.
|
||||||
@ -3989,16 +4021,19 @@ External Lua libraries
|
|||||||
|
|
||||||
A lot of useful lua libraries can be found here:
|
A lot of useful lua libraries can be found here:
|
||||||
|
|
||||||
* Lua toolbox has been superseded by `https://luarocks.org/ <https://luarocks.org/>`_
|
* Lua toolbox has been superseded by
|
||||||
The old lua toolbox source code is still available here `https://github.com/catwell/lua-toolbox <https://github.com/catwell/lua-toolbox>`_ (DEPRECATED)
|
`https://luarocks.org/ <https://luarocks.org/>`_
|
||||||
|
|
||||||
|
The old lua toolbox source code is still available here
|
||||||
|
`https://github.com/catwell/lua-toolbox <https://github.com/catwell/lua-toolbox>`_ (DEPRECATED)
|
||||||
|
|
||||||
Redis client library:
|
Redis client library:
|
||||||
|
|
||||||
* `https://github.com/nrk/redis-lua <https://github.com/nrk/redis-lua>`_
|
* `https://github.com/nrk/redis-lua <https://github.com/nrk/redis-lua>`_
|
||||||
|
|
||||||
This is an example about the usage of the Redis library within HAProxy. Note that
|
This is an example about the usage of the Redis library within HAProxy.
|
||||||
each call to any function of this library can throw an error if the socket
|
Note that each call to any function of this library can throw an error if
|
||||||
connection fails.
|
the socket connection fails.
|
||||||
|
|
||||||
.. code-block:: lua
|
.. code-block:: lua
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user