mysql-proxy-discuss team mailing list archive
-
mysql-proxy-discuss team
-
Mailing list archive
-
Message #00140
Re: Question about connect_server()
Ah, after I sent the email I figured it out
function connect_server()
-- emulate a server
proxy.response = {
type = proxy.MYSQLD_PACKET_RAW,
packets = {
packet_auth()
}
}
if proxy.global.backends[1].state == proxy.BACKEND_STATE_DOWN then
last_node = 1
return proxy.PROXY_SEND_RESULT
end
return proxy.PROXY_IGNORE_RESULT
end
In the next few days I'll publish the complete code on a blog (This is
to add synchronous replication to proxydb
(http://fmpwizard.blogspot.com/2009/05/mysql-proxy-proxydb.html) )
Thanks!
Diego
On Wed, May 20, 2009 at 10:57 PM, Diego Medina <diego@xxxxxxxxxxxxx> wrote:
> Hi,
>
> I have a sue case where I want to only use one lua script, to handle
> two different situations.
> The idea is:
>
> mysql client -> proxy1->proxy2
>
> You send a query to proxy 1, proxy1 sends that same query to proxy2.
> proxy2 will need to know that is the last one on the chain and return
> an ok packet back to proxy1 and proxy1 will need to send it back to
> the client.
>
> I think that what I need is to do is play with connect_server() ,
> proxy1 needs to know that there is another proxy behind it, so it will
> just pass the connect request to proxy2, but proxy2 has to simulate
> the
> connect_server() function and send the regular "I'm a server you can
> connect to" message.
>
> Any hints?
>
> Thanks
>
> P.S.
>
> I tried
>
> local s = proxy.global.backends[1]
> if s.state ~= proxy.BACKEND_STATE_DOWN then
> function cconnect_server()
> -- emulate a server
> proxy.response = {
> type = proxy.MYSQLD_PACKET_RAW,
> packets = {
> packet_auth()
> }
> }
> return proxy.PROXY_SEND_RESULT
> end
>
> end
>
>
> But the client ends up getting the "all backends are down" response :(
>
>
> --
> Diego Medina
> Web Developer
> http://www.fmpwizard.com
>
--
Diego Medina
Web Developer
http://www.fmpwizard.com
References