Cloned from https://bitbucket.org/winebarrel/mysql-replication-listener