-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Improve] Use new Factory API to create KafkaSource #5635
[Improve] Use new Factory API to create KafkaSource #5635
Conversation
9fbc1d0
to
5b12a51
Compare
5b12a51
to
990ae3b
Compare
@@ -105,127 +67,36 @@ public String getPluginName() { | |||
|
|||
@Override | |||
public void prepare(Config config) throws PrepareFailException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this method ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
setDeserialization(config); | ||
kafkaSourceConfig = new KafkaSourceConfig(ReadonlyConfig.fromConfig(config)); | ||
} | ||
|
||
@Override | ||
public SeaTunnelRowType getProducedType() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this method ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can not be removed for now. I need to do some extra work on the translation layer in the next PR before I can properly remove it. For this PR, it is better to keep it.
@@ -66,6 +73,10 @@ public <T> T get(Option<T> option) { | |||
return getOptional(option).orElseGet(option::defaultValue); | |||
} | |||
|
|||
public <T> T get(Option<T> option, T defaultValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the following:
-
Define default value in Option
-
getOptional(Option).orElse(defaultValue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's better way, I removed this method.
990ae3b
to
9b4b165
Compare
CheckResult result = readonlyConfig.checkAllExists(TOPIC, BOOTSTRAP_SERVERS); | ||
if (!result.isSuccess()) { | ||
throw new KafkaConnectorException( | ||
SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED, | ||
String.format( | ||
"PluginName: %s, PluginType: %s, Message: %s", | ||
CONNECTOR_IDENTITY, PluginType.SOURCE, result.getMsg())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think checkAllExists
is unnecessary. As ReadonlyConfig
, if it implement TableSourceFactory
, we will check whether all configs are legal. Please refer
seatunnel/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/factory/FactoryUtil.java
Line 116 in aefc135
ConfigValidator.of(context.getOptions()).validate(factory.optionRule()); |
c_bytes = bytes | ||
c_date = date | ||
c_timestamp = timestamp | ||
columns = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create new conf not replace old one? I think we should make sure both two config way worked fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with you
410dd3c
to
5d7344c
Compare
5d7344c
to
3834b8a
Compare
Collections.emptyMap(), | ||
Collections.emptyList(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine after #5681 merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Purpose of this pull request
KafkaSource use new Factory API to create, after this change the CatalogTable can be send to post task.
Does this PR introduce any user-facing change?
How was this patch tested?
Use e2e case to assert the catalog generate by KafkaSource
Check list
New License Guide
release-note
.