Skip to content

Commit

Permalink
Add a lifecycle hook to run commands before streaming has begun
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-mattalexander committed Mar 8, 2024
1 parent b112e8e commit 3ff3c9d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/github/shyiko/mysql/binlog/BinaryLogClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ public void connect() throws IOException, IllegalStateException {
setupConnection();
gtid = null;
tx = false;

for (LifecycleListener lifecycleListener : lifecycleListeners) {
lifecycleListener.beforeConnect(this);
}

requestBinaryLogStream();
} catch (IOException e) {
disconnectChannel();
Expand Down Expand Up @@ -1365,6 +1370,13 @@ public interface EventListener {
* {@link BinaryLogClient}'s lifecycle listener.
*/
public interface LifecycleListener {
/**
* Called once client has successfully logged in but before requested binlog events.
* @param client the client that logged in
*/
default void beforeConnect(BinaryLogClient client) {
client.logger.info("No pre-streaming activity configured");
}

/**
* Called once client has successfully logged in but before started to receive binlog events.
Expand Down

0 comments on commit 3ff3c9d

Please sign in to comment.