-
Notifications
You must be signed in to change notification settings - Fork 48
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. If I understand correctly, sql.Conn
is part of Go 1.9, yes?
// truncate to the microsecond as postgres driver does | ||
want = want.Truncate(time.Microsecond) | ||
// truncate to the Second as postgres driver does | ||
want = want.Truncate(time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
Time: j.RunAt, | ||
Valid: !j.RunAt.IsZero(), | ||
runAt := sql.NullString{ | ||
String: j.RunAt.Format(time.RFC3339), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use time.RFC3339Nano
to include microseconds here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbandy yes I'll change it. If time.RFC3339Nano
is used here, I guess there is no need of truncating it to second in the tests.
conn := newConn() | ||
i := 0 | ||
for { | ||
var waiting bool | ||
err := conn.QueryRow(`SELECT pg_stat_get_backend_waiting($1)`, backendID).Scan(&waiting) | ||
err := conn.QueryRowContext(context.Background(), `SELECT waiting from pg_stat_activity where pid=$1`, backendID).Scan(&waiting) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using postgresql 9.6 and pg_stat_get_backend_waiting
doesn't seem to exist in 9.6.
|
||
mu sync.Mutex | ||
deleted bool | ||
pool *pgx.ConnPool | ||
conn *pgx.Conn | ||
db *sql.DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't mind this still being named pool
. Newcomers to the database/sql
package often do not recognize that *sql.DB
is a connection pool. (Keeping it as pool
would also reduce the size of this diff.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -121,14 +121,14 @@ func (j *Job) Error(msg string) error { | |||
// Client is a Que client that can add jobs to the queue and remove jobs from | |||
// the queue. | |||
type Client struct { | |||
pool *pgx.ConnPool | |||
db *sql.DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with pool
here as well.
@@ -121,14 +121,14 @@ func (j *Job) Error(msg string) error { | |||
// Client is a Que client that can add jobs to the queue and remove jobs from | |||
// the queue. | |||
type Client struct { | |||
pool *pgx.ConnPool | |||
db *sql.DB | |||
|
|||
// TODO: add a way to specify default queueing options | |||
} | |||
|
|||
// NewClient creates a new Client that uses the pgx pool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove "pgx" here.
... that uses the connection pool.
pool *pgx.ConnPool | ||
conn *pgx.Conn | ||
db *sql.DB | ||
conn *sql.Conn | ||
} | ||
|
||
// Conn returns the pgx connection that this job is locked to. You may initiate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove "pgx" here.
Conn returns the connection that this job ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@aravindc26 thanks for submitting this! I have a few questions before I review it.
I realized I hadn't yet tagged any releases on this repo, so I just tagged |
@bgentry There are some differences in API between Completely removing pgx support would mean that one cannot use ConnPool's
Sure I can work on them 👍 |
If you're saying that you've entirely removed the use of prepared statements in this PR (which is what it appears like at a glance), that's probably a no-go. When I was writing this lib, there was a dramatic difference in perf once prepared statements were added (likely bc the Que SQL statements are fairly complex). |
@bgentry if there is dramatic difference in performance, it does not make sense to move to database/sql; Closing the PR. |
Would you accept a PR if I were to upgrade the pgx dependency to v3 ? |
Absolutely!
…On Tue, Aug 1, 2017 at 7:01 AM Aravind Chintalapalli < ***@***.***> wrote:
Would you accept a PR if I were to upgrade the pgx dependency to v3 ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAG9cTzF2grPBFYdQEwZFKirWk40rqmgks5sTy-XgaJpZM4OmY4o>
.
|
Since go 1.9's database/sql interface allows you grab an individual connection, I have removed pgx dependency.