Skip to content

Commit

Permalink
Fix NewClient()
Browse files Browse the repository at this point in the history
  • Loading branch information
winebarrel committed Oct 2, 2024
1 parent 464dadb commit b5cc888
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions que.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,8 @@ type Client struct {
// TODO: add a way to specify default queueing options
}

// NewClient2 creates a new Client that uses the pgx pool.
//
// Deprecated: Use `NewClient` instead.
func NewClient2(pool *sql.DB) (*Client, error) {
// NewClient creates a new Client that uses the pgx pool.
func NewClient(pool *sql.DB) (*Client, error) {
stmtJobStats, err := pool.Prepare(sqlJobStats)
if err != nil {
return nil, err
Expand All @@ -226,11 +224,11 @@ func NewClient2(pool *sql.DB) (*Client, error) {
}, nil
}

// NewClient creates a new Client that uses the pgx pool. Returns nil if the initialization fails.
func NewClient(pool *sql.DB) *Client {
c, err := NewClient2(pool)
// MustNewClient creates a new Client that uses the pgx pool. Panic if the initialization fails.
func MustNewClient(pool *sql.DB) *Client {
c, err := NewClient(pool)
if err != nil {
return nil
panic(err)
}
return c
}
Expand Down
2 changes: 1 addition & 1 deletion que_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func openTestClientMaxConns(t testing.TB, maxConnections int) *Client {
db.SetMaxIdleConns(maxConnections)
// make lifetime sufficiently long
db.SetConnMaxLifetime(time.Duration(5 * time.Minute))
c, err := NewClient2(db)
c, err := NewClient(db)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit b5cc888

Please sign in to comment.