瀏覽代碼

export interceptor methods

Diego Alvarez 3 年之前
父節點
當前提交
a29994860e
共有 3 個文件被更改,包括 11 次插入11 次删除
  1. 2 2
      async_producer_test.go
  2. 3 3
      config.go
  3. 6 6
      interceptors.go

+ 2 - 2
async_producer_test.go

@@ -1235,7 +1235,7 @@ type appendInterceptor struct {
 	i int
 }
 
-func (b *appendInterceptor) onSend(msg *ProducerMessage) {
+func (b *appendInterceptor) OnSend(msg *ProducerMessage) {
 	if b.i < 0 {
 		panic("hey, the interceptor has failed")
 	}
@@ -1244,7 +1244,7 @@ func (b *appendInterceptor) onSend(msg *ProducerMessage) {
 	b.i++
 }
 
-func (b *appendInterceptor) onConsume(msg *ConsumerMessage) {
+func (b *appendInterceptor) OnConsume(msg *ConsumerMessage) {
 	if b.i < 0 {
 		panic("hey, the interceptor has failed")
 	}

+ 3 - 3
config.go

@@ -234,7 +234,7 @@ type Config struct {
 		// message for the first time. Interceptors allows to intercept and
 		// possible mutate the message before they are published to Kafka
 		// cluster. *ProducerMessage modified by the first interceptor's
-		// onSend() is passed to the second interceptor onSend(), and so on in
+		// OnSend() is passed to the second interceptor OnSend(), and so on in
 		// the interceptor chain.
 		Interceptors []ProducerInterceptor
 	}
@@ -403,8 +403,8 @@ type Config struct {
 		// Interceptors to be called just before the record is sent to the
 		// messages channel. Interceptors allows to intercept and possible
 		// mutate the message before they are returned to the client.
-		// *ConsumerMessage modified by the first interceptor's onConsume() is
-		// passed to the second interceptor onConsume(), and so on in the
+		// *ConsumerMessage modified by the first interceptor's OnConsume() is
+		// passed to the second interceptor OnConsume(), and so on in the
 		// interceptor chain.
 		Interceptors []ConsumerInterceptor
 	}

+ 6 - 6
interceptors.go

@@ -5,10 +5,10 @@ package sarama
 // https://cwiki.apache.org/confluence/display/KAFKA/KIP-42%3A+Add+Producer+and+Consumer+Interceptors#KIP42:AddProducerandConsumerInterceptors-Motivation
 type ProducerInterceptor interface {
 
-	// onSend is called when the producer message is intercepted. Please avoid
+	// OnSend is called when the producer message is intercepted. Please avoid
 	// modifying the message until it's safe to do so, as this is _not_ a copy
 	// of the message.
-	onSend(*ProducerMessage)
+	OnSend(*ProducerMessage)
 }
 
 // ConsumerInterceptor allows you to intercept (and possibly mutate) the records
@@ -16,10 +16,10 @@ type ProducerInterceptor interface {
 // https://cwiki.apache.org/confluence/display/KAFKA/KIP-42%3A+Add+Producer+and+Consumer+Interceptors#KIP42:AddProducerandConsumerInterceptors-Motivation
 type ConsumerInterceptor interface {
 
-	// onConsume is called when the consumed message is intercepted. Please
+	// OnConsume is called when the consumed message is intercepted. Please
 	// avoid modifying the message until it's safe to do so, as this is _not_ a
 	// copy of the message.
-	onConsume(*ConsumerMessage)
+	OnConsume(*ConsumerMessage)
 }
 
 func (msg *ProducerMessage) safelyApplyInterceptor(interceptor ProducerInterceptor) {
@@ -29,7 +29,7 @@ func (msg *ProducerMessage) safelyApplyInterceptor(interceptor ProducerIntercept
 		}
 	}()
 
-	interceptor.onSend(msg)
+	interceptor.OnSend(msg)
 }
 
 func (msg *ConsumerMessage) safelyApplyInterceptor(interceptor ConsumerInterceptor) {
@@ -39,5 +39,5 @@ func (msg *ConsumerMessage) safelyApplyInterceptor(interceptor ConsumerIntercept
 		}
 	}()
 
-	interceptor.onConsume(msg)
+	interceptor.OnConsume(msg)
 }