Documentation ¶
Index ¶
Constants ¶
View Source
const ( StatusWorking = Status("WORKING") StatusCompleted = Status("COMPLETED") )
List of available statuses of background jobs.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Background ¶
type Background struct { Service JobService Logger Logger PingInterval time.Duration // contains filtered or unexported fields }
Background converts handlers to background handlers.
func NewMiddleware ¶
func NewMiddleware(service JobService, logger Logger) *Background
NewMiddleware creates new middleware that use service as backend for job information updating. Currently all handlers executed in goroutines.
func (*Background) InBackground ¶
InBackground converts handler to background handler. It respond immediately with job ID that can be used to track status and getting response.
type Job ¶
type Job struct { ID string `json:"id"` Status Status `json:"status"` Response *Response `json:"response"` Kind string `json:"kind"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
Job represents background job.
type JobService ¶
type JobService interface { JobStarted(ctx context.Context, kind string) (Job, error) JobCompleted(ctx context.Context, id string, response Response) error Ping(ctx context.Context, id string) error }
JobService manages background jobs information.
Click to show internal directories.
Click to hide internal directories.