vahmed-hamdy commented on code in PR #29:
URL: 
https://github.com/apache/flink-connector-rabbitmq/pull/29#discussion_r1604736511


##########
flink-connector-rabbitmq/src/main/java/org/apache/flink/connector/rabbitmq/common/RabbitMQConnectionConfig.java:
##########
@@ -0,0 +1,465 @@
+package org.apache.flink.connector.rabbitmq.common;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.streaming.connectors.rabbitmq.RMQSource;
+import 
org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig;
+import org.apache.flink.util.Preconditions;
+
+import java.io.Serializable;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+
+/** Configuration class for RabbitMQ connections. */
+@PublicEvolving
+public class RabbitMQConnectionConfig implements Serializable {
+    private static final long DEFAULT_DELIVERY_TIMEOUT = 30000;
+
+    private String host;
+    private Integer port;
+    private String virtualHost;
+    private String username;
+    private String password;
+    private String uri;
+
+    private Integer networkRecoveryInterval;
+    private Boolean automaticRecovery;
+    private Boolean topologyRecovery;
+
+    private Integer connectionTimeout;
+    private Integer requestedChannelMax;
+    private Integer requestedFrameMax;
+    private Integer requestedHeartbeat;
+
+    private Integer prefetchCount;
+    private final long deliveryTimeout;
+
+    protected RabbitMQConnectionConfig(RabbitMQConnectionConfig.Builder 
builder) {
+        Preconditions.checkArgument(
+                builder.uri != null || (builder.host != null && builder.port 
!= null),
+                "Either URI or host/port must be set");
+        if (builder.uri == null) {
+            Preconditions.checkNotNull(
+                    builder.username, "username can not be null when host/port 
is set");
+            Preconditions.checkNotNull(
+                    builder.password, "password can not be null when host/port 
is set");
+        }
+
+        Preconditions.checkArgument(
+                builder.deliveryTimeout == null || builder.deliveryTimeout > 0,
+                "deliveryTimeout must be positive");
+        this.uri = builder.uri;
+        this.host = builder.host;
+        this.port = builder.port;
+        this.virtualHost = builder.virtualHost;
+        this.username = builder.username;
+        this.password = builder.password;
+
+        this.networkRecoveryInterval = builder.networkRecoveryInterval;
+        this.automaticRecovery = builder.automaticRecovery;
+        this.topologyRecovery = builder.topologyRecovery;
+        this.connectionTimeout = builder.connectionTimeout;
+        this.requestedChannelMax = builder.requestedChannelMax;
+        this.requestedFrameMax = builder.requestedFrameMax;
+        this.requestedHeartbeat = builder.requestedHeartbeat;
+        this.prefetchCount = builder.prefetchCount;
+        this.deliveryTimeout =
+                
Optional.ofNullable(builder.deliveryTimeout).orElse(DEFAULT_DELIVERY_TIMEOUT);
+    }
+
+    /**
+     * @param uri the connection URI
+     * @param networkRecoveryInterval connection recovery interval in 
milliseconds
+     * @param automaticRecovery if automatic connection recovery
+     * @param topologyRecovery if topology recovery
+     * @param connectionTimeout connection timeout
+     * @param requestedChannelMax requested maximum channel number
+     * @param requestedFrameMax requested maximum frame size
+     * @param requestedHeartbeat requested heartbeat interval
+     * @param deliveryTimeout message delivery timeout in the queueing consumer
+     * @throws NullPointerException if URI is null
+     */
+    protected RabbitMQConnectionConfig(
+            String uri,
+            Integer networkRecoveryInterval,
+            Boolean automaticRecovery,
+            Boolean topologyRecovery,
+            Integer connectionTimeout,
+            Integer requestedChannelMax,
+            Integer requestedFrameMax,
+            Integer requestedHeartbeat,
+            Integer prefetchCount,
+            Long deliveryTimeout) {
+        Preconditions.checkNotNull(uri, "Uri can not be null");
+        Preconditions.checkArgument(
+                deliveryTimeout == null || deliveryTimeout > 0, 
"deliveryTimeout must be positive");
+        this.uri = uri;
+
+        this.networkRecoveryInterval = networkRecoveryInterval;
+        this.automaticRecovery = automaticRecovery;
+        this.topologyRecovery = topologyRecovery;
+        this.connectionTimeout = connectionTimeout;
+        this.requestedChannelMax = requestedChannelMax;
+        this.requestedFrameMax = requestedFrameMax;
+        this.requestedHeartbeat = requestedHeartbeat;
+        this.prefetchCount = prefetchCount;
+        this.deliveryTimeout =
+                
Optional.ofNullable(deliveryTimeout).orElse(DEFAULT_DELIVERY_TIMEOUT);
+    }
+
+    /** @return the host to use for connections */
+    public String getHost() {
+        return host;
+    }
+
+    /** @return the port to use for connections */
+    public int getPort() {
+        return port;

Review Comment:
   good catch!



-- 
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]

Reply via email to