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

feat(sink): support encode protobuf with confluent schema registry #15546

Merged
merged 4 commits into from
Mar 13, 2024

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Mar 8, 2024

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

What's changed and what's your intention?

When creating kafka sink with format plain encode protobuf, the schema definition can now come from confluent schema registry, in addition to previously supported http[s]:// and file://.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • 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

Support confluent schema registry for kafka sink using format plain encode protobuf.

The following options are same as in protobuf/avro source and avro sink.

  • schema.registry (instead of schema.location): required
  • schema.registry.username
  • schema.registry.password
  • schema.registry.name.strategy: optional and defaults to topic_name_strategy

The following options are same as protobuf source, but different from avro source/sink:

  • message
    • required for protobuf
    • (for avro, only required when name strategy is record_name_strategy or topic_record_name_strategy)
  • key.message
    • NOT APPLICABLE for protobuf (because we only support format plain; there's no format upsert support)
    • (for avro, only required when name strategy is record_name_strategy or topic_record_name_strategy)

Example:

format plain encode protobuf (
  schema.registry = 'http://message_queue:8081',
  message = 'test.package.MessageA');

@xiangjinwu xiangjinwu added user-facing-changes Contains changes that are visible to users and removed type/feature labels Mar 8, 2024
buf.reserve(1 + 4);
buf.put_u8(0);
buf.put_i32(schema_id);
MessageIndexes::from(self.message.descriptor()).encode(&mut buf);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be pre-computed and is same for all messages.

@xiangjinwu xiangjinwu force-pushed the feat-sink-protobuf-schema-registry branch from 56acf85 to 63bddef Compare March 11, 2024 06:29
@xiangjinwu xiangjinwu force-pushed the feat-sink-protobuf-schema-registry branch 2 times, most recently from 9c94e58 to 12acefe Compare March 12, 2024 05:25
@xiangjinwu xiangjinwu force-pushed the feat-sink-protobuf-schema-registry branch 2 times, most recently from 7b2c44a to b41d537 Compare March 12, 2024 06:14
@xiangjinwu xiangjinwu force-pushed the feat-sink-protobuf-schema-registry branch from b41d537 to 30b9477 Compare March 12, 2024 06:48
@xiangjinwu xiangjinwu marked this pull request as ready for review March 12, 2024 06:48
@xiangjinwu xiangjinwu requested a review from tabVersion March 12, 2024 06:48
Copy link
Contributor

@tabVersion tabVersion 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, thanks

Comment on lines +39 to +40
let schema_location = format_options.get(SCHEMA_LOCATION_KEY);
let schema_registry = format_options.get(SCHEMA_REGISTRY_KEY);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we also need to handle the auth for schema registry here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is handled inside the unified SchemaLoader (#14642)

let client_config = format_options.into();

But yes our e2e tests use redpanda without password, and cannot catch bugs on auth (e.g. #14755).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to be an involved process. Leaving it as a separate issue.
https://docs.redpanda.com/23.2/manage/security/authentication/#configure-basic-authentication

@xiangjinwu xiangjinwu added this pull request to the merge queue Mar 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2024
@xiangjinwu xiangjinwu enabled auto-merge March 12, 2024 09:47
@xiangjinwu xiangjinwu added this pull request to the merge queue Mar 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 12, 2024
@xiangjinwu xiangjinwu added this pull request to the merge queue Mar 13, 2024
Merged via the queue into main with commit 8d043b7 Mar 13, 2024
27 of 28 checks passed
@xiangjinwu xiangjinwu deleted the feat-sink-protobuf-schema-registry branch March 13, 2024 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants