| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This package is not in the latest version of its module.
Go to latest Published: Mar 28, 2025 License: MITThe Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Modules with tagged versions give importers more predictable builds.
When a project reaches major version v1 it is considered stable.
This section is empty.
This section is empty.
This section is empty.
type AdvancedJob interface {
Run(jr JobRecord) (any, error)
RetryCount() uint // returns how many times we allow this job to fail
BackoffTime() time.Duration // how long to wait after a failure
JobTimeout() time.Duration // how long this job may run before timing out
}
AdvancedJob Job is the interface each job must implement.
type AdvancedJobConstructor func() (AdvancedJob, error)
type Config struct {
// DB is the user-provided database connection where the jobs table is stored.
DB *sql.DB
// DbName is name of the database.
DbName string
// RetryCount is how many times we allow a job to fail before ignoring it.
RetryCount uint
// BackoffTime is how long we wait before letting a failed job become available again.
BackoffTime time.Duration
// PollInterval is how frequently workers check for new jobs.
PollInterval time.Duration
// JobTimeout is how long we allow an individual job to run before marking it as failed.
// If zero, there is no enforced timeout.
JobTimeout time.Duration
// InfoLog is called for informational or success logs.
// If nil, defaults to printing to stdout.
InfoLog func(ev LogEvent)
// ErrorLog is called for error logs.
// If nil, defaults to printing to stderr (or stdout).
ErrorLog func(ev LogEvent)
}
Config holds the settings and resources needed by the queue system.
JobHandler is a function that receives the payload string, constructs and runs the job, and returns an optional output string plus an error.
type JobRecord struct {
ID uint64
Operation Operation
Status JobStatus
Output any
LockedBy *string
LockedUntil *time.Time
RetryCount uint
AvailableAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
// contains filtered or unexported fields
}
JobRecord corresponds to one row in the jobs table.
type LogEvent struct {
// A human-readable message about the event.
Message string
// The ID of the worker that triggered the log (if any).
WorkerID string
// The Job ID, if available.
JobID *uint64
// The operation name, if available.
Operation *string
// Any error associated with the event.
Err error
// How long the job or operation took, if relevant.
Duration *time.Duration
}
LogEvent captures information about a logging event.
type Operation string
Operation is a type for your job "name" or "action" (e.g., "ADD_CUSTOMER").
type TaskFlow struct {
// contains filtered or unexported fields
}
func (tf *TaskFlow) CreateJob(ctx context.Context, operation Operation, payload any, executeAt time.Time) (int64, error)
CreateJob inserts a new job into the database
func (tf *TaskFlow) RegisterAdvancedHandler(op Operation, constructor func() AdvancedJob)
func (tf *TaskFlow) RegisterHandler(op Operation, handler JobHandler)
RegisterHandler allows end users to associate an Operation with a JobHandler.
type WorkerStatus int
const ( WorkerIdle WorkerStatus = iota WorkerBusy WorkerFailing WorkerExecFailed )
| Back | FazBrowse Home | New Git URL |