Hi Wei,
On Mon, Aug 23, 2010 at 03:40:41AM -0400, Wang, Wei wrote:
> Hi Willy,
>
> Our client send the request to our back-end server. And the request
> contains a string of user id.
> So I want to write an analyser to extract the user id from request and
> haproxy can stick client to server base on user id.
OK. You will have to ensure that your analyser is able to wait for the
information to be present in the buffer. One way do easily do that is
to have an ACL which matches the presence of the field in the data, and
which is used in a "tcp-request content" rule, in conjunction with a
"tcp-request inspect-delay" (just as we do with SSL detection for instance).
That way you don't need an analyser and you know that when you extract your
pattern, the data is already present.
> Now I want to configure haproxy as following
> stick match userid table servers
>
> So I add a pattern_fetch_keyword to pattern_fetch_keywords list as
> following
> { "userid", pattern_fetch_userid, PATTERN_TYPE_STRING,
> PATTERN_FETCH_REQ }
>
> The function pattern_fetch_userid is declared.
> /* extract the string of user id in request */
> static int
> pattern_fetch_userid (struct proxy *px, struct session *l4, void *l7,
> int dir,
> const char *arg, int arg_len, union pattern_data
> *data)
>
>
> Could you suggest on how to reuse the existing stickiness infrastructure
> in haproxy.
All you did looks good, and I don't think you have to change anything
else. However, you must be aware of one thing : while stickiness on
string has been implemented in the core, it has not been used yet, so
it is not tested. Thus, if you notice that something does not work as
expected, one possibility is that it is your code, but another one is
that it comes from haproxy. Do not hesitate to add debugging outputs
everywhere in this case.
Regards,
Willy