-
Notifications
You must be signed in to change notification settings - Fork 526
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
feat(connector): SinkExecutor init + MySQLSink mvp #2969
Conversation
I suggest you should create a new crate for the sink code. Because we may not want the MySQL and redis libs bundled in the streaming crate. |
is sink on the same level of source? we may reuse the connector's code later? |
I was thinking it would make sense to move sink into the connector crate and have a separate |
I partly agree, we can go iteratively and leave the sink code in connector crate in the first version. |
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.
license-eye has totally checked 832 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
830 | 1 | 1 | 0 |
Click to see the invalid file list
- src/frontend/test_runner/tests/gen/testcases.rs
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||
|
||
#[tokio::test] | ||
async fn test_expr() { |
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.
We don't have this file now. It was removed by some pr long ago.
src/connector/src/sink.rs
Outdated
pub struct RedisSink; | ||
|
||
#[async_trait] | ||
impl Sink for RedisSink { |
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.
/sink/mysql.rs
/sink/redis.rs
/sink/mod.rs
Personally recommend this way to organize the files.
src/connector/src/sink.rs
Outdated
fn endpoint(&self) -> String; | ||
fn table(&self) -> String; | ||
fn database(&self) -> Option<String>; | ||
fn user(&self) -> Option<String>; | ||
fn password(&self) -> Option<String>; // TODO(nanderstabel): auth? |
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 is sink-specific. Not all sinks have the concepts of "table", "database", or "user". You need to generalize them into a "SinkConfig", which could be an enum.
pub enum SinkConfig {
Mysql(MysqlConfig),
Redis(RedisConfig)
}
impl Sink {
fn new(cfg: SinkConfig) {
match cfg {
SinkConfig::Mysql(cfg) => ...
}
}
}
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.
Not 100% what you mean by impl Sink
since Sink
is a trait?
I solved it now like this:
pub enum SinkImpl {
MySQL(MySQLSink),
Redis(RedisSink),
}
impl SinkImpl {
fn new(cfg: SinkConfig) -> Self {
match cfg {
SinkConfig::Mysql(cfg) => SinkImpl::MySQL(MySQLSink::new(cfg)),
SinkConfig::Redis(cfg) => SinkImpl::Redis(RedisSink::new(cfg)),
}
}
}
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.
Sorry for not giving the right syntax. I'm indicating https://doc.rust-lang.org/book/ch10-02-traits.html. Anyway, SinkImpl also looks good to me.
The overall design looks nice to me, but I think the e2e testing would be a hard problem to solve. |
src/common/Cargo.toml
Outdated
@@ -23,6 +23,7 @@ lru = { git = "https://github.com/singularity-data/lru-rs.git", rev = "e0e9ddaf8 | |||
madsim = "=0.2.0-alpha.3" | |||
memcomparable = { path = "../utils/memcomparable" } | |||
more-asserts = "0.3" | |||
mysql_async = "0.30" |
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.
Don't add more dependencies to common
crate 🤣
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
src/common/src/error.rs
Outdated
@@ -138,6 +139,8 @@ pub enum ErrorCode { | |||
}, | |||
#[error("Invalid Parameter Value: {0}")] | |||
InvalidParameterValue(String), | |||
#[error("MySQL error: {0}")] | |||
MySQLError(MySQLError), |
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.
use BoxedError here so that we don't need to import mysql_async to common crate
Codecov Report
@@ Coverage Diff @@
## main #2969 +/- ##
==========================================
- Coverage 73.65% 73.59% -0.06%
==========================================
Files 740 744 +4
Lines 101830 102029 +199
==========================================
+ Hits 75001 75089 +88
- Misses 26829 26940 +111
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
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, great work!
What's changed and what's your intention?
Intention is to create a simple start of the implementation of a the SinkExecutor MVP.
Please explain IN DETAIL what the changes are in this PR and why they are needed:
Sink
trait is added:SinkExecutor
struct:MySQLSink
struct:For
MySQLSink
is a mvp version ofFn write_batch
implemented.Checklist
./risedev check
(or alias,./risedev c
)