Skip to content
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

refactor(sink): refine sink trait and macro #12478

Merged
merged 6 commits into from
Sep 26, 2023
Merged

Conversation

wenym1
Copy link
Contributor

@wenym1 wenym1 commented Sep 21, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

In this PR we refine sink trait and macro similar to what we do for source in #12260.

Previously when we add a new sink, we need to add new code to SinkConfig, SinkImpl, build_sink, dispatch_sink_impl and other places. After this PR, we have a macro for_all_sinks that declare all sinks, and when we add a new sink, we only need to add the sink to the list in for_all_sinks. The SinkConfig enum is removed, and the dispatch_sink_impl will generate code based on the sinks listed in for_all_sinks.

Sinks will implement TryFrom<SinkParam> as a general way to be created from the sink param.

Besides, the async_trait macro on sink trait and impl are removed.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

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

Generally LGTM

@@ -152,13 +206,14 @@ pub struct SinkWriterParam {
pub meta_client: Option<MetaClient>,
}

#[async_trait]
pub trait Sink {
pub trait Sink: TryFrom<SinkParam, Error = SinkError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub trait Sink: TryFrom<SinkParam, Error = SinkError> {
pub trait Sink: TryFrom<SinkContext, Error = SinkError> {

I would suggest to add sth like SinkContext, we may need to add more info such as actor id for better observability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Sink is a set of logical metadata, and it is used in all env such an CN and meta. The compute runtime information, such as actor id and executor id, should only be passed to the sink writer, which is already passed in the SinkWriterParam when we create a new sink writer.

Copy link
Contributor

@StrikeW StrikeW left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@yufansong yufansong left a comment

Choose a reason for hiding this comment

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

Nats part LGTM!

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Merging #12478 (c855fbf) into main (5eeef12) will decrease coverage by 0.01%.
Report is 1 commits behind head on main.
The diff coverage is 18.79%.

@@            Coverage Diff             @@
##             main   #12478      +/-   ##
==========================================
- Coverage   69.43%   69.43%   -0.01%     
==========================================
  Files        1438     1438              
  Lines      238751   238700      -51     
==========================================
- Hits       165783   165734      -49     
+ Misses      72968    72966       -2     
Flag Coverage Δ
rust 69.43% <18.79%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/connector/src/sink/boxed.rs 0.00% <ø> (ø)
src/connector/src/sink/redis.rs 0.00% <0.00%> (ø)
src/meta/src/stream/sink.rs 0.00% <0.00%> (ø)
src/connector/src/sink/kafka.rs 34.16% <0.00%> (-0.24%) ⬇️
src/connector/src/sink/kinesis.rs 0.00% <0.00%> (ø)
src/connector/src/sink/pulsar.rs 0.00% <0.00%> (ø)
src/connector/src/sink/clickhouse.rs 0.00% <0.00%> (ø)
src/connector/src/sink/iceberg.rs 16.30% <0.00%> (-0.26%) ⬇️
src/connector/src/sink/mod.rs 41.75% <74.07%> (+8.86%) ⬆️
src/connector/src/sink/nats.rs 0.00% <0.00%> (ø)
... and 3 more

... and 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@wenym1 wenym1 enabled auto-merge September 26, 2023 07:53
@wenym1 wenym1 added this pull request to the merge queue Sep 26, 2023
Merged via the queue into main with commit f38554e Sep 26, 2023
6 of 7 checks passed
@wenym1 wenym1 deleted the yiming/refine-sink-trait branch September 26, 2023 08:36
BugenZhao pushed a commit that referenced this pull request Sep 27, 2023
…2123)

feat(java-binding): generate jni method signature with macro (#12487)

feat(streaming): recover `no_shuffle_backfill` (#12493)

feat(test): support customized source logic in deterministic test (#12456)

refactor(storage): reorg selector (#12392)

feat(frontend): add rw_catalog.rw_hummock_sstables (#12532)

chore: bump risingwave version in docker compose to 1.2.0 (#12530)

Signed-off-by: Bugen Zhao <[email protected]>

refactor(sink): decouple sink formatter and payload writer (#12515)

chore(java-binding): refine stream chunk benchmark (#12504)

feat(meta): add create_type to `Table` (#12529)

refactor(sink): refine sink trait and macro (#12478)

refactor(backup): refine error message (#12388)

feat(sink): turn sink writer into higher level log sinker (#12152)

fix(over window): don't expect stream keys in UpdateDelete and UpdateInsert the same (#12536)

Signed-off-by: Richard Chien <[email protected]>

refactor(expr): separate function implementations into a new crate (#12485)

Signed-off-by: Runji Wang <[email protected]>

fix(config): make metrics_level opt backward compatible (#12541)

refactor(connector): replace sink writer rpc with jni (#12480)

refactor(connector): remove `WriteGuard` and `fulfill_meta_column` from parser (#12542)

Signed-off-by: Bugen Zhao <[email protected]>

feat(sink): handle stream key sink pk mismatch (#12458)

feat(optimizer): support apply hop window transpose rule (#12338)
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.

4 participants