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: add producer interceptor interface #145

Open
wants to merge 4 commits into
base: v2
Choose a base branch
from

Conversation

ademekici
Copy link
Contributor

No description provided.

@@ -18,10 +18,11 @@ type Writer interface {
}

type producer struct {
w Writer
w Writer
interceptor *ProducerInterceptor
Copy link
Member

Choose a reason for hiding this comment

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

It is not necessary to use interface pointer. I mean ProducerInterceptor is interface, no need to use *

}

func NewProducer(cfg *ProducerConfig) (Producer, error) {
func NewProducer(cfg *ProducerConfig, interceptor *ProducerInterceptor) (Producer, error) {
Copy link
Member

Choose a reason for hiding this comment

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

we can use interceptor ...ProducerInterceptor syntax.
In that way, client can use

  • NewProducer(producerConfig)
  • NewProducer(producerConfig, interceptor1)
  • NewProducer(producerConfig, interceptor1, interceptor2)

@@ -18,10 +18,11 @@ type Writer interface {
}

type producer struct {
w Writer
w Writer
interceptor *ProducerInterceptor
Copy link
Member

@Abdulsametileri Abdulsametileri Sep 19, 2024

Choose a reason for hiding this comment

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

I think we can support []ProducerInterceptor, in that way client could implement many interceptors if they want, what do you think?

XSourceAppValue = "kafka-konsumer"
)

func (i *MockProducerInterceptor) OnProduce(ctx kafka.ProducerInterceptorContext) {
Copy link
Member

Choose a reason for hiding this comment

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

I think, stubdata directory is not necessary, we can put this implementation on integration_test


// When
err := p.Produce(context.Background(), msg)
// Then
Copy link
Member

Choose a reason for hiding this comment

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

Formatting!: We need to put whitespace between 38 and 39

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.

2 participants