Documentation ¶
Index ¶
- Constants
- Variables
- func GetWorkflowsFromPath(path string) map[string]*Workflow
- func StatusToString(status int32) string
- type CLITask
- type HTTPTask
- type InputParameter
- type InputParameters
- type Job
- type NATSTask
- type SMTPTask
- type Task
- type TaskResult
- type TaskResultCLI
- type TaskResultHTTPRequest
- type TaskResultHTTPResponse
- type TaskResultNATS
- type TaskResultSMTP
- type Workflow
Constants ¶
const ( StatusDone = int32(iota) StatusPending StatusProcessing StatusFailure )
Status
const ( TaskTypeCLI = "cli" TaskTypeHTTP = "http" TaskTypeNATS = "nats" TaskTypeSMTP = "smtp" )
Type of tasks
const DefaultTopic = "default"
const ErrMsgMissingParamF = "Missing input parameters: %s"
ErrMsgMissingParamF is the error message for missing input parameters
Variables ¶
var ( // ErrInvalidStatus is the error for invalid status ErrInvalidStatus = errors.New("Invalid status") )
Functions ¶
func GetWorkflowsFromPath ¶
GetWorkflowsFromPath parse the workflows stored as JSON files in a directory and returns them
func StatusToString ¶
StatusToString returns the job's status as a string
Types ¶
type CLITask ¶
type CLITask struct { Command []string `json:"command" bson:"command"` ExecutionTimeOut int `json:"executionTimeOut" bson:"executionTimeOut"` }
CLITask stores the parameters of the CLI commands for a WorkflowTask
type HTTPTask ¶
type HTTPTask struct { URI string `json:"uri" bson:"uri"` Method string `json:"method" bson:"method"` ContentType string `json:"contentType,omitempty" bson:"contentType"` Body string `json:"body,omitempty" bson:"body"` FormData map[string]string `json:"formdata,omitempty" bson:"formdata"` JSON interface{} `json:"json,omitempty" bson:"json"` StatusCodes []int `json:"statusCodes,omitempty" bson:"statusCodes"` Headers map[string]string `json:"headers" bson:"headers"` ConnectionTimeOut int `json:"connectionTimeOut" bson:"connectionTimeOut"` ReadTimeOut int `json:"readTimeOut" bson:"readTimeOut"` }
HTTPTask stores the parameters of the HTTP calls for a WorkflowTask
type InputParameter ¶
type InputParameter struct { // Name of the parameter Name string `json:"name" bson:"name"` // Value of the input parameter Value string `json:"value" bson:"value"` // Raw value of the input parameter Raw interface{} `json:"raw,omitempty" bson:"raw"` }
InputParameter defines the input parameter of a job
type InputParameters ¶
type InputParameters []InputParameter
func (InputParameters) Map ¶
func (param InputParameters) Map() map[string]interface{}
type Job ¶
type Job struct { // Id is the ID of the job ID string `json:"id" bson:"_id"` // WorkflowName contains the name of the workflow WorkflowName string `json:"workflowName" bson:"workflow_name"` // InputParameters contains the name of the workflow InputParameters InputParameters `json:"inputParameters" bson:"input_parameters"` // Enumerated status of the Job and string field used for unmarshalling Status int32 `json:"-" bson:"status"` StatusString string `json:"status,omitempty" bson:"-"` // Results produced by a finished job. If status is not "done" this // field will always be nil. Results []TaskResult `json:"results" bson:"results,omitempty"` // insert time InsertTime time.Time `json:"insert_time" bson:"insert_time,omitempty"` //workflow version WorkflowVersion string `json:"version" bson:"version,omitempty"` }
Job defines the execution job a workflow
func (*Job) PrepareForJSONMarshalling ¶
func (job *Job) PrepareForJSONMarshalling()
type NATSTask ¶
type NATSTask struct { Subject string `json:"subject" bson:"subject"` Data interface{} `json:"data" bson:"data"` }
NATSTask stores the parameters of the NATS parameters for a WorkflowTask
type SMTPTask ¶
type SMTPTask struct { From string `json:"from" bson:"from"` To []string `json:"to" bson:"to"` Cc []string `json:"cc" bson:"cc"` Bcc []string `json:"bcc" bson:"bcc"` Subject string `json:"subject" bson:"subject"` Body string `json:"body" bson:"body"` HTML string `json:"html" bson:"html"` Timeout int `json:"timeout" bson:"timeout"` }
SMTPTask stores the parameters of the SMTP messages for a WorkflowTask
type Task ¶
type Task struct { Name string `json:"name" bson:"name"` Type string `json:"type" bson:"type"` Retries uint8 `json:"retries" bson:"retries"` RetryDelaySeconds uint8 `json:"retryDelaySeconds" bson:"retryDelaySeconds"` Requires []string `json:"requires,omitempty" bson:"requires,omitempty"` HTTP *HTTPTask `json:"http,omitempty" bson:"http,omitempty"` CLI *CLITask `json:"cli,omitempty" bson:"cli,omitempty"` NATS *NATSTask `json:"nats,omitempty" bson:"nats,omitempty"` SMTP *SMTPTask `json:"smtp,omitempty" bson:"smtp,omitempty"` }
Task stores the definition of a task within a workflow
type TaskResult ¶
type TaskResult struct { Name string `json:"name" bson:"name"` Type string `json:"type" bson:"type"` Success bool `json:"success" bson:"success"` Skipped bool `json:"skipped" bson:"skipped"` CLI *TaskResultCLI `json:"cli,omitempty" bson:"cli,omitempty"` HTTPRequest *TaskResultHTTPRequest `json:"httpRequest,omitempty" bson:"httpRequest,omitempty"` //nolint:lll HTTPResponse *TaskResultHTTPResponse `json:"httpResponse,omitempty" bson:"httpResponse,omitempty"` NATS *TaskResultNATS `json:"nats,omitempty" bson:"nats,omitempty"` SMTP *TaskResultSMTP `json:"smtp,omitempty" bson:"smtp,omitempty"` }
TaskResult contains the result of the execution of a task
type TaskResultCLI ¶
type TaskResultCLI struct { Command []string `json:"command" bson:"command"` Output string `json:"output" bson:"output"` Error string `json:"error" bson:"error"` ExitCode int `json:"exitCode" bson:"exitCode"` }
TaskResultCLI contains the CLI command, the output and the exit status
type TaskResultHTTPRequest ¶
type TaskResultHTTPRequest struct { URI string `json:"uri" bson:"uri"` Method string `json:"method" bson:"method"` Body string `json:"body" bson:"body"` Headers []string `json:"headers" bson:"headers"` }
TaskResultHTTPRequest contains the request
type TaskResultHTTPResponse ¶
type TaskResultHTTPResponse struct { StatusCode int `json:"statusCode" bson:"status_code"` Body string `json:"body" bson:"body"` }
TaskResultHTTPResponse contains the response
type TaskResultNATS ¶
type TaskResultNATS struct {
Error string `json:"error" bson:"error"`
}
type TaskResultSMTP ¶
type TaskResultSMTP struct { Sender string `json:"sender" bson:"sender"` Recipients []string `json:"recipients" bson:"recipients"` Message string `json:"message" bson:"message"` Error string `json:"error" bson:"error"` }
TaskResultSMTP contains the SMTP message, the output and the exit status
type Workflow ¶
type Workflow struct { Name string `json:"name" bson:"_id"` Topic string `json:"topic" bson:"topic"` Ephemeral bool `json:"ephemeral" bson:"ephemeral"` Description string `json:"description" bson:"description"` Version int `json:"version" bson:"version"` SchemaVersion int `json:"schemaVersion" bson:"schema_version"` Tasks []Task `json:"tasks" bson:"tasks"` InputParameters []string `json:"inputParameters" bson:"input_parameters"` OptionalParameters []string `json:"optionalParameters" bson:"optional_parameters,omitempty"` }
Workflow stores the definition of a workflow
func ParseWorkflowFromJSON ¶
ParseWorkflowFromJSON parse a JSON string and returns a Workflow struct