Skip to content

Commit bbbb66f

Browse files
pass active to list of jobs, formatting postgres locker
1 parent 64609f0 commit bbbb66f

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

looper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (l *Looper) AddJob(ctx context.Context, jobInput *Job) (err error) {
173173
Timeout: setDefaultDuration(jobInput.Timeout, time.Minute),
174174
WaitAfterSuccess: setDefaultDuration(jobInput.WaitAfterSuccess, time.Second),
175175
WaitAfterError: setDefaultDuration(jobInput.WaitAfterError, time.Second),
176-
Active: true,
176+
Active: jobInput.Active,
177177
BeforeJob: beforeJob,
178178
AfterJob: afterJob,
179179
AfterJobError: afterJobError,

postgresql.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@ const defaultTableName = "looper_lock"
1111

1212
// PostgresLocker provides an implementation of the Locker interface using
1313
// a PostgreSQL table for storage.
14-
func PostgresLocker(ctx context.Context, db *sql.DB, table string) (locker, error) {
15-
err := db.PingContext(ctx)
16-
if err != nil {
14+
func PostgresLocker(ctx context.Context, db *sql.DB, tableName string) (locker, error) {
15+
if err := db.PingContext(ctx); err != nil {
1716
return nil, fmt.Errorf("%w: %v", ErrFailedToConnectToLocker, err)
1817
}
1918

20-
if table == "" {
21-
table = defaultTableName
19+
if tableName == "" {
20+
tableName = defaultTableName
2221
}
22+
2323
// Ensure the lock table exists, create it if necessary
24-
err = createLockTable(ctx, db, table)
25-
if err != nil {
24+
if err := createLockTable(ctx, db, tableName); err != nil {
2625
return nil, err
2726
}
2827

2928
pl := &postgresLocker{
3029
db: db,
31-
table: table,
30+
table: tableName,
3231
}
3332

3433
return pl, nil

0 commit comments

Comments
 (0)