-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on redis #5901
Conversation
} | ||
|
||
@Override | ||
public void prepare(Config pluginConfig) throws PrepareFailException { | ||
public RedisSource(Config pluginConfig) { |
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 ReadOnlyConfig
, do not convert ReadOnlyConfig
to Config
. This is a bad example, we want connectors to be able to use ReadOnlyConfig
instead of Config
this.hashKeyParseMode = | ||
RedisConfig.HashKeyParseMode.valueOf( | ||
config.getString(RedisConfig.HASH_KEY_PARSE_MODE.key()).toUpperCase()); | ||
config.get(RedisConfig.HASH_KEY_PARSE_MODE).name().toUpperCase()); |
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.
After config.get(RedisConfig.HASH_KEY_PARSE_MODE)
. The value already are enum of HashKeyParseMode
. So we don't need use valueOf
to parse it again.
this.mode = | ||
RedisConfig.RedisMode.valueOf( | ||
config.getString(RedisConfig.MODE.key()).toUpperCase()); | ||
config.get(RedisConfig.MODE).name().toUpperCase()); |
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.
ditto
if (config.getOptional(RedisConfig.DB_NUM).isPresent()) { | ||
this.dbNum = config.get(RedisConfig.DB_NUM); | ||
} |
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.
if (config.getOptional(RedisConfig.DB_NUM).isPresent()) { | |
this.dbNum = config.get(RedisConfig.DB_NUM); | |
} | |
this.dbNum = config.get(RedisConfig.DB_NUM); |
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.
Thank you for your review. I have made the necessary modifications PTAL @Hisoka-X
if (config.getOptional(RedisConfig.AUTH).isPresent()) { | ||
this.auth = config.get(RedisConfig.AUTH); | ||
} | ||
// set user | ||
if (config.hasPath(RedisConfig.USER.key())) { | ||
this.user = config.getString(RedisConfig.USER.key()); | ||
if (config.getOptional(RedisConfig.USER).isPresent()) { | ||
this.user = config.get(RedisConfig.USER); | ||
} | ||
// set mode | ||
if (config.hasPath(RedisConfig.MODE.key())) { | ||
this.mode = | ||
RedisConfig.RedisMode.valueOf( | ||
config.getString(RedisConfig.MODE.key()).toUpperCase()); | ||
if (config.getOptional(RedisConfig.MODE).isPresent()) { | ||
this.mode = config.get(RedisConfig.MODE); | ||
} else { | ||
this.mode = RedisConfig.MODE.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.
This part also should be changed like #5901 (comment).
Because it default value already be defined in OptionRule.
if (config.getOptional(RedisConfig.HASH_KEY_PARSE_MODE).isPresent()) { | ||
this.hashKeyParseMode = config.get(RedisConfig.HASH_KEY_PARSE_MODE); | ||
} else { | ||
this.hashKeyParseMode = RedisConfig.HASH_KEY_PARSE_MODE.defaultValue(); | ||
} | ||
// set redis nodes information | ||
if (config.hasPath(RedisConfig.NODES.key())) { | ||
this.redisNodes = config.getStringList(RedisConfig.NODES.key()); | ||
if (config.getOptional(RedisConfig.NODES).isPresent()) { | ||
this.redisNodes = config.get(RedisConfig.NODES); | ||
} | ||
// set key | ||
if (config.hasPath(RedisConfig.KEY.key())) { | ||
this.keyField = config.getString(RedisConfig.KEY.key()); | ||
if (config.getOptional(RedisConfig.KEY).isPresent()) { | ||
this.keyField = config.get(RedisConfig.KEY); | ||
} | ||
// set keysPattern | ||
if (config.hasPath(RedisConfig.KEY_PATTERN.key())) { | ||
this.keysPattern = config.getString(RedisConfig.KEY_PATTERN.key()); | ||
if (config.getOptional(RedisConfig.KEY_PATTERN).isPresent()) { | ||
this.keysPattern = config.get(RedisConfig.KEY_PATTERN); | ||
} | ||
if (config.hasPath(RedisConfig.EXPIRE.key())) { | ||
this.expire = config.getLong(RedisConfig.EXPIRE.key()); | ||
if (config.getOptional(RedisConfig.EXPIRE).isPresent()) { | ||
this.expire = config.get(RedisConfig.EXPIRE); | ||
} |
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.
ditto
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.
thanks i know
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.
done PTAL
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. Thanks @jackyyyyyssss
Purpose of this pull request
[Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on redis #5651 #5897
Does this PR introduce any user-facing change?
How was this patch tested?
current e2e test
Check list
New License Guide
release-note
.