Documentation ¶
Index ¶
- Variables
- type Job
- func (j *Job) Cancel(ctx context.Context) error
- func (j *Job) Context() context.Context
- func (j *Job) DispatchedAt() time.Time
- func (j *Job) Done() <-chan struct{}
- func (j *Job) Err() error
- func (j *Job) Mail() postdog.Mail
- func (j *Job) Runtime() time.Duration
- func (j *Job) SendOptions() []postdog.SendOption
- type Mailer
- type Option
- type Queue
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStarted means the queue has already been started. ErrStarted = errors.New("queue already started") // ErrNotStarted means the queue has not been started yet. ErrNotStarted = errors.New("queue not started") // ErrCanceled means a job has been canceled by either calling job.Cancel() or by canceling it's context. ErrCanceled = errors.New("job canceled") // ErrFinished means a job has already been finished and can therefore not be canceled. ErrFinished = errors.New("job already finished") )
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job is a queue job.
func (*Job) Context ¶
Context returns the job's context that has been passed to the (*Queue).Dispatch() method.
func (*Job) DispatchedAt ¶
DispatchedAt returns the time at which j was dispatched.
func (*Job) Done ¶
func (j *Job) Done() <-chan struct{}
Done returns a channel that's closed when the job is done. After the returned channel has been closed, j.Err() returns either nil or an error if the job failed.
func (*Job) Runtime ¶
Runtime returns the current runtime time.Now().Sub(j.DispatchedAt()) if the job isn't done yet. Otherwise it returns the total duration between j.DispatchedAt() and the time the job has completed.
func (*Job) SendOptions ¶
func (j *Job) SendOptions() []postdog.SendOption
SendOptions returns the job's postdog.SendOptions.
type Option ¶
type Option func(*Queue)
Option is a queue option.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the mailer queue.
func (*Queue) Dispatch ¶
func (q *Queue) Dispatch(ctx context.Context, m postdog.Mail, opts ...dispatch.Option) (*Job, error)
Dispatch adds m to q and returns the queue *Job, or an error if the dispatch failed.