Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

23 lignes
450 B

  1. package kafkaclient
  2. import (
  3. "time"
  4. "github.com/segmentio/kafka-go"
  5. )
  6. // Create Kafka writer
  7. //
  8. // Deprecated: Use context manager object instead
  9. func KafkaWriter(kafkaURL, topic string) *kafka.Writer {
  10. return &kafka.Writer{
  11. Addr: kafka.TCP(kafkaURL),
  12. Topic: topic,
  13. Balancer: &kafka.LeastBytes{},
  14. Async: false,
  15. RequiredAcks: kafka.RequireAll,
  16. BatchSize: 100,
  17. BatchTimeout: 10 * time.Millisecond,
  18. }
  19. }