Documentation
¶
Index ¶
- Variables
- type Config
- type Conn
- func (c *Conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (c *Conn) Close()
- func (c *Conn) Exec(ctx context.Context, stmt *sql.Stmt, args ...interface{}) (sql.Result, error)
- func (c *Conn) ExecWithoutLock(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (c *Conn) WithTx(ctx context.Context, txFn func(tx *sql.Tx) error) error
- type Lock
- func (l *Lock) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (l *Lock) BeginTxWithState(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, *State, error)
- func (l *Lock) Conn(ctx context.Context) (*Conn, error)
- func (l *Lock) Exec(ctx context.Context, stmt *sql.Stmt, args ...interface{}) (sql.Result, error)
- func (l *Lock) WithTx(ctx context.Context, fn func(context.Context, *sql.Tx) error) error
- func (l *Lock) WithTxShared(ctx context.Context, fn func(context.Context, *sql.Tx) error) error
- type Module
- type SetupArgs
- type Setupable
- type State
- type Type
- type Updatable
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoLock is returned when a lock can not be acquired due to normal causes. ErrNoLock = errors.New("advisory lock already taken or incompatible version") )
Static errors
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Type Type
Version int32 // Version must match the value in engine_processing_versions exactly or no lock will be obtained.
}
Config defines the parameters of the lock.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn allows using locked transactions over a single connection.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
A Lock is used to start "locked" transactions.
func (*Lock) BeginTx ¶
BeginTx will start a transaction with the appropriate lock in place (based on Config).
func (*Lock) BeginTxWithState ¶ added in v0.30.0
BeginTxWithState will start a transaction, returning a State object.
func (*Lock) Conn ¶
Conn returns a new connection from the DB pool.
Note: No version checking/locking is done until a transaction is started.
type Module ¶ added in v0.33.0
type Module interface {
Name() string
}
Module is a processing lock module.
type SetupArgs ¶ added in v0.33.0
type SetupArgs struct {
DB *sql.DB
Workers *river.Workers
EventBus *event.Bus
River *river.Client[pgx.Tx]
}
SetupArgs is a struct that contains the arguments for the setup function.
type Setupable ¶ added in v0.33.0
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
}
Setupable is an interface for types that can be set up using the job queue system.
type State ¶ added in v0.30.0
type State struct {
// contains filtered or unexported fields
}
State manages the state value for a processing lock.
type Type ¶
type Type string
Type indicates the lock type. For TypeMessage, the RegionID is used.
const ( TypeEscalation Type = "escalation" TypeHeartbeat Type = "heartbeat" TypeNPCycle Type = "np_cycle" TypeRotation Type = "rotation" TypeSchedule Type = "schedule" TypeStatusUpdate Type = "status_update" TypeVerify Type = "verify" TypeMessage Type = "message" TypeCleanup Type = "cleanup" TypeMetrics Type = "metrics" TypeCompat Type = "compat" TypeSignals Type = "signals" )
Recognized types