← Back to team overview

mysql-proxy-discuss team mailing list archive

Question about connect_server()

 

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



Follow ups