Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateLockID ¶
GenerateLockID creates a deterministic int64 lock ID from a task name using FNV-64a hash.
Types ¶
type SingletonConfig ¶
type SingletonConfig struct {
// Name identifies the task (used for logging and lock ID generation).
Name string
// DB is the PostgreSQL connection pool.
DB *pgxpool.Pool
// Interval is the time between executions.
Interval time.Duration
// InitialDelay is an optional delay before the first execution.
InitialDelay time.Duration
// TaskFn is the function to execute on each tick.
TaskFn TaskFunc
}
SingletonConfig configures a SingletonTask.
type SingletonTask ¶
type SingletonTask struct {
// contains filtered or unexported fields
}
SingletonTask runs a periodic function protected by a PostgreSQL advisory lock. Only one instance across the cluster will execute the task at any given interval.
func NewSingletonTask ¶
func NewSingletonTask(config SingletonConfig) *SingletonTask
NewSingletonTask creates a new singleton task.
func (*SingletonTask) Start ¶
func (t *SingletonTask) Start(ctx context.Context)
Start begins the periodic execution loop.
Click to show internal directories.
Click to hide internal directories.