Documentation ¶
Index ¶
- Variables
- type Client
- type Handler
- func (h *Handler) Complete(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Init(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Lease(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Load(file string) error
- func (h *Handler) Save(ctx context.Context, t *time.Ticker)
- func (h *Handler) Update(w http.ResponseWriter, r *http.Request)
- type Job
- type Jobs
- type Sequence
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmpty is returned when the job-server has no more dates available. ErrEmpty = errors.New("no dates available") // ErrWait is returned when the job-server may have more dates in the future. ErrWait = errors.New("more dates may become available") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client manages requests to the job-server.
type Handler ¶
type Handler struct { // JobsStateFile is the file name where the handler will periodically write the job state. JobsStateFile string // Timeout is the maximum time a leased job should remain leased without // updates before being returned to the pending queue. Timeout time.Duration // contains filtered or unexported fields }
Handler is an HTTP handler for a jobs server.
func (*Handler) Complete ¶
func (h *Handler) Complete(w http.ResponseWriter, r *http.Request)
Complete moves a leased job to the set of completed jobs. If the job is not leased, Complete returns an error.
func (*Handler) Init ¶
func (h *Handler) Init(w http.ResponseWriter, r *http.Request)
Init populates the set of Pending jobs with all dates between the given "start" and "end" (exclusive) date parameters. These dates should use the format YYYY-MM-DD.
func (*Handler) Lease ¶
func (h *Handler) Lease(w http.ResponseWriter, r *http.Request)
Lease takes a job from the pending queue. If no jobs are currently pending, but still leased, the Lease handler will return "Status Too Early" to signal a client to retry after waiting. If no jobs are currently pending, the Lease handler will return "Status No Content" to signal a client to stop attempting leases.
type Jobs ¶
type Jobs struct { // Pending is the list of dates to be processed. Pending Sequence // Leased is the set of currently leased jobs. Leased map[string]Job // Completed is the set of all completed jobs. Completed map[string]Job }
Jobs represents a collection of pending, currently leased, and completed Jobs. A given date will only be in one of Pending, Leased, or Completed. A Jobs instance can be Marshalled to JSON.