mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-14 22:15:59 +08:00
fix: Refactoring the code for component detection (#1868)
* feat: add component check func * fix: fix the outpu error * fix: fix the stderr outpu * fix: fix the component check func * fix: fix the error * fix: fix the output error * fix: del the disruptions code * fix the log output format * fix: fix the tools version
This commit is contained in:
Vendored
+3
-2
@@ -77,9 +77,10 @@ func NewRedis() (redis.UniversalClient, error) {
|
||||
defer cancel()
|
||||
err = rdb.Ping(ctx).Err()
|
||||
if err != nil {
|
||||
return nil, errs.Wrap(fmt.Errorf("redis ping %w", err))
|
||||
uriFormat := "address:%s, username:%s, password:%s, clusterMode:%t, enablePipeline:%t"
|
||||
errMsg := fmt.Sprintf(uriFormat, config.Config.Redis.Address, config.Config.Redis.Username, config.Config.Redis.Password, config.Config.Redis.ClusterMode, config.Config.Redis.EnablePipeline)
|
||||
return nil, errs.Wrap(err, errMsg)
|
||||
}
|
||||
|
||||
redisClient = rdb
|
||||
return rdb, err
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ func NewMongo() (*Mongo, error) {
|
||||
time.Sleep(time.Second) // exponential backoff could be implemented here
|
||||
continue
|
||||
}
|
||||
return nil, errs.Wrap(err)
|
||||
return nil, errs.Wrap(err, uri)
|
||||
}
|
||||
return nil, errs.Wrap(err)
|
||||
return nil, errs.Wrap(err, uri)
|
||||
}
|
||||
|
||||
func buildMongoURI() string {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -33,7 +35,7 @@ func NewZookeeperDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, er
|
||||
username := getEnv("ZOOKEEPER_USERNAME", config.Config.Zookeeper.Username)
|
||||
password := getEnv("ZOOKEEPER_PASSWORD", config.Config.Zookeeper.Password)
|
||||
|
||||
return openkeeper.NewClient(
|
||||
zk, err := openkeeper.NewClient(
|
||||
zkAddr,
|
||||
schema,
|
||||
openkeeper.WithFreq(time.Hour),
|
||||
@@ -42,6 +44,16 @@ func NewZookeeperDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, er
|
||||
openkeeper.WithTimeout(10),
|
||||
openkeeper.WithLogger(log.NewZkLogger()),
|
||||
)
|
||||
if err != nil {
|
||||
uriFormat := "address:%s, username :%s, password :%s, schema:%s."
|
||||
errInfo := fmt.Sprintf(uriFormat,
|
||||
config.Config.Zookeeper.ZkAddr,
|
||||
config.Config.Zookeeper.Username,
|
||||
config.Config.Zookeeper.Password,
|
||||
config.Config.Zookeeper.Schema)
|
||||
return nil, errs.Wrap(err, errInfo)
|
||||
}
|
||||
return zk, nil
|
||||
}
|
||||
|
||||
// getEnv returns the value of an environment variable if it exists, otherwise it returns the fallback value.
|
||||
|
||||
@@ -51,7 +51,7 @@ func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addrs []str
|
||||
SetupTLSConfig(consumerGroupConfig)
|
||||
consumerGroup, err := sarama.NewConsumerGroup(addrs, groupID, consumerGroupConfig)
|
||||
if err != nil {
|
||||
return nil, errs.Wrap(err, strings.Join(topics, ","), strings.Join(addrs, ","), groupID)
|
||||
return nil, errs.Wrap(err, strings.Join(topics, ","), strings.Join(addrs, ","), groupID, config.Config.Kafka.Username, config.Config.Kafka.Password)
|
||||
}
|
||||
return &MConsumerGroup{
|
||||
consumerGroup,
|
||||
|
||||
Reference in New Issue
Block a user