app

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package app Waiting Time Analysis Backend API

The tool allows to identify activity transitions given an event log and analyze its waiting times.

Schemes: http Host: 193.40.11.233 BasePath: / Version: 1.0.0

Consumes:

  • application/json

Produces:

  • application/json

swagger:meta

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CancelJobByID

func CancelJobByID(app *Application) http.HandlerFunc

swagger:operation GET /jobs/{id}/cancel cancelJob

Cancel processing of a job.

--- Produces:

  • application/json

Parameters:

  • name: id in: path description: Job's ID required: true type: string

Responses:

default:
  schema:
    $ref: '#/definitions/ApiResponseError'
200:
  schema:
    $ref: '#/definitions/ApiSingleJobResponse'

func DeleteJobs

func DeleteJobs(app *Application) http.HandlerFunc

swagger:route DELETE /jobs deleteJobs

Delete all non-running jobs. If a job is running, it returns an error. Cancel the running jobs manually before deleting them.

--- Responses:

default:
  schema:
    $ref: '#/definitions/ApiResponseError'
200:
  schema:
    $ref: '#/definitions/ApiJobsResponse'

func EnableCORS

func EnableCORS(inner http.Handler) http.Handler

func GetJobByID

func GetJobByID(app *Application) http.HandlerFunc

swagger:operation GET /jobs/{id} getJob

Get a single job.

--- Consumes:

  • application/json

Produces:

  • application/json

Parameters:

  • name: id in: path description: Job's ID required: true type: string

Responses:

default:
  schema:
    $ref: '#/definitions/ApiResponseError'
200:
  schema:
    $ref: '#/definitions/ApiSingleJobResponse'

func GetJobs

func GetJobs(app *Application) http.HandlerFunc

swagger:route GET /jobs listJobs

List all jobs.

--- Responses:

default:
  schema:
    $ref: '#/definitions/ApiJobsResponse'

func Index

func Index(w http.ResponseWriter, r *http.Request)

func Logger

func Logger(app *Application, inner http.Handler, name string) http.Handler

func PostJob

func PostJob(app *Application) http.HandlerFunc

swagger:operation POST /jobs postJob

Submit a job for analysis. The endpoint accepts JSON and CSV request bodies. If the callback URL is provided, a GET request with empty body is sent to this endpoint when analysis is complete.

--- Consumes:

  • application/json
  • text/csv

Produces:

  • application/json

Parameters:

  • name: Body in: body description: Description of a job required: true schema: $ref: '#/definitions/ApiRequest'

Responses:

default:
  schema:
    $ref: '#/definitions/ApiResponseError'
200:
  schema:
    $ref: '#/definitions/ApiSingleJobResponse'

func PostJobFromBody

func PostJobFromBody(app *Application) http.HandlerFunc

func SampleCallback added in v1.1.0

func SampleCallback(app *Application) http.HandlerFunc

swagger:operation POST /callback postCallback

Sample endpoint that receives a callback from the analysis service and responds with a 200 OK.

--- Consumes:

  • application/json

Produces:

  • application/json

Parameters:

  • name: Body in: body description: Callback request required: true schema: $ref: '#/definitions/ApiCallbackRequest'

Responses:

default:
  schema:
    $ref: '#/definitions/ApiResponseError'
200:
  schema:
    $ref: '#/definitions/ApiCallbackRequest'

func StaticAssets

func StaticAssets(app *Application) http.HandlerFunc

func SwaggerJSON

func SwaggerJSON(app *Application) http.HandlerFunc

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication(config *Configuration) (*Application, error)

func (*Application) AddJob

func (app *Application) AddJob(job *model.Job) error

func (*Application) Addr

func (app *Application) Addr() string

func (*Application) Close

func (app *Application) Close()

func (*Application) GetRouter

func (app *Application) GetRouter() *mux.Router

func (*Application) LoadQueue

func (app *Application) LoadQueue() error

func (*Application) ProcessQueue

func (app *Application) ProcessQueue()

ProcessQueue should be started in a separate goroutine to run the queue processing alongside the web server. It checks for any pending job and process one if available. It also saves the queue to disk when processing is done, and clears old records periodically.

func (*Application) SaveQueue

func (app *Application) SaveQueue() error

type Configuration

type Configuration struct {
	DevelopmentMode bool
	Host            string
	Port            uint
	AssetsDir       string
	ResultsDir      string
	QueueSleepTime  time.Duration
	JobTimeout      time.Duration
	LogPath         string
	QueuePath       string
}

func DefaultConfiguration

func DefaultConfiguration() *Configuration

type Queue

type Queue struct {
	Jobs []*model.Job
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue() *Queue

func (*Queue) Add

func (q *Queue) Add(job *model.Job) error

Add adds a job to the queue if it's not yet present there.

func (*Queue) Clear

func (q *Queue) Clear() error

Clear empties the queue and removes related disk data.

func (*Queue) ClearOld added in v1.1.0

func (q *Queue) ClearOld(d time.Duration) error

ClearOld removes jobs older than a given time from the queue and disk. Given duration should be negative to represent a time in the past.

func (*Queue) FindByID

func (q *Queue) FindByID(id string) *model.Job

FindByID finds a job by its ID.

func (*Queue) FindByMD5

func (q *Queue) FindByMD5(md5 string) *model.Job

func (*Queue) Next

func (q *Queue) Next() *model.Job

Next finds the first pending job in the queue.

func (*Queue) Remove

func (q *Queue) Remove(job *model.Job, removeFiles bool) error

Remove removes a job from the queue if it finds one. It also can remove files related to the job.

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	PathPrefix  string
	HandlerFunc http.HandlerFunc
}

type Routes

type Routes []Route

Jump to

Keyboard shortcuts

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