Skip to content

Commit

Permalink
eventuate-foundation#152 add support for multi-host connection string…
Browse files Browse the repository at this point in the history
… for Postgres
  • Loading branch information
rrrship committed Oct 11, 2023
1 parent 8ba65c3 commit e3de97f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import io.eventuate.common.eventuate.local.BinlogFileOffset;
import io.eventuate.common.jdbc.EventuateSchema;
import io.eventuate.common.jdbc.JdbcUrl;
import io.eventuate.common.jdbc.JdbcUrlParser;
import io.eventuate.local.common.BinlogEntryReader;
import io.eventuate.local.common.CdcMonitoringDao;
import io.micrometer.core.instrument.MeterRegistry;
Expand All @@ -15,11 +13,9 @@ public abstract class DbLogClient extends BinlogEntryReader {

protected String dbUserName;
protected String dbPassword;
protected String host;
protected int port;
protected DbLogMetrics dbLogMetrics;
protected String dataSourceUrl;
private boolean checkEntriesForDuplicates;
protected String dataSourceUrl;
private boolean checkEntriesForDuplicates;
protected volatile boolean connected;
protected CdcMonitoringDao cdcMonitoringDao;

Expand Down Expand Up @@ -53,10 +49,6 @@ public DbLogClient(MeterRegistry meterRegistry,
this.dbUserName = dbUserName;
this.dbPassword = dbPassword;
this.dataSourceUrl = dataSourceUrl;

JdbcUrl jdbcUrl = JdbcUrlParser.parse(dataSourceUrl);
host = jdbcUrl.getHost();
port = jdbcUrl.getPort();
}

public boolean isConnected() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.google.common.collect.ImmutableSet;
import io.eventuate.common.eventuate.local.BinlogFileOffset;
import io.eventuate.common.jdbc.EventuateSchema;
import io.eventuate.common.jdbc.JdbcUrl;
import io.eventuate.common.jdbc.JdbcUrlParser;
import io.eventuate.common.jdbc.SchemaAndTable;
import io.eventuate.local.common.BinlogEntry;
import io.eventuate.local.common.BinlogEntryHandler;
Expand Down Expand Up @@ -62,6 +64,8 @@ public class MySqlBinaryLogClient extends DbLogClient {
private AtomicLong timeOfLatestMessage = new AtomicLong();;
private Timer messagePublishingTimer;
private BinaryLogClient.EventListener eventListener;
private final String host;
private final int port;

public MySqlBinaryLogClient(MeterRegistry meterRegistry,
String dbUserName,
Expand Down Expand Up @@ -98,6 +102,10 @@ public MySqlBinaryLogClient(MeterRegistry meterRegistry,
this.offsetStore = offsetStore;
this.debeziumBinlogOffsetKafkaStore = debeziumBinlogOffsetKafkaStore;

JdbcUrl jdbcUrl = JdbcUrlParser.parse(dataSourceUrl);
host = jdbcUrl.getHost();
port = jdbcUrl.getPort();

timestampExtractor = new MySqlBinlogCdcMonitoringTimestampExtractor(dataSource);
mySqlBinlogEntryExtractor = new MySqlBinlogEntryExtractor(dataSource);
tableMapper = new TableMapper();
Expand Down

0 comments on commit e3de97f

Please sign in to comment.