Documentation
¶
Index ¶
- Variables
- func RandomJid() string
- type Dlqer
- type Failure
- type Helper
- type Job
- func (j *Job) GetCustom(name string) (interface{}, bool)
- func (j *Job) JsonBytes() ([]byte, error)
- func (j *Job) SetCustom(name string, value interface{}) *Job
- func (j *Job) SetExpiresAt(expiresAt time.Time) *Job
- func (j *Job) SetExpiresIn(expiresIn time.Duration) *Job
- func (j *Job) SetUniqueFor(secs uint) *Job
- func (j *Job) SetUniqueness(until UniqueUntil) *Job
- type JobProcessor
- type UniqueUntil
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RetryPolicyDefault = 25 RetryPolicyEmphemeral = 0 RetryPolicyDirectToMorgue = -1 )
Functions ¶
Types ¶
type Failure ¶
type Failure struct { RetryCount int `json:"retry_count"` RetryRemaining int `json:"remaining"` FailedAt string `json:"failed_at"` NextAt string `json:"next_at,omitempty"` ErrorMessage string `json:"message,omitempty"` ErrorType string `json:"errtype,omitempty"` Backtrace []string `json:"backtrace,omitempty"` }
type Helper ¶
type Helper interface { Jid() string JobType() string // Custom provides access to the job custom hash. // Returns the value and `ok=true` if the key was found. // If not, returns `nil` and `ok=false`. // // No type checking is performed, please use with caution. Custom(key string) (value interface{}, ok bool) // Faktory Enterprise: // the BID of the Batch associated with this job Bid() string // Faktory Enterprise: // the BID of the Batch associated with this callback (complete or success) job CallbackBid() string // Faktory Enterprise: // open the batch associated with this job so we can add more jobs to it. // // func myJob(ctx context.Context, args ...interface{}) error { // helper := worker.HelperFor(ctx) // helper.Batch(func(b *faktory.Batch) error { // return b.Push(faktory.NewJob("sometype", 1, 2, 3)) // }) Batch(func(*faktory.Batch) error) error // allows direct access to the Faktory server from the job With(func(*faktory.Client) error) error // Faktory Enterprise: // this method integrates with Faktory Enterprise's Job Tracking feature. // `reserveUntil` is optional, only needed for long jobs which have more dynamic // lifetimes. // // helper.TrackProgress(10, "Updating code...", nil) // helper.TrackProgress(20, "Cleaning caches...", &time.Now().Add(1 * time.Hour))) // TrackProgress(percent int, desc string, reserveUntil *time.Time) error }
type Job ¶
type Job struct { // required Jid string `json:"jid"` Queue string `json:"queue"` Type string `json:"jobtype"` Args []interface{} `json:"args"` // optional CreatedAt string `json:"created_at,omitempty"` EnqueuedAt string `json:"enqueued_at,omitempty"` At string `json:"at,omitempty"` ReserveFor int `json:"reserve_for,omitempty"` Retry *int `json:"retry"` Backtrace int `json:"backtrace,omitempty"` Failure *Failure `json:"failure,omitempty"` Custom map[string]interface{} `json:"custom,omitempty"` }
func NewJob ¶
Clients should use this constructor to build a Job, not allocate a bare struct directly.
func (*Job) SetCustom ¶
Set custom metadata for this job. Faktory reserves all element names starting with "_" for internal use, e.g. SetCustom("_txid", "12345")
func (*Job) SetExpiresAt ¶
Configure the TTL for this job. After this point in time, the job will be discarded rather than executed.
func (*Job) SetUniqueFor ¶
Configure this job to be unique for +secs+ seconds or until the job has been successfully processed.
func (*Job) SetUniqueness ¶
func (j *Job) SetUniqueness(until UniqueUntil) *Job
Configure the uniqueness deadline for this job, legal values are:
- "success" - the job will be considered unique until it has successfully processed or the +unique_for+ TTL has passed, this is the default value.
- "start" - the job will be considered unique until it starts processing. Retries may lead to multiple copies of the job running.
type JobProcessor ¶
type UniqueUntil ¶
type UniqueUntil string
const ( UntilSuccess UniqueUntil = "success" // default UntilStart UniqueUntil = "start" )
Click to show internal directories.
Click to hide internal directories.