Skip to content

Commit

Permalink
check if cfg is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
diPhantxm committed Sep 20, 2024
1 parent fd4e78e commit 9cb16b5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions coordinator/provider/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,19 @@ func (qc *qdbCoordinator) watchRouters(ctx context.Context) {
}

func NewCoordinator(tlsconfig *tls.Config, db qdb.XQDB) (*qdbCoordinator, error) {
shards, err := config.LoadShardDataCfg(config.CoordinatorConfig().ShardDataCfg)
if err != nil {
return nil, err
}

for id, cfg := range shards.ShardsData {
if err := db.AddShard(context.TODO(), qdb.NewShard(id, cfg.Hosts)); err != nil {
if config.CoordinatorConfig().ShardDataCfg != "" {
shards, err := config.LoadShardDataCfg(config.CoordinatorConfig().ShardDataCfg)
if err != nil {
return nil, err
}

if shards != nil {
for id, cfg := range shards.ShardsData {
if err := db.AddShard(context.TODO(), qdb.NewShard(id, cfg.Hosts)); err != nil {
return nil, err
}
}
}
}

return &qdbCoordinator{
Expand Down

0 comments on commit 9cb16b5

Please sign in to comment.