Documentation
¶
Index ¶
- func GetUpdatesFromJobPatches(ctx context.Context, patches []dprequest.Patch, currentJob *models.Job) (jobUpdates models.Job, bsonUpdates bson.M, err error)
- func GetValueType(value interface{}) string
- func ReadJSONBody(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) PatchJobStatusHandler(w http.ResponseWriter, req *http.Request)
- func (api *API) PutNumTasksHandler(w http.ResponseWriter, req *http.Request)
- type AuthHandler
- type DataStorer
- type Indexer
- type Paginator
- type ReindexRequestedProducer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUpdatesFromJobPatches ¶ added in v0.16.0
func GetUpdatesFromJobPatches(ctx context.Context, patches []dprequest.Patch, currentJob *models.Job) (jobUpdates models.Job, bsonUpdates bson.M, err error)
GetUpdatesFromJobPatches returns an updated job resource and updated bson.M resource based on updates from the patches
func GetValueType ¶ added in v0.18.0
func GetValueType(value interface{}) string
GetValueType gets the type of a value and returns the type which is understandable for an API user
func ReadJSONBody ¶ added in v0.9.0
func ReadJSONBody(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, producer ReindexRequestedProducer) *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) PatchJobStatusHandler ¶ added in v0.16.0
func (api *API) PatchJobStatusHandler(w http.ResponseWriter, req *http.Request)
PatchJobStatusHandler updates the status of a job
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 { AcquireJobLock(ctx context.Context, id string) (lockID string, err error) CheckInProgressJob(ctx context.Context, cfg *config.Config) error CreateJob(ctx context.Context, job models.Job) error GetJob(ctx context.Context, id string) (*models.Job, error) GetJobs(ctx context.Context, options mongo.Options) (job *models.Jobs, err error) GetTask(ctx context.Context, jobID, taskName string) (*models.Task, error) GetTasks(ctx context.Context, jobID string, options mongo.Options) (job *models.Tasks, err error) UnlockJob(ctx context.Context, lockID string) UpdateJob(ctx context.Context, id string, updates bson.M) error UpsertTask(ctx context.Context, jobID, taskName string, task models.Task) error }
DataStorer is an interface for a type that can store and retrieve jobs
type Indexer ¶ added in v0.14.0
type Indexer interface { CreateIndex(ctx context.Context, serviceAuthToken, searchAPISearchURL string, httpClient dpHTTP.Clienter) (*http.Response, error) GetIndexNameFromResponse(ctx context.Context, body io.ReadCloser) (string, error) }
Indexer is a type that can create new ElasticSearch indexes
type Paginator ¶ added in v0.8.0
type Paginator interface {
ValidateParameters(offsetParam string, limitParam string, totalCount int) (offset int, limit int, err error)
}
Paginator defines the required methods from the paginator package
type ReindexRequestedProducer ¶ added in v0.15.0
type ReindexRequestedProducer interface {
ProduceReindexRequested(ctx context.Context, event models.ReindexRequested) error
}
ReindexRequestedProducer is a type that can produce reindex-requested events