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

YQ Connector: YQ-2747: add timeout and ping to ydb connection manager #24

Merged
merged 1 commit into from
Jan 9, 2024
Merged
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
6 changes: 6 additions & 0 deletions app/server/datasource/rdbms/ydb/connection_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
logger *zap.Logger,
dsi *api_common.TDataSourceInstance,
) (rdbms_utils.Connection, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

Check warning on line 84 in app/server/datasource/rdbms/ydb/connection_manager.go

View check run for this annotation

Codecov / codecov/patch

app/server/datasource/rdbms/ydb/connection_manager.go#L83-L84

Added lines #L83 - L84 were not covered by tests

// TODO: add credentials (iam and basic) support
endpoint := common.EndpointToString(dsi.Endpoint)
dsn := sugar.DSN(endpoint, dsi.Database, dsi.UseTls)
Expand All @@ -95,6 +98,9 @@
}

conn := sql.OpenDB(ydbConn)
if err := conn.Ping(); err != nil {
return nil, fmt.Errorf("conn ping: %w", err)

Check warning on line 102 in app/server/datasource/rdbms/ydb/connection_manager.go

View check run for this annotation

Codecov / codecov/patch

app/server/datasource/rdbms/ydb/connection_manager.go#L101-L102

Added lines #L101 - L102 were not covered by tests
}

const (
maxIdleConns = 5
Expand Down