request

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package request provides an interface for managing requests, which are the core compontent of the Request Manager.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidParams   = errors.New("invalid request type and/or arguments")
	ErrNotUpdated      = errors.New("cannot find request to update")
	ErrMultipleUpdated = errors.New("multiple requests updated")
)

Functions

This section is empty.

Types

type DBAccessor

type DBAccessor interface {
	// SaveRequest saves a proto.Request, along with it's job chain and the
	// request params that created it (both as byte arrays), in the database.
	SaveRequest(proto.Request, proto.CreateRequestParams) error

	// GetRequest retrieves a request from the database.
	GetRequest(string) (proto.Request, error)

	// UpdateRequest updates a request in the database.
	UpdateRequest(proto.Request) error

	// IncrementRequestFinishedJobs increments the finished_jobs field on a
	// request in the database. This is so that, when you just get the high-
	// level status of a request, you can see what % of jobs are finished.
	IncrementRequestFinishedJobs(string) error

	// GetRequestJobStatuses takes a request id and returns the status of
	// all of the jobs in the request in the form of a proto.RequestStatus.
	// It uses the most recent JL entry for each job to determine its status.
	GetRequestJobStatuses(string) (proto.JobStatuses, error)

	// GetJobChain retrieves a job chain from the database.
	GetJobChain(string) (proto.JobChain, error)

	// Get full job log of a request.
	GetFullJL(string) ([]proto.JobLog, error)

	// GetLatestJL takes a request id and a job id and returns the latest
	// corresponding jog log.
	GetLatestJL(string, string) (proto.JobLog, error)

	// SaveJL saves a proto.JobLog to the database.
	SaveJL(proto.JobLog) error
}

A DBAccessor persists requests to a database.

func NewDBAccessor

func NewDBAccessor(db *sql.DB) DBAccessor

type ErrInvalidState

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

func NewErrInvalidState

func NewErrInvalidState(expectedState, actualState string) ErrInvalidState

func (ErrInvalidState) Error

func (e ErrInvalidState) Error() string

type ErrNotFound

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

func NewErrNotFound

func NewErrNotFound(resource string) ErrNotFound

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type Manager

type Manager interface {
	// CreateRequest creates a proto.Request from a proto.CreateRequestParams. It
	// uses the Grapher package to create a job chain which it attaches to the
	// request proto.
	CreateRequest(proto.CreateRequestParams) (proto.Request, error)

	// GetRequest retrieves the request corresponding to the provided request id.
	GetRequest(requestId string) (proto.Request, error)

	// StartRequest starts a request (sends it to the Job Runner).
	StartRequest(requestId string) error

	// FinishRequest marks a request as being finished. It gets the request's final
	// state from the proto.FinishRequestParams argument.
	FinishRequest(requestId string, finishParams proto.FinishRequestParams) error

	// StopRequest tells the Job Runner to stop running the request's job chain.
	StopRequest(requestId string) error

	// RequestStatus returns the status of a request and all of the jobs in it.
	// The live status output of any jobs that are currently running will be
	// included as well.
	RequestStatus(requestId string) (proto.RequestStatus, error)

	// GetJobChain retrieves the job chain corresponding to the provided request id.
	GetJobChain(requestId string) (proto.JobChain, error)

	// GetJL retrieves the job log corresponding to the provided request and job ids.
	GetJL(requestId string, jobId string) (proto.JobLog, error)
	GetFullJL(requestId string) ([]proto.JobLog, error)

	// CreateJL takes a request id and a proto.JobLog and creates a
	// proto.JobLog. This could be a no-op, or, depending on implementation, it
	// could update some of the fields on the JL, save it to a database, etc.
	CreateJL(requestId string, jl proto.JobLog) (proto.JobLog, error)

	RequestList() []proto.RequestSpec
}

A Manager is used to create and manage requests.

func NewManager

func NewManager(requestResolver *grapher.Grapher, dbAccessor DBAccessor, jrClient jr.Client) Manager

Jump to

Keyboard shortcuts

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