Skip to content

Commit

Permalink
Revert "feat: implement db query timeout (#2167)" (#2169)
Browse files Browse the repository at this point in the history
This reverts commit f10ee33.
  • Loading branch information
nick-bisonai authored Aug 21, 2024
1 parent f10ee33 commit e0652e6
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions node/pkg/db/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"strings"
"sync"
"time"

errorSentinel "bisonai.com/orakl/node/pkg/error"
"bisonai.com/orakl/node/pkg/secrets"
Expand All @@ -15,8 +14,6 @@ import (
"github.com/rs/zerolog/log"
)

const BasicTimeout = 10 * time.Second

// singleton pattern
// make sure env is loaded from main before calling this
var (
Expand Down Expand Up @@ -103,9 +100,7 @@ func QueryRows[T any](ctx context.Context, queryString string, args map[string]a
}

func query(ctx context.Context, pool *pgxpool.Pool, query string, args map[string]any) (pgx.Rows, error) {
ctxWithTimeout, cancel := context.WithTimeout(ctx, BasicTimeout)
defer cancel()
return pool.Query(ctxWithTimeout, query, pgx.NamedArgs(args))
return pool.Query(ctx, query, pgx.NamedArgs(args))
}

func queryRow[T any](ctx context.Context, pool *pgxpool.Pool, queryString string, args map[string]any) (T, error) {
Expand Down Expand Up @@ -368,15 +363,9 @@ func GetTransientPool(ctx context.Context, connectionString string) (*pgxpool.Po
}

func QueryRowTransient[T any](ctx context.Context, pool *pgxpool.Pool, queryString string, args map[string]any) (T, error) {
ctxWithTimeout, cancel := context.WithTimeout(ctx, BasicTimeout)
defer cancel()

return queryRow[T](ctxWithTimeout, pool, queryString, args)
return queryRow[T](ctx, pool, queryString, args)
}

func QueryRowsTransient[T any](ctx context.Context, pool *pgxpool.Pool, queryString string, args map[string]any) ([]T, error) {
ctxWithTimeout, cancel := context.WithTimeout(ctx, BasicTimeout)
defer cancel()

return queryRows[T](ctxWithTimeout, pool, queryString, args)
return queryRows[T](ctx, pool, queryString, args)
}

0 comments on commit e0652e6

Please sign in to comment.