Documentation ¶
Index ¶
- Variables
- func ReadJSONBody(ctx context.Context, body io.ReadCloser, v interface{}) error
- type API
- func (*API) Close(ctx context.Context) error
- func (api *API) CreateJobHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) CreateTaskHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) GetJobHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) GetJobsHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) GetTaskHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) GetTasksHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) PutNumTasksHandler(w http.ResponseWriter, req *http.Request)
- type AuthHandler
- type DataStorer
- type Indexer
- type Paginator
Constants ¶
This section is empty.
Variables ¶
var ( // NewID generates a random uuid and returns it as a string. NewID = func() string { return uuid.NewV4().String() } )
Functions ¶
func ReadJSONBody ¶ added in v0.9.0
func ReadJSONBody(ctx context.Context, body io.ReadCloser, v interface{}) error
ReadJSONBody reads the bytes from the provided body, and marshals it to the provided model interface.
Types ¶
type API ¶
API provides a struct to wrap the api around
func Setup ¶
func Setup(router *mux.Router, dataStore DataStorer, permissions AuthHandler, taskNames map[string]bool, cfg *config.Config, httpClient dpHTTP.Clienter, reindex Indexer) *API
Setup function sets up the api and returns an api
func (*API) Close ¶ added in v0.10.0
Close is called during graceful shutdown to give the API an opportunity to perform any required disposal task
func (*API) CreateJobHandler ¶ added in v0.10.0
func (api *API) CreateJobHandler(w http.ResponseWriter, req *http.Request)
CreateJobHandler generates a new Job resource and a new ElasticSearch index associated with it .
func (*API) CreateTaskHandler ¶ added in v0.10.0
func (api *API) CreateTaskHandler(w http.ResponseWriter, req *http.Request)
CreateTaskHandler returns a function that generates a new TaskName resource containing default values in its fields.
func (*API) GetJobHandler ¶ added in v0.10.0
func (api *API) GetJobHandler(w http.ResponseWriter, req *http.Request)
GetJobHandler returns a function that gets an existing Job resource, from the Job Store, that's associated with the id passed in.
func (*API) GetJobsHandler ¶ added in v0.10.0
func (api *API) GetJobsHandler(w http.ResponseWriter, req *http.Request)
GetJobsHandler gets a list of existing Job resources, from the Job Store, sorted by their values of last_updated time (ascending).
func (*API) GetTaskHandler ¶ added in v0.10.0
func (api *API) GetTaskHandler(w http.ResponseWriter, req *http.Request)
GetTaskHandler returns a function that gets a specific task, associated with an existing Job resource, using the job id and task name passed in.
func (*API) GetTasksHandler ¶ added in v0.12.0
func (api *API) GetTasksHandler(w http.ResponseWriter, req *http.Request)
GetTasksHandler gets a list of existing Task resources, from the data store, sorted by their values of last_updated time (ascending).
func (*API) PutNumTasksHandler ¶ added in v0.10.0
func (api *API) PutNumTasksHandler(w http.ResponseWriter, req *http.Request)
PutNumTasksHandler returns a function that updates the number_of_tasks in an existing Job resource, which is associated with the id passed in.
type AuthHandler ¶ added in v0.9.0
type AuthHandler interface {
Require(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc
}
AuthHandler provides authorisation checks on requests
type DataStorer ¶ added in v0.10.0
type DataStorer interface { CreateJob(ctx context.Context, id string) (job models.Job, err error) GetJob(ctx context.Context, id string) (job models.Job, err error) GetJobs(ctx context.Context, offset int, limit int) (job models.Jobs, err error) AcquireJobLock(ctx context.Context, id string) (lockID string, err error) UnlockJob(lockID string) error PutNumberOfTasks(ctx context.Context, id string, count int) error CreateTask(ctx context.Context, jobID string, taskName string, numDocuments int) (task models.Task, err error) GetTask(ctx context.Context, jobID string, taskName string) (task models.Task, err error) GetTasks(ctx context.Context, offset int, limit int, jobID string) (job models.Tasks, err error) UpdateIndexName(indexName string, jobID string) error UpdateJobState(state string, jobID string) error }
DataStorer is an interface for a type that can store and retrieve jobs