Capturing a Connection with connect-opracowanie

Nasza ocena:

Wyświetleń: 343
Komentarze: 0

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
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
function connect_server()
print("-- a client really wants to talk to a server")
if (tonumber("%M")) % 2 == 0) then
proxy.connection.backend_ndx = 2
print("Choosing backend 2")
proxy.connection.backend_ndx = 1
print("Choosing backend 1")
print("Using " ..[proxy.connection.backend_ndx]
This example also displays the IP address/port combination by accessing the information from the
internal table.
... zobacz całą notatkę

Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz