Documentation
¶
Overview ¶
Package proto provides all API and service-to-service (s2s) message structures and constants.
Index ¶
Constants ¶
const ( STATE_UNKNOWN byte = iota // Normal states, in order STATE_PENDING // not started STATE_RUNNING // running STATE_COMPLETE // completed successfully // Error states, no order STATE_FAIL // failed due to error or non-zero exit STATE_TIMEOUT // timeout STATE_STOPPED // stopped by user )
Variables ¶
var StateName = map[byte]string{ STATE_UNKNOWN: "UNKNOWN", STATE_PENDING: "PENDING", STATE_RUNNING: "RUNNING", STATE_COMPLETE: "COMPLETE", STATE_FAIL: "FAIL", STATE_TIMEOUT: "TIMEOUT", STATE_STOPPED: "STOPPED", }
var StateValue = map[string]byte{ "UNKNOWN": STATE_UNKNOWN, "PENDING": STATE_PENDING, "RUNNING": STATE_RUNNING, "COMPLETE": STATE_COMPLETE, "FAIL": STATE_FAIL, "TIMEOUT": STATE_TIMEOUT, "STOPPED": STATE_STOPPED, }
Functions ¶
This section is empty.
Types ¶
type CreateRequestParams ¶
type CreateRequestParams struct {
Type string // the type of request being made
Args map[string]interface{} // the arguments for the request
User string // the user making the request
}
CreateRequestParams represents the payload that is required to create a new request in the RM.
type FinishRequestParams ¶
type FinishRequestParams struct {
State byte // the final state of the chain
}
FinishRequestParams represents the payload that is required to tell the RM that a request has finished.
type Job ¶
type Job struct {
Id string `json:"id"` // unique id
Type string `json:"type"` // user-specific job type
Bytes []byte `json:"bytes"` // return value of Job.Serialize method
State byte `json:"state"` // STATE_* const
Args map[string]interface{} `json:"args"` // the jobArgs a job was created with
Data map[string]interface{} `json:"data"` // job-specific data during Job.Run
Retry uint `json:"retry"` // retry N times if first run fails
RetryWait uint `json:"retryWait"` // wait time (milliseconds) between retries
}
Job represents one job in a job chain. Jobs are identified by Id, which must be unique within a job chain.
type JobChain ¶
type JobChain struct {
RequestId string `json:"requestId"` // unique identifier for the chain
Jobs map[string]Job `json:"jobs"` // Job.Id => job
AdjacencyList map[string][]string `json:"adjacencyList"` // Job.Id => next []Job.Id
State byte `json:"state"` // STATE_* const
}
JobChain represents a directed acyclic graph of jobs for one request. Job chains are identified by RequestId, which must be globally unique.
type JobChainStatus ¶
type JobChainStatus struct {
RequestId string `json:"requestId"`
JobStatuses JobStatuses `json:"jobStatuses"`
}
JobChainStatus represents the status of a job chain reported by the Job Runner.
type JobLog ¶
type JobLog struct {
// These three fields uniquely identify an entry in the job log.
RequestId string `json:"requestId"`
JobId string `json:"jobId"`
Try uint `json:"try"` // try number N of 1 + Job.Retry
Type string `json:"type"` // the type of the job
StartedAt int64 `json:"startedAt"` // when the job runner started the job
FinishedAt int64 `json:"finishedAt"` // when the job returned, regardless of state
State byte `json:"state"` // STATE_* const
Exit int64 `json:"exit"` // unix exit code
Error string `json:"error"` // error message
Stdout string `json:"stdout"` // stdout output
Stderr string `json:"stderr"` // stderr output
}
JobLog represents a log entry for a finished job.
type JobStatus ¶
type JobStatus struct {
RequestId string `json:"requestId"`
JobId string `json:"jobId"`
State byte `json:"state"`
Status string `json:"status"` // @todo: job.Status()
Runtime float64 `json:"runtime"` // seconds
N uint `json:"n"` // Nth job ran in chain
}
JobStatus represents the status of one job in a job chain.
type JobStatusByRuntime ¶
type JobStatusByRuntime []JobStatus
func (JobStatusByRuntime) Len ¶
func (js JobStatusByRuntime) Len() int
func (JobStatusByRuntime) Less ¶
func (js JobStatusByRuntime) Less(i, j int) bool
func (JobStatusByRuntime) Swap ¶
func (js JobStatusByRuntime) Swap(i, j int)
type JobStatuses ¶
type JobStatuses []JobStatus
JobStatuses are a list of job status sorted by job id.
func (JobStatuses) Len ¶
func (js JobStatuses) Len() int
func (JobStatuses) Less ¶
func (js JobStatuses) Less(i, j int) bool
func (JobStatuses) Swap ¶
func (js JobStatuses) Swap(i, j int)
type Request ¶
type Request struct {
Id string `json:"id"` // unique identifier for the request
Type string `json:"type"` // the type of request
State byte `json:"state"` // STATE_* const
User string `json:"user"` // the user who made the request
CreatedAt time.Time `json:"createdAt"` // when the request was created
// These are pointers so that they can have nil values.
StartedAt *time.Time `json:"startedAt"` // when the request was sent to the job runner
FinishedAt *time.Time `json:"finishedAt"` // when the job runner finished the request. doesn't indicate success/failure
JobChain *JobChain `json:",omitempty"` // the job chain
TotalJobs int `json:"totalJobs"` // the number of jobs in the request's job chain
FinishedJobs int `json:"finishedJobs"` // the number of finished jobs in the request
}
Request represents something that a user asks Spin Cycle to do.
type RequestArg ¶
RequestArg represents one request arg.
type RequestSpec ¶
type RequestSpec struct {
Name string
Args []RequestArg
}
RequestSpec represents the metadata of a request necessary to start the request.
type RequestStatus ¶
type RequestStatus struct {
Request `json:"request"`
JobChainStatus JobChainStatus `json:"jobChainStatus"`
}
RequestStatus represents the status of a request reported by the Request Manager.