You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 regels
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. }