Communications Sequence with Upstream

Magnus Lynch maglyx at gmail.com
Mon Apr 26 14:33:14 MSD 2010


On Sun, Apr 25, 2010 at 2:35 AM, agentzh <agentzh at gmail.com> wrote:
> On Sun, Apr 25, 2010 at 4:58 PM, Magnus Lynch <maglyx at gmail.com> wrote:
>> Say I have a location /url that I want to construct responses to based
>> on a sequence of communications with an upstream, host:port. To be
>> specific, the upstream would be a database, and the sequence of
>> communications would comprise commands and responses.
>
> We've been doing this kind of things via ngx_echo's echo_location
> directive in our ngx_memc and ngx_drizzle's tests suite. Here's some
> an example to do sequential memcached command execution against the
> ngx_memc upstream module in a single location /main:
>
>    location /main {
>        echo_location '/memc?cmd=flush_all';
>        echo_location '/memc?key=foo&cmd=set&val=';
>        echo_location '/memc?key=foo&cmd=get';
>    }
>    location /memc {
>        set $memc_cmd $arg_cmd;
>        set $memc_key $arg_key;
>        set $memc_value $arg_val;
>        memc_pass 127.0.0.1:11211;
>    }
>
> You can find more examples here:
> http://github.com/agentzh/memc-nginx-module/blob/master/test/t/

Thanks. I looked over echo_location. It uses ngx_http_subrequest,
which I had gathered to be limited to concatenating responses
together, and it still appears that way to me. It appears there's no
hook for you to deal with the data the subrequest produces, as the
various filter hooks the upstream support provides.

This the flow it appears to me you're limited to:
handler does HTTP GET x_1, response y_1 comes back, ..., HTTP GET x_n,
response y_n. and what message the handler ultimately produces is
y_1...y_n.

I'm interested in a more general ability to:
handler sends arbitrary message x_1, response y_1 comes back, ...
repeat n times. handler sends response f(y_1, ..., y_n) to original
query, f an arbitrary function--which is to say I want to have the
responses passed through a filter of mine as they're generated, not
sent straight to the client.

Maybe I'll have to write my own code from scratch for dealing with this.



More information about the nginx mailing list