Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix import connection configuration #3308

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"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 @@
continue
}
}
if err := connection.ReloadNamedConnection(); err != nil {
ngjaying marked this conversation as resolved.
Show resolved Hide resolved
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 @@
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 @@
"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 @@
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
Loading