mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Add etcd as a service discovery mechanism
This commit is contained in:
parent
caf41c3e80
commit
5a6e774893
@ -139,28 +139,28 @@ func main() {
|
|||||||
func performChecks(ctx context.Context, mongoConfig *config.Mongo, redisConfig *config.Redis, kafkaConfig *config.Kafka, minioConfig *config.Minio, discovery *config.Discovery, maxRetry int) error {
|
func performChecks(ctx context.Context, mongoConfig *config.Mongo, redisConfig *config.Redis, kafkaConfig *config.Kafka, minioConfig *config.Minio, discovery *config.Discovery, maxRetry int) error {
|
||||||
checksDone := make(map[string]bool)
|
checksDone := make(map[string]bool)
|
||||||
|
|
||||||
checks := map[string]func() error{
|
checks := map[string]func(ctx context.Context) error{
|
||||||
"Mongo": func() error {
|
"Mongo": func(ctx context.Context) error {
|
||||||
return CheckMongo(ctx, mongoConfig)
|
return CheckMongo(ctx, mongoConfig)
|
||||||
},
|
},
|
||||||
"Redis": func() error {
|
"Redis": func(ctx context.Context) error {
|
||||||
return CheckRedis(ctx, redisConfig)
|
return CheckRedis(ctx, redisConfig)
|
||||||
},
|
},
|
||||||
"Kafka": func() error {
|
"Kafka": func(ctx context.Context) error {
|
||||||
return CheckKafka(ctx, kafkaConfig)
|
return CheckKafka(ctx, kafkaConfig)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if minioConfig != nil {
|
if minioConfig != nil {
|
||||||
checks["MinIO"] = func() error {
|
checks["MinIO"] = func(ctx context.Context) error {
|
||||||
return CheckMinIO(ctx, minioConfig)
|
return CheckMinIO(ctx, minioConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if discovery.Enable == "etcd" {
|
if discovery.Enable == "etcd" {
|
||||||
checks["Etcd"] = func() error {
|
checks["Etcd"] = func(ctx context.Context) error {
|
||||||
return CheckEtcd(ctx, &discovery.Etcd)
|
return CheckEtcd(ctx, &discovery.Etcd)
|
||||||
}
|
}
|
||||||
} else if discovery.Enable == "zookeeper" {
|
} else if discovery.Enable == "zookeeper" {
|
||||||
checks["Zookeeper"] = func() error {
|
checks["Zookeeper"] = func(ctx context.Context) error {
|
||||||
return CheckZookeeper(ctx, &discovery.ZooKeeper)
|
return CheckZookeeper(ctx, &discovery.ZooKeeper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ func performChecks(ctx context.Context, mongoConfig *config.Mongo, redisConfig *
|
|||||||
allSuccess := true
|
allSuccess := true
|
||||||
for name, check := range checks {
|
for name, check := range checks {
|
||||||
if !checksDone[name] {
|
if !checksDone[name] {
|
||||||
if err := check(); err != nil {
|
if err := check(ctx); err != nil {
|
||||||
fmt.Printf("%s check failed: %v\n", name, err)
|
fmt.Printf("%s check failed: %v\n", name, err)
|
||||||
allSuccess = false
|
allSuccess = false
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user