Capturing a Connection with connect-opracowanie

Nasza ocena:

3
Wyświetleń: 343
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Capturing a Connection with connect-opracowanie - strona 1

Fragment notatki:

Capturing a Connection with connect_server()
When the proxy accepts a connection from a MySQL client, the connect_server() function is
called.
There are no arguments to the function, but you can use and if necessary manipulate the information in
the proxy.connection table, which is unique to each client session.
For example, if you have multiple backend servers, you can specify which server that connection
should use by setting the value of proxy.connection.backend_ndx to a valid server number. The
following code chooses between two servers based on whether the current time in minutes is odd or
even:
function connect_server()
print("-- a client really wants to talk to a server")
if (tonumber(os.date("%M")) % 2 == 0) then
proxy.connection.backend_ndx = 2
print("Choosing backend 2")
else
proxy.connection.backend_ndx = 1
print("Choosing backend 1")
end
print("Using " .. proxy.global.backends[proxy.connection.backend_ndx].dst.name)
end
This example also displays the IP address/port combination by accessing the information from the
internal proxy.global.backends table.
... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz