Back to

Package api

Latest Go to latest

The latest major version is v2.

Published: Sep 25, 2020 | License: Apache-2.0 | Module:


Package api provides controllers for each api endpoint. Controllers are "dumb wiring"; there is little to no application logic in this package. Controllers call and coordinate other packages to satisfy the api endpoint.



const (
	API_ROOT = "/api/v1/"


var (
	// Errors related to getting and setting traversers in the traverser repo.
	ErrDuplicateTraverser = errors.New("traverser already exists")
	ErrTraverserNotFound  = errors.New("traverser not found")
	ErrInvalidTraverser   = errors.New("traverser found, but type is invalid")

	// Error when Job Runner is shutting down and not starting new job chains
	ErrShuttingDown = errors.New("Job Runner is shutting down - no new job chains are being started")

type API

type API struct {
	// contains filtered or unexported fields

api provides controllers for endpoints it registers with a router.

func NewAPI

func NewAPI(cfg Config) *API

NewAPI creates a new API struct. It initializes an echo web server within the struct, and registers all of the API's routes with it.

func (*API) Run

func (api *API) Run() error

Run API server.

func (*API) ServeHTTP

func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*API) Stop

func (api *API) Stop() error

Stop stops the API when it's running. When Stop is called, Run returns immediately. Make sure to wait for Stop to return.

type Config

type Config struct {
	AppCtx           app.Context
	TraverserFactory chain.TraverserFactory
	TraverserRepo    cmap.ConcurrentMap
	StatusManager    status.Manager
	ShutdownChan     chan struct{}
	BaseURL          string // returned in location header when starting/resuming job chains

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier