-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: v2
Are you sure you want to change the base?
Conversation
@@ -18,10 +18,11 @@ type Writer interface { | |||
} | |||
|
|||
type producer struct { | |||
w Writer | |||
w Writer | |||
interceptor *ProducerInterceptor |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
No description provided.