fix: kafka tls config

This commit is contained in:
loveuer
2025-04-07 15:44:24 +08:00
parent 2e13671bb7
commit b8905b53f9
4 changed files with 37 additions and 25 deletions

View File

@ -2,6 +2,7 @@ package kafka
import (
"context"
"os"
"os/signal"
"syscall"
"testing"
@ -16,9 +17,14 @@ func TestKafka(t *testing.T) {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
defer cancel()
client, err := New("10.220.10.15:9092",
address := os.Getenv("TARGET")
password := os.Getenv("PASSWORD")
t.Logf("address = %s, password = %s", address, password)
client, err := New(address,
WithTopic("test_zyp"),
WithPlainAuth("admin", "Yhblsqt@!."),
WithPlainAuth("admin", password),
WithReconnection(),
)
if err != nil {
@ -42,9 +48,14 @@ func TestKafka(t *testing.T) {
func TestKafkaWrite(t *testing.T) {
log.SetLogLevel(log.LogLevelDebug)
client, err := New("10.220.10.15:9092",
address := os.Getenv("TARGET")
password := os.Getenv("PASSWORD")
t.Logf("address = %s, password = %s", address, password)
client, err := New(address,
WithTopic("test_zyp"),
WithPlainAuth("admin", "Yhblsqt@!."),
WithPlainAuth("admin", password),
WithReconnection(),
)
if err != nil {