Documentation ¶
Index ¶
- Constants
- Variables
- type DBLocker
- func (d *DBLocker) Close() error
- func (d *DBLocker) Lock(ctx xcontext.Context, jobID types.JobID, duration time.Duration, ...) error
- func (d *DBLocker) RefreshLocks(ctx xcontext.Context, jobID types.JobID, duration time.Duration, ...) error
- func (d *DBLocker) ResetAllLocks(ctx xcontext.Context) error
- func (d *DBLocker) TryLock(ctx xcontext.Context, jobID types.JobID, duration time.Duration, ...) ([]string, error)
- func (d *DBLocker) Unlock(ctx xcontext.Context, jobID types.JobID, targets []*target.Target) error
- type Opt
Constants ¶
const DefaultMaxBatchSize = 100
Variables ¶
var Name = "DBLocker"
Name is the plugin name.
Functions ¶
This section is empty.
Types ¶
type DBLocker ¶
type DBLocker struct {
// contains filtered or unexported fields
}
DBLocker implements a simple target locker based on a relational database. The current implementation only supports MySQL officially. All functions in DBLocker are safe for concurrent use by multiple goroutines.
func (*DBLocker) Lock ¶
func (d *DBLocker) Lock(ctx xcontext.Context, jobID types.JobID, duration time.Duration, targets []*target.Target) error
Lock locks the given targets. See target.Locker for API details
func (*DBLocker) RefreshLocks ¶
func (d *DBLocker) RefreshLocks(ctx xcontext.Context, jobID types.JobID, duration time.Duration, targets []*target.Target) error
RefreshLocks refreshes the locks on the given targets. See target.Locker for API details
func (*DBLocker) ResetAllLocks ¶
ResetAllLocks resets the database and clears all locks, regardless of who owns them. This is primarily for testing, and should not be used by used in prod, this is why it is not exposed by target.Locker
type Opt ¶
type Opt func(dblocker *DBLocker)
Opt is a function type that sets parameters on the DBLocker object
func WithDriverName ¶
WithDriverName option allows using a mysql-compatible driver (e.g. a wrapper around mysql or a syntax-compatible variant).
func WithMaxBatchSize ¶
WithMaxBatchSize option sets maximum batch size for statements.