-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Added ability to add annotations to Connector Configs #6983
Conversation
ConnectorDefinition defn = ConnectorUtils.getConnectorDefinition(classLoader); | ||
if (defn.getSinkConfigClass() != null) { | ||
Class configClass = Class.forName(defn.getSinkConfigClass(), true, classLoader); | ||
ObjectMapper mapper = new ObjectMapper(); |
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.
Please use ObjectMapperFactory.getThreadLocal
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.
Changed
if (defn.getSinkConfigClass() != null) { | ||
Class configClass = Class.forName(defn.getSinkConfigClass(), true, classLoader); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
Object configObject = mapper.readValue(new ObjectMapper().writeValueAsString(sinkConfig.getConfigs()), configClass); |
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.
You can achieve the same thing by using the following method
mapper.convertValue(map, MyPojo.class);
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.
Changed
@srkukarni thinking more about it, I am wondering for sources and sinks whether the following interface is appropriate now that we formalized the concept of a connector config.
Since a connector will have a config class attached to it should we still have "Map<String, Object> config" as an argument or should we somehow just pass in the config POJO? Though not sure that is possible given we only allow developers to specify in the connector config class in "pulsar-io.yaml". There is not way to use Java generics to automatically specify the type of the config argument. |
@jerrypeng wrt your comment on the correct interface, yes in hindsight it does seem as if we should have had an explicit config class in the open. Almost all of the connectors in the repo seem to be following this. |
* Added sourceConfigClass and sinkConfigClass * Add Validator annotation helpers to validate class parameters * Fix build errors * Take feedback into account * Connected with validation * Fix bugs * Added tests * Fix class name * Address feedback Co-authored-by: Sanjeev Kulkarni <sanjeevk@splunk.com>
* Added sourceConfigClass and sinkConfigClass * Add Validator annotation helpers to validate class parameters * Fix build errors * Take feedback into account * Connected with validation * Fix bugs * Added tests * Fix class name * Address feedback Co-authored-by: Sanjeev Kulkarni <sanjeevk@splunk.com>
* Added sourceConfigClass and sinkConfigClass * Add Validator annotation helpers to validate class parameters * Fix build errors * Take feedback into account * Connected with validation * Fix bugs * Added tests * Fix class name * Address feedback Co-authored-by: Sanjeev Kulkarni <sanjeevk@splunk.com>
* Added sourceConfigClass and sinkConfigClass * Add Validator annotation helpers to validate class parameters * Fix build errors * Take feedback into account * Connected with validation * Fix bugs * Added tests * Fix class name * Address feedback Co-authored-by: Sanjeev Kulkarni <sanjeevk@splunk.com>
* Added sourceConfigClass and sinkConfigClass * Add Validator annotation helpers to validate class parameters * Fix build errors * Take feedback into account * Connected with validation * Fix bugs * Added tests * Fix class name * Address feedback Co-authored-by: Sanjeev Kulkarni <sanjeevk@splunk.com>
* Added sourceConfigClass and sinkConfigClass * Add Validator annotation helpers to validate class parameters * Fix build errors * Take feedback into account * Connected with validation * Fix bugs * Added tests * Fix class name * Address feedback Co-authored-by: Sanjeev Kulkarni <sanjeevk@splunk.com>
* Added sourceConfigClass and sinkConfigClass * Add Validator annotation helpers to validate class parameters * Fix build errors * Take feedback into account * Connected with validation * Fix bugs * Added tests * Fix class name * Address feedback Co-authored-by: Sanjeev Kulkarni <sanjeevk@splunk.com>
(If this PR fixes a github issue, please add
Fixes #<xyz>
.)Fixes #
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>
to link to the master issue.)Master Issue: #
Motivation
This pr adds the ability for pulsar io sources and sinks to define annotations in their configs and have them checked at submission time. This means that creation/update of connectors with improper config can be rejected outright at request time rather than at runtime which is the current case. This will lead to faster troubleshooting when developing and running connectors. We make this check gated by a worker config parameter.
Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation