Skip to content

[feat][client] Support configure MessageCrypto in ProducerBuilder#19939

Merged
tisonkun merged 3 commits into
apache:masterfrom
tisonkun:producer-MessageCrypto
Apr 1, 2023
Merged

[feat][client] Support configure MessageCrypto in ProducerBuilder#19939
tisonkun merged 3 commits into
apache:masterfrom
tisonkun:producer-MessageCrypto

Conversation

@tisonkun

@tisonkun tisonkun commented Mar 27, 2023

Copy link
Copy Markdown
Member

This closes #19139.

Motivation

It's a lightweight feature alignment. Since it somehow touches public API, I don't know if it requires a PIP. It may not be, just trivial.

Modifications

Support configure MessageCrypto in ProducerBuilder.

We already test this field but never pass or expose the config:

if (conf.getMessageCrypto() != null) {
this.msgCrypto = conf.getMessageCrypto();
} else {
// default to use MessageCryptoBc;
MessageCrypto msgCryptoBc;
try {
msgCryptoBc = new MessageCryptoBc(logCtx, true);
} catch (Exception e) {
log.error("MessageCryptoBc may not included in the jar in Producer. e:", e);
msgCryptoBc = null;
}
this.msgCrypto = msgCryptoBc;
}

Verifying this change

Trivial.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

Maybe I should update some doc, but I'm not sure where is related doc.

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@tisonkun tisonkun self-assigned this Mar 27, 2023
@github-actions github-actions Bot added the doc-required Your PR changes impact docs and you will update later. label Mar 27, 2023
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun tisonkun force-pushed the producer-MessageCrypto branch from 000889e to 56b048d Compare March 27, 2023 14:59
@Technoboy- Technoboy- added this to the 3.0.0 milestone Mar 28, 2023
@Technoboy-

Copy link
Copy Markdown
Contributor

LGTM

@RobertIndie RobertIndie self-requested a review March 29, 2023 08:33

@RobertIndie RobertIndie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it was the lack of testing that caused the missing exposure of this field to the ProducerBuilder. Better to add a test to cover this case.

@tisonkun

tisonkun commented Mar 29, 2023

Copy link
Copy Markdown
Member Author

@RobertIndie I was thinking of it, but the only test case comes to my mind is some getter/setter tests (i.e., we configure the message crypoto object, and verify that it's configured). I can add some if asked.

@RobertIndie RobertIndie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just found out that the consumer also lacks of function test of message crypto. I'm +1 for this PR.

@tisonkun

Copy link
Copy Markdown
Member Author

Just found out that the consumer also lacks of function test of message crypto. I'm +1 for this PR.

Yep. This is a standard builder pattern and a complement. We don't test builders but upper-layer logic, do we?

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I support this patch and I don't think it requires a PIP.

But I think that we need to need some test at least to prevent that someone changes the API in the future.

Please also add the test for the similar method on the ConsumerBuilder

@tisonkun

Copy link
Copy Markdown
Member Author

@eolivelli e73ad35 add basic set-and-get tests to prevent API breaking. ConsumerBuilderImplTest already has similar API call to prevent API breaking. Please take another look :)

@tisonkun tisonkun requested a review from eolivelli March 30, 2023 16:19
@tisonkun

tisonkun commented Apr 1, 2023

Copy link
Copy Markdown
Member Author

Thanks for your reviews!

Merging...

@tisonkun tisonkun merged commit 0214745 into apache:master Apr 1, 2023
@tisonkun tisonkun deleted the producer-MessageCrypto branch April 1, 2023 06:18
@Anonymitaet

Anonymitaet commented Apr 10, 2023

Copy link
Copy Markdown
Member

@tisonkun thanks for introducing this improvement!

I see this PR is labeled with doc-required, so from the doc perspective:

Thank you!

poorbarcode pushed a commit to streamnative/pulsar-archived that referenced this pull request Aug 29, 2023
…ache#19939)

Signed-off-by: tison <wander4096@gmail.com>
(cherry picked from commit 0214745)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-required Your PR changes impact docs and you will update later. ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Client] Add MessageCrypto setting in ProducerBuilder

5 participants