mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 18:15:59 +08:00
fix: fix openim zk env set
Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
package kafka
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/IBM/sarama"
|
||||
|
||||
@@ -44,3 +46,20 @@ func getEnvOrConfig(envName string, configValue string) string {
|
||||
}
|
||||
return configValue
|
||||
}
|
||||
|
||||
// getKafkaAddrFromEnv returns the Kafka addresses combined from the KAFKA_ADDRESS and KAFKA_PORT environment variables.
|
||||
// If the environment variables are not set, it returns the fallback value.
|
||||
func getKafkaAddrFromEnv(fallback []string) []string {
|
||||
envAddr := os.Getenv("KAFKA_ADDRESS")
|
||||
envPort := os.Getenv("KAFKA_PORT")
|
||||
|
||||
if envAddr != "" && envPort != "" {
|
||||
addresses := strings.Split(envAddr, ",")
|
||||
for i, addr := range addresses {
|
||||
addresses[i] = fmt.Sprintf("%s:%s", addr, envPort)
|
||||
}
|
||||
return addresses
|
||||
}
|
||||
|
||||
return fallback
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user