api

package
v0.0.0-...-37c92c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package api brings the HTTTP API to the application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddJobRequest

type AddJobRequest struct {
	Job       *database.Job `json:"job"`
	QueueName string        `json:"queue_name"`
}

AddJobRequest represents the request body for the add job endpoint

type CreateQueueRequest

type CreateQueueRequest struct {
	Name      string `json:"name"`
	AccessKey string `json:"access_key"`
}

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

func (a *HTTPAPI) ListenAndServe(port string) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL