Skip to content

Conversation

@liunaijie
Copy link
Member

Purpose of this pull request

subtask of #8576

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

@liunaijie liunaijie changed the title [Improve] re-struct connector common options [Improve] restruct connector common options Feb 10, 2025
@liunaijie
Copy link
Member Author

update to

image

@Hisoka-X
Copy link
Member

cc @hailin0


public static OptionRule getEnvOptionRules() {
@AutoService(Factory.class)
public class EnvOptionRule implements Factory {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this class implement Factory. Then we can also use SPI to get the env config parameters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env is only one, why we need SPI?

Copy link
Member Author

@liunaijie liunaijie Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If use Factory. we can use this code to verify parameter.

OptionRule optionRule = ServiceLoader.load(Factory.class, classLoader).filter("xxxxx").getEnvOptionRules();


ConfigValidator.of(context.getOptions()).validate(optionRule);

If not implement Factory. the behavior is like this.


OptionRule optionRule; 
if( is connector ){
  optionRule = ServiceLoader.load(Factory.class, classLoader).filter("xxxxx").getEnvOptionRules();
} else if ( is env ) {
  optionRule = EnvOptionRule.getEnvOptionRules();
} 

ConfigValidator.of(context.getOptions()).validate(optionRule);

I am both Ok. but looks implement Factory looks have a unified style.

@hailin0 hailin0 merged commit f3499a6 into apache:dev Feb 13, 2025
5 checks passed
@liunaijie liunaijie deleted the improve/env_options branch February 22, 2025 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants