Skip to content

Commit

Permalink
fix_import_conn
Browse files Browse the repository at this point in the history
Signed-off-by: Song Gao <disxiaofei@163.com>
  • Loading branch information
Yisaer committed Oct 18, 2024
1 parent 343936b commit d396180
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/meta/yamlConfigMeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/lf-edge/ekuiper/v2/internal/pkg/store"
"github.com/lf-edge/ekuiper/v2/internal/pkg/util"
"github.com/lf-edge/ekuiper/v2/pkg/cast"
"github.com/lf-edge/ekuiper/v2/pkg/connection"
"github.com/lf-edge/ekuiper/v2/pkg/errorx"
"github.com/lf-edge/ekuiper/v2/pkg/kv"
"github.com/lf-edge/ekuiper/v2/pkg/replace"
Expand Down Expand Up @@ -768,6 +769,9 @@ func LoadConfigurations(configSets YamlConfigurationSet) YamlConfigurationSet {
continue
}
}
if err := connection.ReloadNamedConnection(); err != nil {
conf.Log.Errorf("reload connection config error: %s", err.Error())
}

Check warning on line 774 in internal/meta/yamlConfigMeta.go

View check run for this annotation

Codecov / codecov/patch

internal/meta/yamlConfigMeta.go#L773-L774

Added lines #L773 - L774 were not covered by tests
return configResponse
}

Expand Down Expand Up @@ -823,5 +827,8 @@ func LoadConfigurationsPartial(configSets YamlConfigurationSet) YamlConfiguratio
continue
}
}
if err := connection.ReloadNamedConnection(); err != nil {
conf.Log.Errorf("reload connection config error: %s", err.Error())
}

Check warning on line 832 in internal/meta/yamlConfigMeta.go

View check run for this annotation

Codecov / codecov/patch

internal/meta/yamlConfigMeta.go#L831-L832

Added lines #L831 - L832 were not covered by tests
return configResponse
}
4 changes: 4 additions & 0 deletions internal/server/yaml_import_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/lf-edge/ekuiper/v2/internal/service"
"github.com/lf-edge/ekuiper/v2/pkg/ast"
"github.com/lf-edge/ekuiper/v2/pkg/cast"
"github.com/lf-edge/ekuiper/v2/pkg/connection"
"github.com/lf-edge/ekuiper/v2/pkg/replace"
)

Expand Down Expand Up @@ -522,6 +523,9 @@ func importConfigurations(m *MetaConfiguration) error {
return err
}
}
if err := connection.ReloadNamedConnection(); err != nil {
conf.Log.Errorf("reload connection config error: %s", err.Error())
}

Check warning on line 528 in internal/server/yaml_import_export.go

View check run for this annotation

Codecov / codecov/patch

internal/server/yaml_import_export.go#L527-L528

Added lines #L527 - L528 were not covered by tests
return nil
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/connection/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func FetchConnection(ctx api.StreamContext, refId, typ string, props map[string]

// ReloadNamedConnection is called when server starts. It initializes all stored named connections
func ReloadNamedConnection() error {
globalConnectionManager.Lock()
defer globalConnectionManager.Unlock()
cfgs, err := conf.GetCfgFromKVStorage("connections", "", "")
if err != nil {
return err
Expand All @@ -126,6 +128,9 @@ func ReloadNamedConnection() error {
}
typ := names[1]
id := names[2]
if _, ok := globalConnectionManager.connectionPool[id]; ok {
continue
}
meta := &Meta{
ID: id,
Typ: typ,
Expand Down

0 comments on commit d396180

Please sign in to comment.