Documentation
¶
Overview ¶
Package api brings the HTTTP API to the application
Index ¶
- type AddJobRequest
- type CreateQueueRequest
- type ErrorResponse
- type GetQueueResponse
- type HTTPAPI
- func (a *HTTPAPI) AddJob(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) CreateQueue(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) DeleteJob(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) DeleteQueue(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) GetJob(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) GetNextJob(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) GetQueue(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) ListenAndServe(port string) error
- func (a *HTTPAPI) Test(w http.ResponseWriter, r *http.Request)
- func (a *HTTPAPI) UpdateJobStatus(w http.ResponseWriter, r *http.Request)
- type UpdateJobStatusRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddJobRequest ¶
AddJobRequest represents the request body for the add job endpoint
type CreateQueueRequest ¶
CreateQueueRequest represents the request body for the create queue endpoint
type ErrorResponse ¶
type ErrorResponse struct {
Err string `json:"error"`
}
ErrorResponse can be called from any handler, to notify of an error in the request/processing
type GetQueueResponse ¶
type GetQueueResponse struct {
Jobs []*database.Job `json:"jobs"`
Size int `json:"size"`
Name string `json:"name"`
}
GetQueueResponse is a response object for the Get Queue endpoint
type HTTPAPI ¶
type HTTPAPI struct {
// contains filtered or unexported fields
}
HTTPAPI is an object for an HTTP/1.1 API for controlling the application
func NewHTTPAPI ¶
func NewHTTPAPI(logger logger.Logger, monitor database.DBMonitor, controller database.QueryController) *HTTPAPI
NewHTTPAPI is a constructor for an HttpAPI object
func (*HTTPAPI) AddJob ¶
func (a *HTTPAPI) AddJob(w http.ResponseWriter, r *http.Request)
AddJob is an endpoint handler for adding a new job to a queue
func (*HTTPAPI) CreateQueue ¶
func (a *HTTPAPI) CreateQueue(w http.ResponseWriter, r *http.Request)
CreateQueue is an endpoint handler for API requests to create a queue
func (*HTTPAPI) DeleteJob ¶
func (a *HTTPAPI) DeleteJob(w http.ResponseWriter, r *http.Request)
DeleteJob is a handler for deleting a job entry
func (*HTTPAPI) DeleteQueue ¶
func (a *HTTPAPI) DeleteQueue(w http.ResponseWriter, r *http.Request)
DeleteQueue is an endpoint handler for API requests to delete a queue
func (*HTTPAPI) GetJob ¶
func (a *HTTPAPI) GetJob(w http.ResponseWriter, r *http.Request)
GetJob is a handler for querying an entry for a specific job
func (*HTTPAPI) GetNextJob ¶
func (a *HTTPAPI) GetNextJob(w http.ResponseWriter, r *http.Request)
GetNextJob is a handler for returning the next job from the queue head that is queued
func (*HTTPAPI) GetQueue ¶
func (a *HTTPAPI) GetQueue(w http.ResponseWriter, r *http.Request)
GetQueue is an endpoint handler for API requests to return a copy of a queue
func (*HTTPAPI) ListenAndServe ¶
ListenAndServe starts the API listening for requets, blocks current goroutine
func (*HTTPAPI) Test ¶
func (a *HTTPAPI) Test(w http.ResponseWriter, r *http.Request)
Test is a simple 'is-alive' endpoint handler, returning a 200 status code
func (*HTTPAPI) UpdateJobStatus ¶
func (a *HTTPAPI) UpdateJobStatus(w http.ResponseWriter, r *http.Request)
UpdateJobStatus is a handler for updating the status of a given job
type UpdateJobStatusRequest ¶
type UpdateJobStatusRequest struct {
QueueName string `json:"queue_name"`
UID string `json:"uid"`
NewStatus string `json:"new_status"`
}
UpdateJobStatusRequest represents the request body for the update job endpoint