jberragan commented on code in PR #187:
URL:
https://github.com/apache/cassandra-analytics/pull/187#discussion_r3023979455
##########
cassandra-analytics-cdc-sidecar/src/main/java/org/apache/cassandra/cdc/sidecar/SidecarCdcBuilder.java:
##########
@@ -85,17 +89,38 @@ public class SidecarCdcBuilder extends CdcBuilder
EventConsumer eventConsumer,
SchemaSupplier schemaSupplier,
TokenRangeSupplier tokenRangeSupplier,
+ @NotNull Function<String, Integer> portResolver,
SidecarCdcClient.ClientConfig clientConfig,
SidecarClient sidecarClient,
ICdcStats cdcStats)
{
super(jobId, partitionId, eventConsumer, schemaSupplier);
this.clusterConfigProvider = clusterConfigProvider;
- this.sidecarCdcClient = new SidecarCdcClient(clientConfig,
sidecarClient, cdcStats);
+ this.portResolver = portResolver;
+ this.sidecarCdcClient = new SidecarCdcClient(clientConfig,
sidecarClient, cdcStats, portResolver);
withCdcOptions(cdcOptions);
withTokenRangeSupplier(tokenRangeSupplier);
}
+ /**
+ * Builds a port resolver function from the {@link
CdcSidecarInstancesProvider}. The resolver looks up
+ * the port for a given hostname from the provider, falling back to the
configured effective port.
+ */
+ static Function<String, Integer> buildPortResolver(@NotNull
CdcSidecarInstancesProvider provider,
Review Comment:
This is a bit `O(n)` can we change the interface to be `(CassandraInstance)
-> Integer`, that way we can just return:
```
(instance) -> instance.port();
```
##########
cassandra-analytics-cdc-sidecar/src/main/java/org/apache/cassandra/cdc/sidecar/SidecarCdcBuilder.java:
##########
@@ -43,6 +44,8 @@ public class SidecarCdcBuilder extends CdcBuilder
{
protected ClusterConfigProvider clusterConfigProvider;
protected SidecarCdcClient sidecarCdcClient;
+ @NotNull
+ protected Function<String, Integer> portResolver;
Review Comment:
Could you keep a default implementation that returns `(ignored) ->
config.effectivePort()` so we keep the preexisting behavior. Then add a builder
method e.g. `withPortResolver` if users wish to override with their own
implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]