File size: 857 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package processinglock

import (
	"context"
	"database/sql"

	"github.com/jackc/pgx/v5"
	"github.com/riverqueue/river"
	"github.com/target/goalert/event"
)

// Module is a processing lock module.
type Module interface {
	Name() string
}

// Updatable is an interface for types that can be updated.
type Updatable interface {
	Module
	UpdateAll(context.Context) error
}

// SetupArgs is a struct that contains the arguments for the setup function.
type SetupArgs struct {
	DB       *sql.DB
	Workers  *river.Workers
	EventBus *event.Bus
	River    *river.Client[pgx.Tx]
}

// Setupable is an interface for types that can be set up using the job queue system.
type Setupable interface {
	Module

	// Setup is called to configure the processing lock system. Any workers, queues, and periodic jobs should be added here.
	Setup(context.Context, SetupArgs) error
}