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

Pulsar Client: allow to print GenericRecord contents #9785

Merged
merged 4 commits into from
Mar 12, 2021

Conversation

eolivelli
Copy link
Contributor

Motivation

When you are dealing with structured data it would be pretty useful to have a tool that prints decoded records directly to the console.

Modifications

Add two new options to the "pulsar-client consume" tool:

  • "--schema-type" option, that can be "bytes" and "auto_consume" in order to select the Schema (in particular you are interested in AUTO_CONSUME if you are dealing with GenericRecords)
  • "--hide-content" boolean option, that shuts down the printing of the contents of the messages, in case they are in binary form or that you are using the tool only to test if any message is coming from the topic

In case of GenericRecords we are printing the content of the record like a Java Map. We are also handling nested GenericRecord structures as well.

@eolivelli
Copy link
Contributor Author

@codelipenghui @wolfstudy @rdhabalia please help merging this patch.
it is a trivial work but very useful while dealing with structured data

import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to avoid the star import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codelipenghui it was my IDE.

we should have checkstyle to block this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think the check style plugin does not enable for this module, so...

@codelipenghui codelipenghui added type/feature The PR added a new feature or issue requested a new feature area/cli labels Mar 4, 2021
@codelipenghui codelipenghui added the doc-required Your PR changes impact docs and you will update later. label Mar 4, 2021
@codelipenghui codelipenghui added this to the 2.8.0 milestone Mar 4, 2021
@Anonymitaet
Copy link
Member

@eolivelli thanks for your work, could you pls add docs for this PR?

@eolivelli
Copy link
Contributor Author

@Anonymitaet I added docs in the pulsar-client section.
Thanks for the suggestion
PTAL

@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@Anonymitaet Anonymitaet added doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. and removed doc-required Your PR changes impact docs and you will update later. labels Mar 8, 2021
@Anonymitaet
Copy link
Member

@eolivelli Many thanks for your docs.

@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@eolivelli
Copy link
Contributor Author

@codelipenghui @zymap this patch has been approved, can you please help me merging to master branch ?
thanks for your review (also to @Anonymitaet )

@315157973
Copy link
Contributor

/pulsarbot run-failure-checks

1 similar comment
@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@eolivelli
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

2 similar comments
@eolivelli
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@eolivelli
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@eolivelli
Copy link
Contributor Author

@codelipenghui @rdhabalia I am not sure why pulsarbot it not going to rerun the failed tests.
can you please force the rerun from the github UI ?

@codelipenghui
Copy link
Contributor

@eolivelli I have rerun through the Github UI.

@eolivelli
Copy link
Contributor Author

Tests are always failing for errors unrelated to this patch.
I am merging with current master, let's see if it goes better

@eolivelli
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

3 similar comments
@eolivelli
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@eolivelli
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@eolivelli
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@codelipenghui codelipenghui merged commit 3988f9f into apache:master Mar 12, 2021
fmiguelez pushed a commit to fmiguelez/pulsar that referenced this pull request Mar 16, 2021
### Motivation
When you are dealing with structured data it would be pretty useful to have a tool that prints decoded records directly to the console.

### Modifications

Add two new options to the "pulsar-client consume" tool:
- "--schema-type" option, that can be "bytes" and "auto_consume" in order to select the Schema (in particular you are interested in AUTO_CONSUME if you are dealing with GenericRecords)
- "--hide-content" boolean option, that shuts down the printing of the contents of the messages, in case they are in binary form or that you are using the tool only to test if any message is coming from the topic

In case of GenericRecords we are printing the content of the record like a Java Map. We are also handling nested GenericRecord structures as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants