Documentation ¶
Index ¶
- Constants
- type ConnectionClosedError
- type FailedJob
- type FailedJobs
- type FailureLog
- type HasFailureLog
- type HasInspector
- type HasNodeInfo
- type Impl
- type InactiveError
- type IncomingJob
- type InspectedJob
- type InspectedJobs
- type Inspector
- type Job
- type JobQueue
- type NextInfo
- type Node
- type Result
- type Stats
Constants ¶
const ( // ResultStatusSuccess means that the job is successfully processed. ResultStatusSuccess = "success" // ResultStatusFailure means that the job is failed but it may be retried. ResultStatusFailure = "failure" // ResultStatusPermanentFailure means that the job is failed and // should never be retried. ResultStatusPermanentFailure = "permanent-failure" // ResultStatusInternalFailure means that the job is failed before // processing it in some internal reason. ResultStatusInternalFailure = "internal-failure" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionClosedError ¶
type ConnectionClosedError struct{}
ConnectionClosedError is an error returned when Pop() is called but connection to a remote store has been lost.
func (*ConnectionClosedError) Error ¶
func (e *ConnectionClosedError) Error() string
type FailedJob ¶
type FailedJob struct { ID uint64 `json:"id"` JobID uint64 `json:"job_id"` Category string `json:"category"` URL string `json:"url"` Payload json.RawMessage `json:"payload,omitempty"` Result *Result `json:"result"` FailCount uint `json:"fail_count"` FailedAt time.Time `json:"failed_at"` CreatedAt time.Time `json:"created_at"` }
FailedJob describes a (permanently) failed job that was in a queue.
type FailedJobs ¶
type FailedJobs struct { FailedJobs []FailedJob `json:"failed_jobs"` NextCursor string `json:"next_cursor"` }
FailedJobs describes a (page of) failed job list of a queue.
type FailureLog ¶
type FailureLog interface { Add(failed Job, result *Result) error Delete(failureID uint64) error Find(failureID uint64) (*FailedJob, error) FindAll(limit uint, cursor string) (*FailedJobs, error) FindAllRecentFailures(limit uint, cursor string) (*FailedJobs, error) }
FailureLog is an interface to inspect failed jobs of a queue.
type HasFailureLog ¶
type HasFailureLog interface {
FailureLog() FailureLog
}
HasFailureLog is an interface describing that it has an FailureLog.
This is typically a JobQueue sub-interface.
type HasInspector ¶
type HasInspector interface {
Inspector() Inspector
}
HasInspector is an interface describing that it has an Inspector.
This is typically a JobQueue sub-interface.
type HasNodeInfo ¶
HasNodeInfo is an interface describing that it has a Node information.
This is typically a JobQueue sub-interface.
type Impl ¶
type Impl interface { Start() Stop() <-chan struct{} Push(job IncomingJob) (Job, error) Pop(limit uint) ([]Job, error) Delete(job Job) Update(job Job, next NextInfo) IsActive() bool }
Impl is an interface of a job queue implementation.
type InactiveError ¶
type InactiveError struct{}
InactiveError is an error returned when Pop() is called on an inactive queue.
func (*InactiveError) Error ¶
func (e *InactiveError) Error() string
type IncomingJob ¶
type IncomingJob interface { Category() string URL() string Payload() string NextDelay() uint64 // milliseconds Timeout() uint // seconds RetryDelay() uint // seconds RetryCount() uint }
IncomingJob is an interface of incoming jobs.
type InspectedJob ¶
type InspectedJob struct { ID uint64 `json:"id"` Category string `json:"category"` URL string `json:"url"` Payload json.RawMessage `json:"payload,omitempty"` Status string `json:"status"` CreatedAt time.Time `json:"created_at"` NextTry time.Time `json:"next_try"` Timeout uint `json:"timeout"` FailCount uint `json:"fail_count"` MaxRetries uint `json:"max_retries"` RetryDelay uint `json:"retry_delay"` }
InspectedJob describes a job in a queue.
type InspectedJobs ¶
type InspectedJobs struct { Jobs []InspectedJob `json:"jobs"` NextCursor string `json:"next_cursor"` }
InspectedJobs describes a (page of) job list in a queue.
type Inspector ¶
type Inspector interface { Delete(jobID uint64) error Find(jobID uint64) (*InspectedJob, error) FindAllGrabbed(limit uint, cursor string) (*InspectedJobs, error) FindAllWaiting(limit uint, cursor string) (*InspectedJobs, error) FindAllDeferred(limit uint, cursor string) (*InspectedJobs, error) }
Inspector is an interface to inspect jobs in a queue.
type Job ¶
type Job interface { URL() string Payload() string Timeout() uint RetryCount() uint RetryDelay() uint FailCount() uint ToLoggable() logger.LoggableJob }
Job is an interface of jobs.
type JobQueue ¶
type JobQueue interface { Stop() <-chan struct{} Push(job IncomingJob) (uint64, error) Pop(limit uint) ([]Job, error) Complete(job Job, res *Result) Name() string IsActive() bool Node() (*Node, error) Stats() *Stats Inspector() (Inspector, bool) FailureLog() (FailureLog, bool) }
JobQueue is an interface of a job queue.
type Result ¶
type Result struct { Status string `json:"status"` Code int `json:"code"` Message string `json:"message"` }
Result describes the result of a processed job.
func (*Result) IsFinished ¶
IsFinished returns if the job can be retried or not.
type Stats ¶
type Stats struct { TotalPushes int64 `json:"total_pushes"` TotalPops int64 `json:"total_pops"` TotalSuccesses int64 `json:"total_successes"` TotalFailures int64 `json:"total_failures"` TotalCompletes int64 `json:"total_completes"` TotalElapsed int64 `json:"total_elapsed"` PushesPerSecond int64 `json:"pushes_per_second"` PopsPerSecond int64 `json:"pops_per_second"` }
Stats describes queue statistics.