Welcome! Log In Create A New Profile

Advanced

[Lua] Using txn.c:<converter>

Posted by Baptiste 
Baptiste
[Lua] Using txn.c:<converter>
May 08, 2018 08:30PM
Hi All, Thierry,

I'm trying to use the converter 'table_http_req_cnt()' from a Lua script,
but I'm not successful and so I wonder how I'm supposed to use the
converter class (txn.c:<converter>)...

The documentation misses an example:
https://www.arpalert.org/src/haproxy-lua-api/1.8/index.html#converters-class

Like for the fetches class:
https://www.arpalert.org/src/haproxy-lua-api/1.8/index.html#fetches-class

Any help would be appreciated. (HAProxy 1.8, HTTP action context, where I
want to pass a string to the converter table_http_req_cnt to read some data
from my table).

Baptiste
Baptiste
Re: [Lua] Using txn.c:<converter>
May 08, 2018 09:30PM
On Tue, May 8, 2018 at 8:17 PM, Baptiste <[email protected]> wrote:

> Hi All, Thierry,
>
> I'm trying to use the converter 'table_http_req_cnt()' from a Lua script,
> but I'm not successful and so I wonder how I'm supposed to use the
> converter class (txn.c:<converter>)...
>
> The documentation misses an example:
> https://www.arpalert.org/src/haproxy-lua-api/1.8/index.
> html#converters-class
>
> Like for the fetches class:
> https://www.arpalert.org/src/haproxy-lua-api/1.8/index.html#fetches-class
>
> Any help would be appreciated. (HAProxy 1.8, HTTP action context, where I
> want to pass a string to the converter table_http_req_cnt to read some
> data from my table).
>
> Baptiste
>


Replying to myself with the solution: the sample must be set as the first
argument when calling the converter.
IE: local myvar = txn.c:table_http_req_cnt(<sample>,<table name>)

Hope this helps.

Baptiste
Anonymous User
Re: [Lua] Using txn.c:<converter>
May 09, 2018 04:00PM
On Tue, 8 May 2018 21:26:49 +0200
Baptiste <[email protected]> wrote:

> On Tue, May 8, 2018 at 8:17 PM, Baptiste <[email protected]> wrote:
>
> > Hi All, Thierry,
> >
> > I'm trying to use the converter 'table_http_req_cnt()' from a Lua script,
> > but I'm not successful and so I wonder how I'm supposed to use the
> > converter class (txn.c:<converter>)...
> >
> > The documentation misses an example:
> > https://www.arpalert.org/src/haproxy-lua-api/1.8/index.
> > html#converters-class
> >
> > Like for the fetches class:
> > https://www.arpalert.org/src/haproxy-lua-api/1.8/index.html#fetches-class
> >
> > Any help would be appreciated. (HAProxy 1.8, HTTP action context, where I
> > want to pass a string to the converter table_http_req_cnt to read some
> > data from my table).
> >
> > Baptiste
> >
>
>
> Replying to myself with the solution: the sample must be set as the first
> argument when calling the converter.
> IE: local myvar = txn.c:table_http_req_cnt(<sample>,<table name>)
>
> Hope this helps.


Hi Baptiste,

Lua converters functions are automatically generated from registered
haproxy converters, So converters can't have specific documentation.
The only one rules are:

- The first argument is the input data.
- Next arguments are the arguments described in classic HAProxy doc.

So, the following HAProxy configuration example:

str(test),conv(33)

I written like this in Lua:

txn.c:conv("test", 33)

If you have some useful example, do not hesitate to improve the
documentation.

BR,
Thierry
Sorry, only registered users may post in this forum.

Click here to login