1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
package aws_msk_iam_v2_test
import (
"context"
"crypto/tls"
"time"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/segmentio/kafka-go"
"github.com/segmentio/kafka-go/sasl/aws_msk_iam_v2"
)
func main() {
cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
panic(err)
}
mechanism := aws_msk_iam_v2.NewMechanism(cfg)
_ = kafka.ReaderConfig{
Brokers: []string{"https://localhost"},
GroupID: "some-consumer-group",
GroupTopics: []string{"some-topic"},
Dialer: &kafka.Dialer{
Timeout: 10 * time.Second,
DualStack: true,
SASLMechanism: mechanism,
TLS: &tls.Config{},
},
}
}
|