Documentation
¶
Overview ¶
Package request provides an interface for managing requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidParams = errors.New("invalid request type and/or arguments")
)
Functions ¶
This section is empty.
Types ¶
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 Manager ¶
type Manager interface {
// Create creates a proto.Request and saves it to the db.
Create(proto.CreateRequestParams) (proto.Request, error)
// Get retrieves the request corresponding to the provided id,
// without its job chain or parameters set.
Get(requestId string) (proto.Request, error)
// Get retrieves the request corresponding to the provided id,
// with its job chain and parameters.
GetWithJC(requestId string) (proto.Request, error)
// Start starts a request (sends it to the JR).
Start(requestId string) error
// Stop stops a request (sends a stop signal to the JR).
Stop(requestId string) error
// Status 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.
Status(requestId string) (proto.RequestStatus, error)
// Finish marks a request as being finished. It gets the request's final
// state from the proto.FinishRequestParams argument.
Finish(requestId string, finishParams proto.FinishRequestParams) error
// IncrementFinishedJobs increments the count of the FinishedJobs field
// on the request and saves it to the db.
IncrementFinishedJobs(requestId string) error
// Specs returns a list of all the request specs the the RM knows about.
Specs() []proto.RequestSpec
// JobChain returns the job chain for the given request id.
JobChain(requestId string) (proto.JobChain, error)
}
A Manager is used to create and manage requests.
func NewManager ¶
func NewManager(config ManagerConfig) Manager
type ManagerConfig ¶
type Resumer ¶
type Resumer interface {
// Suspend marks a running request as suspended and saves the corresponding
// suspended job chain.
Suspend(sjc proto.SuspendedJobChain) error
// ResumeAll tries to resume all the SJCs currently stored in the database.
ResumeAll()
// Resume tries to resume a single SJC given its id and a connection to the
// database. The SJC must be claimed (`rm_host` field for the SJC must be set
// to the hostname given when creating the Resumer) before calling Resume, or
// it will fail.
Resume(id string) error
// Cleanup cleans up abandoned and old SJCs. Abandoned SJCs are those that have
// been claimed by an RM (`rm_host` field set) but have not been updated in a
// while, meaning the RM resuming them probably crashed. These SJCs are
// unclaimed (set `rm_host` to null) so they can be resumed in the future. Old
// SJCs are those which haven't been resumed within the TTL provided when
// creating the Resumer (rounded to the nearest second). They're deleted and
// their requests' states set to FAILED.
Cleanup()
}
func NewResumer ¶
func NewResumer(cfg ResumerConfig) Resumer
Click to show internal directories.
Click to hide internal directories.