Skip to content

Commit c7774b4

Browse files
committed
refactor: simplify PostgreSQL connection initialization in postgres_client
1 parent dee17eb commit c7774b4

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

threadwinds-ingestion/internal/client/postgres_client.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,14 @@ func NewPostgresClient(cfg *config.TWConfig) (*PostgresClient, error) {
4141
db.SetMaxIdleConns(1)
4242
db.SetConnMaxLifetime(5 * time.Minute)
4343

44-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
45-
defer cancel()
46-
47-
if err := db.PingContext(ctx); err != nil {
44+
if err := db.Ping(); err != nil {
4845
db.Close()
4946
return nil, fmt.Errorf("failed to ping database: %w", err)
5047
}
5148

5249
catcher.Info("PostgreSQL connection established via native SQL", map[string]any{
5350
"host": cfg.DBHost,
5451
"port": cfg.DBPort,
55-
"db": cfg.DBName,
5652
})
5753

5854
return &PostgresClient{db: db}, nil

0 commit comments

Comments
 (0)