Hi Cédric,

On Fri, Nov 01, 2019 at 10:23:14AM -0400, PR Bot wrote:
>    Hello HAProxy team!
>    While working on a use-case we have at hand, we ended up desperately
>    needing the ability to set GPT0 from a dynamic value. This patch is
>    mostly copy-paste from the `set-var()` action.

I think your proposal totally makes sense. It would be nice to
mention in the doc that gpt0 is only 32-bit wide.

I'm having one small doubt about this part:

+       /* Check the sample data type. */
+       if (smp.data.type != SMP_T_SINT) {
+               send_log(px, LOG_WARNING, "stick table: invalid data type while 
fetching expression.");
+               if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
+                       ha_alert("stick table: invalid data type while fetching 
expression.\n");
+               return 0;
+       }

Usually we don't error on type issues, instead we try to cast the
result as best as we can. This is particularly important with HTTP
processing since most of the contents are text-based, thus you could
extract a numeric field from a query string argument, which would be
returned as a string, and expect it to be automatically converted
instead of returning an error. Please have a look at the end of
sample_fetch_as_type() to see how to proceed.

Personally I think that we would benefit from a variant of sample_expr()
which would take an output type and would automatically perform the
conversion to this type. But it's not that often that we need it
anyway.

Last point regarding your last patch to adjust the coding style, please
remerge it with your first patch (if you're unsure how to proceed, use
"git rebase -i master" for this, then use the "fixup" operation for the
second one instead of "pick", and it will be fused into it).

Thanks!
Willy

Reply via email to