Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 0 additions & 7 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ linters:
excludes:
- G404 # use of non-crypto random; overly broad for our use case

modernize:
disable:
# Keep the Go 1.26 upgrade focused; apply its modernizations separately.
- errorsastype
- newexpr
- stditerators

revive:
rules:
- name: unused-parameter
Expand Down
193 changes: 96 additions & 97 deletions client_test.go

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions cmd/river/rivercli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (

"github.com/jackc/pgx/v5/pgxpool"
_ "modernc.org/sqlite"

"github.com/riverqueue/river/rivershared/util/ptrutil"
)

// Command is an interface to a River CLI subcommand. Commands generally only
Expand Down Expand Up @@ -68,7 +66,7 @@ func RunCommand[TOpts CommandOpts](ctx context.Context, bundle *RunCommandBundle
urlWithoutProtocol string
)
if pgEnvConfigured() {
databaseURL = ptrutil.Ptr("")
databaseURL = new("")
protocol = "postgres"
} else if bundle.DatabaseURL != nil {
databaseURL = bundle.DatabaseURL
Expand Down
11 changes: 5 additions & 6 deletions internal/dblist/db_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/riverqueue/river/riverdriver"
"github.com/riverqueue/river/riverdriver/riverpgxv5"
"github.com/riverqueue/river/rivershared/testfactory"
"github.com/riverqueue/river/rivershared/util/ptrutil"
"github.com/riverqueue/river/rivershared/util/sliceutil"
"github.com/riverqueue/river/rivertype"
)
Expand Down Expand Up @@ -93,11 +92,11 @@ func TestJobListWithJobs(t *testing.T) {
exec = driver.UnwrapExecutor(tx)
)

job1 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Queue: ptrutil.Ptr("priority"), Priority: ptrutil.Ptr(1)})
job2 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{EncodedArgs: []byte(`{"job_num": 2}`), Priority: ptrutil.Ptr(2)})
job3 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Metadata: []byte(`{"some_key": "some_value"}`), Priority: ptrutil.Ptr(3)})
job4 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{State: ptrutil.Ptr(rivertype.JobStateRunning), Priority: ptrutil.Ptr(1)})
job5 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Kind: ptrutil.Ptr("alternate_kind"), Priority: ptrutil.Ptr(2)})
job1 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Queue: new("priority"), Priority: new(1)})
job2 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{EncodedArgs: []byte(`{"job_num": 2}`), Priority: new(2)})
job3 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Metadata: []byte(`{"some_key": "some_value"}`), Priority: new(3)})
job4 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{State: new(rivertype.JobStateRunning), Priority: new(1)})
job5 := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Kind: new("alternate_kind"), Priority: new(2)})

return &testBundle{
baselineTime: time.Now(),
Expand Down
3 changes: 1 addition & 2 deletions internal/dbunique/db_unique_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/riverqueue/river/rivershared/riversharedtest"
"github.com/riverqueue/river/rivershared/uniquestates"
"github.com/riverqueue/river/rivershared/util/ptrutil"
"github.com/riverqueue/river/rivertype"
)

Expand Down Expand Up @@ -420,7 +419,7 @@ func TestUniqueKey(t *testing.T) {
}
},
modifyInsertParamsFunc: func(insertParams *rivertype.JobInsertParams) {
insertParams.ScheduledAt = ptrutil.Ptr(now.Add(time.Hour))
insertParams.ScheduledAt = new(now.Add(time.Hour))
},
uniqueOpts: UniqueOpts{ByPeriod: time.Hour},
expectedJSON: "&kind=worker_4&period=" + now.Add(time.Hour).Truncate(time.Hour).Format(time.RFC3339),
Expand Down
41 changes: 20 additions & 21 deletions internal/jobcompleter/job_completer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/riverqueue/river/rivershared/riversharedtest"
"github.com/riverqueue/river/rivershared/startstop"
"github.com/riverqueue/river/rivershared/testfactory"
"github.com/riverqueue/river/rivershared/util/ptrutil"
"github.com/riverqueue/river/rivertype"
)

Expand Down Expand Up @@ -905,9 +904,9 @@ func testCompleter[TCompleter JobCompleter](
finalizedAt2 = time.Now().UTC().Add(-2 * time.Minute)
finalizedAt3 = time.Now().UTC().Add(-3 * time.Minute)

job1 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job2 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job3 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job1 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job2 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job3 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
)

require.NoError(t, completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job1.ID, finalizedAt1, nil)))
Expand Down Expand Up @@ -1036,14 +1035,14 @@ func testCompleter[TCompleter JobCompleter](
completer, bundle := setup(t)

var (
job1 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job2 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job3 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job4 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job5 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job6 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job7 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job8 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job1 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job2 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job3 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job4 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job5 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job6 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job7 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job8 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
)

require.NoError(t, completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCancelled(job1.ID, time.Now(), []byte("{}"), nil)))
Expand Down Expand Up @@ -1073,9 +1072,9 @@ func testCompleter[TCompleter JobCompleter](
completer, bundle := setup(t)

var (
job1 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job2 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job3 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job1 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job2 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
job3 = testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})
)

require.NoError(t, completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job1.ID, time.Now(), nil)))
Expand Down Expand Up @@ -1123,7 +1122,7 @@ func testCompleter[TCompleter JobCompleter](
completer, bundle := setup(t)

{
job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})

require.NoError(t, completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job.ID, time.Now(), nil)))

Expand All @@ -1138,7 +1137,7 @@ func testCompleter[TCompleter JobCompleter](
{
require.NoError(t, completer.Start(ctx))

job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})

require.NoError(t, completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job.ID, time.Now(), nil)))

Expand Down Expand Up @@ -1178,7 +1177,7 @@ func testCompleter[TCompleter JobCompleter](
}
setExec(completer, execMock)

job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})

require.NoError(t, completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job.ID, time.Now(), nil)))

Expand Down Expand Up @@ -1206,7 +1205,7 @@ func testCompleter[TCompleter JobCompleter](
}
setExec(completer, execMock)

job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})

err := completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job.ID, time.Now(), nil))

Expand Down Expand Up @@ -1239,7 +1238,7 @@ func testCompleter[TCompleter JobCompleter](
}
setExec(completer, execMock)

job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job := testfactory.Job(ctx, t, bundle.exec, &testfactory.JobOpts{Schema: bundle.schema, State: new(rivertype.JobStateRunning)})

err := completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job.ID, time.Now(), nil))

Expand Down Expand Up @@ -1455,7 +1454,7 @@ func doContinuousInsertionInterval(ctx context.Context, t *testing.T, completer
}()

for {
job := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Schema: schema, State: ptrutil.Ptr(rivertype.JobStateRunning)})
job := testfactory.Job(ctx, t, exec, &testfactory.JobOpts{Schema: schema, State: new(rivertype.JobStateRunning)})
require.NoError(t, completer.JobSetStateIfRunning(ctx, &jobstats.JobStatistics{}, riverdriver.JobSetStateCompleted(job.ID, time.Now(), nil)))
numInserted.Add(1)

Expand Down
11 changes: 5 additions & 6 deletions internal/jobexecutor/job_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/riverqueue/river/rivershared/riverpilot"
"github.com/riverqueue/river/rivershared/riversharedtest"
"github.com/riverqueue/river/rivershared/testfactory"
"github.com/riverqueue/river/rivershared/util/ptrutil"
"github.com/riverqueue/river/rivertype"
)

Expand Down Expand Up @@ -152,7 +151,7 @@ func TestJobExecutor_Execute(t *testing.T) {
// Needs to be explicitly set to a "now" horizon that's aligned with the
// JobGetAvailable call. InsertMany applies a default scheduled_at in Go
// so it can't pick up the Postgres-level `now()` default.
ScheduledAt: ptrutil.Ptr(now),
ScheduledAt: new(now),
State: rivertype.JobStateAvailable,
},
},
Expand All @@ -162,7 +161,7 @@ func TestJobExecutor_Execute(t *testing.T) {
// Fetch the job to make sure it's marked as running:
jobs, err := exec.JobGetAvailable(ctx, &riverdriver.JobGetAvailableParams{
MaxToLock: 1,
Now: ptrutil.Ptr(now),
Now: new(now),
Queue: rivercommon.QueueDefault,
})
require.NoError(t, err)
Expand Down Expand Up @@ -664,9 +663,9 @@ func TestJobExecutor_Execute(t *testing.T) {
now := time.Now().UTC()
_, err := exec.JobInsertFullMany(ctx, &riverdriver.JobInsertFullManyParams{
Jobs: []*riverdriver.JobInsertFullParams{
testfactory.Job_Build(t, &testfactory.JobOpts{Kind: ptrutil.Ptr("jobexecutor_test"), ScheduledAt: &now}),
testfactory.Job_Build(t, &testfactory.JobOpts{Kind: ptrutil.Ptr("jobexecutor_test"), ScheduledAt: &now}),
testfactory.Job_Build(t, &testfactory.JobOpts{Kind: ptrutil.Ptr("jobexecutor_test"), ScheduledAt: &now}),
testfactory.Job_Build(t, &testfactory.JobOpts{Kind: new("jobexecutor_test"), ScheduledAt: &now}),
testfactory.Job_Build(t, &testfactory.JobOpts{Kind: new("jobexecutor_test"), ScheduledAt: &now}),
testfactory.Job_Build(t, &testfactory.JobOpts{Kind: new("jobexecutor_test"), ScheduledAt: &now}),
},
})
require.NoError(t, err)
Expand Down
13 changes: 6 additions & 7 deletions internal/leadership/elector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/riverqueue/river/rivershared/startstoptest"
"github.com/riverqueue/river/rivershared/testfactory"
"github.com/riverqueue/river/rivershared/util/dbutil"
"github.com/riverqueue/river/rivershared/util/ptrutil"
"github.com/riverqueue/river/rivertype"
)

Expand Down Expand Up @@ -275,9 +274,9 @@ func TestElectorRunLeaderState(t *testing.T) {
elector.publishLeadershipState(true)

leader := testfactory.Leader(ctx, t, exec, &testfactory.LeaderOpts{
ElectedAt: ptrutil.Ptr(initialNow),
ExpiresAt: ptrutil.Ptr(initialNow.Add(elector.leaderTTL())),
LeaderID: ptrutil.Ptr(elector.config.ClientID),
ElectedAt: new(initialNow),
ExpiresAt: new(initialNow.Add(elector.leaderTTL())),
LeaderID: new(elector.config.ClientID),
})

elector.exec = &leaderReelectExecutorMock{
Expand Down Expand Up @@ -318,9 +317,9 @@ func TestElectorRunLeaderState(t *testing.T) {
elector.publishLeadershipState(true)

leader := testfactory.Leader(ctx, t, exec, &testfactory.LeaderOpts{
ElectedAt: ptrutil.Ptr(initialNow),
ExpiresAt: ptrutil.Ptr(initialNow.Add(elector.leaderTTL())),
LeaderID: ptrutil.Ptr(elector.config.ClientID),
ElectedAt: new(initialNow),
ExpiresAt: new(initialNow.Add(elector.leaderTTL())),
LeaderID: new(elector.config.ClientID),
})

var numAttempts int
Expand Down
Loading
Loading