@@ -63,7 +63,7 @@ type noOpWorker struct {
63
63
WorkerDefaults [noOpArgs ]
64
64
}
65
65
66
- func (w * noOpWorker ) Work (ctx context.Context , j * Job [noOpArgs ]) error { return nil }
66
+ func (w * noOpWorker ) Work (ctx context.Context , job * Job [noOpArgs ]) error { return nil }
67
67
68
68
type periodicJobArgs struct {}
69
69
@@ -73,18 +73,18 @@ type periodicJobWorker struct {
73
73
WorkerDefaults [periodicJobArgs ]
74
74
}
75
75
76
- func (w * periodicJobWorker ) Work (ctx context.Context , j * Job [periodicJobArgs ]) error {
76
+ func (w * periodicJobWorker ) Work (ctx context.Context , job * Job [periodicJobArgs ]) error {
77
77
return nil
78
78
}
79
79
80
80
type callbackFunc func (context.Context , * Job [callbackArgs ]) error
81
81
82
82
func makeAwaitCallback (startedCh chan <- int64 , doneCh chan struct {}) callbackFunc {
83
- return func (ctx context.Context , j * Job [callbackArgs ]) error {
83
+ return func (ctx context.Context , job * Job [callbackArgs ]) error {
84
84
select {
85
85
case <- ctx .Done ():
86
86
return ctx .Err ()
87
- case startedCh <- j .ID :
87
+ case startedCh <- job .ID :
88
88
}
89
89
90
90
// await done signal, or context cancellation:
@@ -108,8 +108,8 @@ type callbackWorker struct {
108
108
fn callbackFunc
109
109
}
110
110
111
- func (w * callbackWorker ) Work (ctx context.Context , j * Job [callbackArgs ]) error {
112
- return w .fn (ctx , j )
111
+ func (w * callbackWorker ) Work (ctx context.Context , job * Job [callbackArgs ]) error {
112
+ return w .fn (ctx , job )
113
113
}
114
114
115
115
func newTestConfig (t * testing.T , callback callbackFunc ) * Config {
@@ -397,11 +397,11 @@ func Test_Client_Stop(t *testing.T) {
397
397
jobDoneChan := make (chan struct {})
398
398
jobStartedChan := make (chan int64 )
399
399
400
- callbackFunc := func (ctx context.Context , j * Job [callbackArgs ]) error {
400
+ callbackFunc := func (ctx context.Context , job * Job [callbackArgs ]) error {
401
401
select {
402
402
case <- ctx .Done ():
403
403
return ctx .Err ()
404
- case jobStartedChan <- j .ID :
404
+ case jobStartedChan <- job .ID :
405
405
}
406
406
407
407
select {
@@ -446,9 +446,9 @@ func Test_Client_Stop(t *testing.T) {
446
446
t .Parallel ()
447
447
448
448
startedCh := make (chan int64 )
449
- callbackFunc := func (ctx context.Context , j * Job [callbackArgs ]) error {
449
+ callbackFunc := func (ctx context.Context , job * Job [callbackArgs ]) error {
450
450
select {
451
- case startedCh <- j .ID :
451
+ case startedCh <- job .ID :
452
452
default :
453
453
}
454
454
return nil
@@ -473,7 +473,7 @@ func Test_Client_Stop(t *testing.T) {
473
473
t .Run ("WithSubscriber" , func (t * testing.T ) {
474
474
t .Parallel ()
475
475
476
- callbackFunc := func (ctx context.Context , j * Job [callbackArgs ]) error { return nil }
476
+ callbackFunc := func (ctx context.Context , job * Job [callbackArgs ]) error { return nil }
477
477
478
478
client := runNewTestClient (ctx , t , newTestConfig (t , callbackFunc ))
479
479
@@ -503,14 +503,14 @@ func Test_Client_StopAndCancel(t *testing.T) {
503
503
jobDoneChan := make (chan struct {})
504
504
jobStartedChan := make (chan int64 )
505
505
506
- callbackFunc := func (ctx context.Context , j * Job [callbackArgs ]) error {
506
+ callbackFunc := func (ctx context.Context , job * Job [callbackArgs ]) error {
507
507
defer close (jobDoneChan )
508
508
509
509
// indicate the job has started, unless context is already done:
510
510
select {
511
511
case <- ctx .Done ():
512
512
return ctx .Err ()
513
- case jobStartedChan <- j .ID :
513
+ case jobStartedChan <- job .ID :
514
514
}
515
515
516
516
t .Logf ("Job waiting for context cancellation" )
@@ -571,12 +571,12 @@ type callbackWorkerWithCustomTimeout struct {
571
571
fn func (context.Context , * Job [callbackWithCustomTimeoutArgs ]) error
572
572
}
573
573
574
- func (w * callbackWorkerWithCustomTimeout ) Work (ctx context.Context , j * Job [callbackWithCustomTimeoutArgs ]) error {
575
- return w .fn (ctx , j )
574
+ func (w * callbackWorkerWithCustomTimeout ) Work (ctx context.Context , job * Job [callbackWithCustomTimeoutArgs ]) error {
575
+ return w .fn (ctx , job )
576
576
}
577
577
578
- func (w * callbackWorkerWithCustomTimeout ) Timeout (j * Job [callbackWithCustomTimeoutArgs ]) time.Duration {
579
- return j .Args .TimeoutValue
578
+ func (w * callbackWorkerWithCustomTimeout ) Timeout (job * Job [callbackWithCustomTimeoutArgs ]) time.Duration {
579
+ return job .Args .TimeoutValue
580
580
}
581
581
582
582
func Test_Client_JobContextInheritsFromProvidedContext (t * testing.T ) {
@@ -589,7 +589,7 @@ func Test_Client_JobContextInheritsFromProvidedContext(t *testing.T) {
589
589
doneCh := make (chan struct {})
590
590
close (doneCh )
591
591
592
- callbackFunc := func (ctx context.Context , j * Job [callbackWithCustomTimeoutArgs ]) error {
592
+ callbackFunc := func (ctx context.Context , job * Job [callbackWithCustomTimeoutArgs ]) error {
593
593
// indicate the job has started, unless context is already done:
594
594
select {
595
595
case <- ctx .Done ():
@@ -1073,7 +1073,7 @@ func Test_Client_ErrorHandler(t *testing.T) {
1073
1073
t .Parallel ()
1074
1074
1075
1075
handlerErr := fmt .Errorf ("job error" )
1076
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1076
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1077
1077
return handlerErr
1078
1078
})
1079
1079
@@ -1127,7 +1127,7 @@ func Test_Client_ErrorHandler(t *testing.T) {
1127
1127
t .Run ("PanicHandler" , func (t * testing.T ) {
1128
1128
t .Parallel ()
1129
1129
1130
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1130
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1131
1131
panic ("panic val" )
1132
1132
})
1133
1133
@@ -1459,7 +1459,7 @@ func Test_Client_RetryPolicy(t *testing.T) {
1459
1459
t .Run ("RetryUntilDiscarded" , func (t * testing.T ) {
1460
1460
t .Parallel ()
1461
1461
1462
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1462
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1463
1463
return fmt .Errorf ("job error" )
1464
1464
})
1465
1465
@@ -1583,8 +1583,8 @@ func Test_Client_Subscribe(t *testing.T) {
1583
1583
1584
1584
// Fail/succeed jobs based on their name so we can get a mix of both to
1585
1585
// verify.
1586
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1587
- if strings .HasPrefix (j .Args .Name , "failed" ) {
1586
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1587
+ if strings .HasPrefix (job .Args .Name , "failed" ) {
1588
1588
return fmt .Errorf ("job error" )
1589
1589
}
1590
1590
return nil
@@ -1649,8 +1649,8 @@ func Test_Client_Subscribe(t *testing.T) {
1649
1649
t .Run ("CompletedOnly" , func (t * testing.T ) {
1650
1650
t .Parallel ()
1651
1651
1652
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1653
- if strings .HasPrefix (j .Args .Name , "failed" ) {
1652
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1653
+ if strings .HasPrefix (job .Args .Name , "failed" ) {
1654
1654
return fmt .Errorf ("job error" )
1655
1655
}
1656
1656
return nil
@@ -1690,8 +1690,8 @@ func Test_Client_Subscribe(t *testing.T) {
1690
1690
t .Run ("FailedOnly" , func (t * testing.T ) {
1691
1691
t .Parallel ()
1692
1692
1693
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1694
- if strings .HasPrefix (j .Args .Name , "failed" ) {
1693
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1694
+ if strings .HasPrefix (job .Args .Name , "failed" ) {
1695
1695
return fmt .Errorf ("job error" )
1696
1696
}
1697
1697
return nil
@@ -1731,7 +1731,7 @@ func Test_Client_Subscribe(t *testing.T) {
1731
1731
t .Run ("EventsDropWithNoListeners" , func (t * testing.T ) {
1732
1732
t .Parallel ()
1733
1733
1734
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1734
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1735
1735
return nil
1736
1736
})
1737
1737
@@ -1775,7 +1775,7 @@ func Test_Client_Subscribe(t *testing.T) {
1775
1775
t .Run ("PanicOnUnknownKind" , func (t * testing.T ) {
1776
1776
t .Parallel ()
1777
1777
1778
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1778
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1779
1779
return nil
1780
1780
})
1781
1781
@@ -1789,7 +1789,7 @@ func Test_Client_Subscribe(t *testing.T) {
1789
1789
t .Run ("SubscriptionCancellation" , func (t * testing.T ) {
1790
1790
t .Parallel ()
1791
1791
1792
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1792
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1793
1793
return nil
1794
1794
})
1795
1795
@@ -1883,7 +1883,7 @@ func Test_Client_JobCompletion(t *testing.T) {
1883
1883
t .Parallel ()
1884
1884
1885
1885
require := require .New (t )
1886
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1886
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1887
1887
return nil
1888
1888
})
1889
1889
@@ -1909,8 +1909,8 @@ func Test_Client_JobCompletion(t *testing.T) {
1909
1909
require := require .New (t )
1910
1910
var dbPool * pgxpool.Pool
1911
1911
now := time .Now ().UTC ()
1912
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1913
- _ , err := queries .JobSetCompleted (ctx , dbPool , dbsqlc.JobSetCompletedParams {ID : j .ID , FinalizedAt : now })
1912
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1913
+ _ , err := queries .JobSetCompleted (ctx , dbPool , dbsqlc.JobSetCompletedParams {ID : job .ID , FinalizedAt : now })
1914
1914
require .NoError (err )
1915
1915
return nil
1916
1916
})
@@ -1936,7 +1936,7 @@ func Test_Client_JobCompletion(t *testing.T) {
1936
1936
t .Parallel ()
1937
1937
1938
1938
require := require .New (t )
1939
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1939
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1940
1940
return errors .New ("oops" )
1941
1941
})
1942
1942
@@ -1961,7 +1961,7 @@ func Test_Client_JobCompletion(t *testing.T) {
1961
1961
t .Parallel ()
1962
1962
1963
1963
require := require .New (t )
1964
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1964
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1965
1965
return JobCancel (errors .New ("oops" ))
1966
1966
})
1967
1967
@@ -1988,9 +1988,9 @@ func Test_Client_JobCompletion(t *testing.T) {
1988
1988
require := require .New (t )
1989
1989
var dbPool * pgxpool.Pool
1990
1990
now := time .Now ().UTC ()
1991
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
1991
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
1992
1992
_ , err := queries .JobSetDiscarded (ctx , dbPool , dbsqlc.JobSetDiscardedParams {
1993
- ID : j .ID ,
1993
+ ID : job .ID ,
1994
1994
Error : []byte ("{\" error\" : \" oops\" }" ),
1995
1995
FinalizedAt : now ,
1996
1996
})
@@ -2023,11 +2023,11 @@ func Test_Client_JobCompletion(t *testing.T) {
2023
2023
now := time .Now ().UTC ()
2024
2024
var updatedJob * Job [callbackArgs ]
2025
2025
2026
- config := newTestConfig (t , func (ctx context.Context , j * Job [callbackArgs ]) error {
2026
+ config := newTestConfig (t , func (ctx context.Context , job * Job [callbackArgs ]) error {
2027
2027
tx , err := dbPool .Begin (ctx )
2028
2028
require .NoError (err )
2029
2029
2030
- updatedJob , err = JobCompleteTx [* riverpgxv5.Driver ](ctx , tx , j )
2030
+ updatedJob , err = JobCompleteTx [* riverpgxv5.Driver ](ctx , tx , job )
2031
2031
require .NoError (err )
2032
2032
2033
2033
return tx .Commit (ctx )
@@ -2150,8 +2150,8 @@ func Test_NewClient_ClientIDWrittenToJobAttemptedByWhenFetched(t *testing.T) {
2150
2150
doneCh := make (chan struct {})
2151
2151
startedCh := make (chan * Job [callbackArgs ])
2152
2152
2153
- callback := func (ctx context.Context , j * Job [callbackArgs ]) error {
2154
- startedCh <- j
2153
+ callback := func (ctx context.Context , job * Job [callbackArgs ]) error {
2154
+ startedCh <- job
2155
2155
<- doneCh
2156
2156
return nil
2157
2157
}
@@ -2529,8 +2529,8 @@ type timeoutTestWorker struct {
2529
2529
doneCh chan testWorkerDeadline
2530
2530
}
2531
2531
2532
- func (w * timeoutTestWorker ) Timeout (j * Job [timeoutTestArgs ]) time.Duration {
2533
- return j .Args .TimeoutValue
2532
+ func (w * timeoutTestWorker ) Timeout (job * Job [timeoutTestArgs ]) time.Duration {
2533
+ return job .Args .TimeoutValue
2534
2534
}
2535
2535
2536
2536
func (w * timeoutTestWorker ) Work (ctx context.Context , job * Job [timeoutTestArgs ]) error {
0 commit comments