You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "JooHyukKim (via GitHub)" <gi...@apache.org> on 2023/08/16 09:41:48 UTC

[GitHub] [pulsar] JooHyukKim commented on a diff in pull request #21004: [improve][io] Improve kinesis connector config.

JooHyukKim commented on code in PR #21004:
URL: https://github.com/apache/pulsar/pull/21004#discussion_r1295644612


##########
pulsar-io/kinesis/src/main/java/org/apache/pulsar/io/kinesis/KinesisSourceConfig.java:
##########
@@ -122,24 +123,27 @@ public class KinesisSourceConfig extends BaseKinesisConfig implements Serializab
     )
     private String dynamoEndpoint = "";
 
-    @FieldDoc(
-        required = false,
-        defaultValue = "",
-        help = "Cloudwatch end-point url. It can be found at https://docs.aws.amazon.com/general/latest/gr/rande.html"
-    )
-    private String cloudwatchEndpoint = "";
-
     @FieldDoc(
         required = false,
         defaultValue = "true",
         help = "When true, uses Kinesis enhanced fan-out, when false, uses polling"
     )
     private boolean useEnhancedFanOut = true;
 
-
-    public static KinesisSourceConfig load(String yamlFile) throws IOException {
-        ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
-        return mapper.readValue(new File(yamlFile), KinesisSourceConfig.class);
+    public static KinesisSourceConfig load(Map<String, Object> config, SourceContext sourceContext) {
+        KinesisSourceConfig kinesisSourceConfig = IOConfigUtils.loadWithSecrets(config,
+                KinesisSourceConfig.class, sourceContext);
+        checkArgument(isNotBlank(kinesisSourceConfig.getAwsRegion())
+                        || (isNotBlank(kinesisSourceConfig.getAwsEndpoint())
+                            && isNotBlank(kinesisSourceConfig.getCloudwatchEndpoint())
+                            && isNotBlank(kinesisSourceConfig.getDynamoEndpoint())),
+                "Either the awsEndpoint, cloudwatchEndpoint, dynamoEndpoint or awsRegion must be set");

Review Comment:
   The current error message can be more consistent with the actual validation logic maybe like.....
   
   ```suggestion
                 "Either \"awsRegion\" must be set OR all of [ \"awsEndpoint\", \"cloudwatchEndpoint\", and \"dynamoEndpoint\" ] must be set.");
   ```



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org