michaeljmarshall commented on code in PR #20902:
URL: https://github.com/apache/pulsar/pull/20902#discussion_r1295391055
##########
pulsar-io/canal/src/main/java/org/apache/pulsar/io/canal/CanalSourceConfig.java:
##########
@@ -80,14 +83,31 @@ public class CanalSourceConfig implements Serializable{
help = "The batch size to fetch from canal.")
private int batchSize = 1000;
+
+ /**
+ * @deprecated Use {@link #load(String, SourceContext)} instead.
+ */
+ @Deprecated
public static CanalSourceConfig load(String yamlFile) throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
return mapper.readValue(new File(yamlFile), CanalSourceConfig.class);
}
+ public static CanalSourceConfig load(String yamlFile, SourceContext
context) throws IOException {
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ return load(mapper.readValue(new File(yamlFile), new
TypeReference<Map<String, Object>>() {}), context);
+ }
+ /**
+ * @deprecated Use {@link #load(Map, SourceContext)} instead.
+ */
+ @Deprecated
public static CanalSourceConfig load(Map<String, Object> map) throws
IOException {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(mapper.writeValueAsString(map),
CanalSourceConfig.class);
}
+
+ public static CanalSourceConfig load(Map<String, Object> map,
SourceContext context) {
+ return IOConfigUtils.loadWithSecrets(map, CanalSourceConfig.class,
context);
Review Comment:
I agree that this is not the ideal solution. I wrote this PR to complete the
paradigm started in the project for some but not all connectors. There are
already several examples using this "flow", which is to convert the
`Map<String, Object>` into my `CustomSinkConfig` class. However, I do not think
we should make this mechanism easier to use. I would prefer to guide developers
to the new generic solution provided in PIP 289 of using env vars instead of
adding new methods in the `Context`.
--
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]