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

#270 support prefix for producer transaction id and consumer group #279

Conversation

MagnusSmith
Copy link
Contributor

Currently producer transaction id and consumer group are treated as literals. This PR addresses #270 by allowing a trailing * to denote a resource pattern type prefix

    consumers:
      - principal: "User:greta"
        group: "greta*"

and

    producers:
      - principal: "User:greta"
        transactionId: "greta*"

Since this is not changing the structure then there should not be any braking changes. Have added test cases.

Copy link
Collaborator

@purbon purbon left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution! I appreciate it a ton! left only small cosmetic comments 👍

@purbon purbon linked an issue May 5, 2021 that may be closed by this pull request
@purbon
Copy link
Collaborator

purbon commented May 5, 2021 via email

@MagnusSmith
Copy link
Contributor Author

MagnusSmith commented May 5, 2021

@purbon In the Producer and Consumer class I see Optional field values. I think these could be better expressed by for example

public class Producer extends User {

  @JsonProperty("transactionId")
  String transactionId;

...

  @JsonIgnore
  public Optional<String> getTransactionId() {
    return Optional.ofNullable(transactionId);
  }
  
  public void setTransactionId(String transactionId) {
    this.transactionId = transactionId;
  }

What do you think?

@purbon
Copy link
Collaborator

purbon commented May 7, 2021

I wonder about your proposal in the use of JsonProperty and JsonIgnore, can you explain why you use them? thanks a lot

@MagnusSmith
Copy link
Contributor Author

I wonder about your proposal in the use of JsonProperty and JsonIgnore, can you explain why you use them? thanks a lot

It allows to separate the underlying instance variable from the getter by telling jackson to map the instance variable rather than the getter/setter. This allows us to keep the Optional getter but removes the need for Optional parameters which tend to be bad because they cause the caller to do unnecessary boxing, can still be null anyway, and don't work well with higher order functions forcing the caller to fallback to if statements. This might be something to consider later on as part of a wider code style refactoring.

@purbon
Copy link
Collaborator

purbon commented May 12, 2021

nice, we can certainly do this in a clean-up! do you mind doing a new PR with this, and might be other nice improvements? I will, for now, merge this one, thanks a lot.

@purbon purbon merged commit c039805 into kafka-ops:master May 12, 2021
@purbon
Copy link
Collaborator

purbon commented May 12, 2021

thanks a lot for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prefixed Group ACLs
2 participants