Skip to content

Commit

Permalink
added ssl_mode option
Browse files Browse the repository at this point in the history
  • Loading branch information
d-hrs committed May 24, 2024
1 parent 91bc7dc commit edafd2f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ MySQL input plugin for Embulk loads data by binlog.
- **user**: MySQL user (string, required)
- **table**: MySQL user (string, required)
- **password**: MySQL password (string, required)
- **ssl_mode**: MySQL SSL mode. See [MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_ssl-mode) for details. (string, default: `DISABLED`)
- **from_binlog_filename**: The beginning of MySQL binlog filename (string, required)
- **from_binlog_position**: The beginning of MySQL binlog position (integer, required)
- **to_binlog_filename**: The end of MySQL binlog filename (string, optional) if to_binlog_filename is provided and to_binlog_position is omitted, this plugin stop fetching date just after binlog rotation to this file. if to_binlog_filename is omitted, plugin stops at the end of binlog.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.shyiko.mysql.binlog.BinaryLogClient;
import com.github.shyiko.mysql.binlog.event.deserialization.EventDeserializer;
import com.github.shyiko.mysql.binlog.network.SSLMode;
import org.embulk.input.mysql_binlog.handler.*;
import org.embulk.input.mysql_binlog.model.DbInfo;
import org.slf4j.Logger;
Expand All @@ -25,7 +26,7 @@ public void setConnecting(boolean connecting) {
}


public MysqlBinlogClient(DbInfo dbInfo, String binlogFilename) {
public MysqlBinlogClient(DbInfo dbInfo, String binlogFilename, SSLMode sslMode) {
client = new BinaryLogClient(dbInfo.getHost(), dbInfo.getPort(), dbInfo.getUser(), dbInfo.getPassword());
EventDeserializer eventDeserializer = new EventDeserializer();
eventDeserializer.setCompatibilityMode(
Expand All @@ -36,6 +37,7 @@ public MysqlBinlogClient(DbInfo dbInfo, String binlogFilename) {
client.setBlocking(false);
client.registerLifecycleListener(this);
client.setHeartbeatInterval(client.getKeepAliveInterval() / 2);
client.setSSLMode(sslMode);
}

public void registerEventListener(BinlogEventHandler binlogEventHandler) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/embulk/input/mysql_binlog/PluginTask.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.embulk.input.mysql_binlog;

import com.github.shyiko.mysql.binlog.network.SSLMode;
import com.google.common.base.Optional;
import org.embulk.config.Config;
import org.embulk.config.ConfigDefault;
Expand Down Expand Up @@ -65,6 +66,10 @@ public interface PluginTask
@ConfigDefault("\"disable\"")
Ssl getSsl();

@Config("ssl_mode")
@ConfigDefault("\"DISABLED\"")
SSLMode getSslMode();

@Config("default_timezone")
@ConfigDefault("\"UTC\"")
String getDefaultTimezone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public MysqlBinlogManager(PluginTask task, PageBuilder pageBuilder, Schema schem
this.setCurrentDdl(t.toDdl());

DbInfo dbInfo = MysqlBinlogClient.convertTaskToDbInfo(task);
this.client = new MysqlBinlogClient(dbInfo, getBinlogFilename());
this.client = new MysqlBinlogClient(dbInfo, getBinlogFilename(), task.getSslMode());
this.registerHandler();
this.client.registerEventListener(handler);
}
Expand Down

0 comments on commit edafd2f

Please sign in to comment.