@@ -32,7 +32,7 @@ software.
32
32
33
33
#### Note:
34
34
35
- In order to better align with our newly adopted Code of Conduct, the kafka-go project has renamed our default branch to ` main ` .
35
+ In order to better align with our newly adopted Code of Conduct, the kafka-go project has renamed our default branch to ` main ` .
36
36
For the full details of our Code Of Conduct see [ this] ( ./CODE_OF_CONDUCT.md ) document.
37
37
38
38
## Migrating to 0.4
@@ -625,18 +625,41 @@ if err != nil {
625
625
panic (err)
626
626
}
627
627
628
- dialer := &kafka.Dialer {
629
- Timeout : 10 * time.Second ,
630
- DualStack : true ,
628
+ // Transports are responsible for managing connection pools and other resources,
629
+ // it's generally best to create a few of these and share them across your
630
+ // application.
631
+ sharedTransport := &kafka.Transport {
631
632
SASLMechanism : mechanism,
632
633
}
633
634
634
- w := kafka.NewWriter (kafka.WriterConfig {
635
- Brokers : []string {" localhost:9093" },
636
- Topic : " topic-A" ,
637
- Balancer : &kafka.Hash {},
638
- Dialer : dialer,
639
- })
635
+ w := kafka.Writer {
636
+ Addr : kafka.TCP (" localhost:9092" ),
637
+ Topic : " topic-A" ,
638
+ Balancer : &kafka.Hash {},
639
+ Transport : sharedTransport,
640
+ }
641
+ ```
642
+
643
+ ### Client
644
+
645
+ ``` go
646
+ mechanism , err := scram.Mechanism (scram.SHA512 , " username" , " password" )
647
+ if err != nil {
648
+ panic (err)
649
+ }
650
+
651
+ // Transports are responsible for managing connection pools and other resources,
652
+ // it's generally best to create a few of these and share them across your
653
+ // application.
654
+ sharedTransport := &kafka.Transport {
655
+ SASLMechanism : mechanism,
656
+ }
657
+
658
+ client := &kafka.Client {
659
+ Addr : kafka.TCP (" localhost:9092" ),
660
+ Timeout : 10 * time.Second ,
661
+ Transport : sharedTransport,
662
+ }
640
663
```
641
664
642
665
#### Reading all messages within a time range
0 commit comments