model

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: Apache-2.0 Imports: 22 Imported by: 11

Documentation

Index

Constants

View Source
const (
	//CatchTask  represent a task name that execute if error occurred and defined
	CatchTask = "catch"
	//DeferredTask represent a task name that always execute if defined
	DeferredTask = "defer"
	//ExplicitActionAttributePrefix represent model attribute prefix
	ExplicitActionAttributePrefix  = ":"
	ExplicitRequestAttributePrefix = "@"
)
View Source
const SliceKey = "data"

SliceKey represents slice key

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractNode

type AbstractNode struct {
	Name        string
	Description string
	Init        Variables `description:"state init instruction "`
	Post        Variables `description:"post execution state update instruction"`
	When        string    `description:"run criteria"`
	SleepTimeMs int       //optional Sleep time
	Logging     *bool     `description:"optional flag to disable logging, enabled by default"`
}

AbstractNode represents an abstract workflow node(of a workflow, task or acton type)

type Action

type Action struct {
	*AbstractNode
	*ServiceRequest
	*MetaTag
	*Repeater
	Async bool   `description:"flag to run action async"`
	Skip  string `description:"criteria to skip current TagID"`
}

Action represents a workflow service action

func (*Action) Clone added in v0.35.0

func (a *Action) Clone() *Action

Clone clones this actions

func (*Action) ID

func (a *Action) ID() string

ID returns action identified

func (*Action) Init

func (a *Action) Init() error

NewActivity returns pipeline activity

type ActionSelector

type ActionSelector string

ActionSelector represents an expression to invoke endly action: service.Action (for workflow service workflow keyword can be skipped)

func (*ActionSelector) Action

func (s *ActionSelector) Action() string

Action returns action

func (ActionSelector) Service

func (s ActionSelector) Service() string

Service returns service

type Activities

type Activities struct {
	Activity *Activity
	// contains filtered or unexported fields
}

Activities represents activities

func NewActivities

func NewActivities() *Activities

NewActivities creates a new activites

func (*Activities) First

func (a *Activities) First() *Activity

func (*Activities) Get

func (a *Activities) Get(index int) *Activity

Get returns activity for index

func (*Activities) Last

func (a *Activities) Last() *Activity

func (*Activities) Len

func (a *Activities) Len() int

func (*Activities) Pop

func (a *Activities) Pop() *Activity

Pop removes last activity

func (*Activities) Push

func (a *Activities) Push(activity *Activity)

Push add activity

func (*Activities) Range added in v0.25.1

func (a *Activities) Range(handler func(activity *Activity) bool, reverse bool)

Range iterates over all activities

type Activity

type Activity struct {
	*MetaTag
	Caller          string
	Task            string
	Service         string
	Action          string
	Description     string
	Error           string
	StartTime       time.Time
	Ineligible      bool
	Request         interface{}
	Response        map[string]interface{}
	ServiceResponse *endly.ServiceResponse
	Logging         *bool
}

Activity represents pipeline or workflow activity

func NewActivity

func NewActivity(context *endly.Context, action *Action, state data.Map) *Activity

NewActivity returns a new workflow Activity.

func (*Activity) FormatTag

func (a *Activity) FormatTag() string

FormatTag return a formatted tag

type ActivityEndEvent

type ActivityEndEvent struct {
	Response interface{}
}

ActivityEndEvent represents Activity end event type.

func NewActivityEndEvent

func NewActivityEndEvent(response interface{}) *ActivityEndEvent

NewActivityEndEvent creates a new ActivityEndEvent

type ExecutionError

type ExecutionError struct {
	Error    string
	Caller   string
	TaskName string
	Request  interface{}
	Response interface{}
}

Error represent workflow error

func (*ExecutionError) AsMap

func (e *ExecutionError) AsMap() map[string]interface{}

AsMap returns error map

type Extract

type Extract struct {
	RegExpr  string `description:"regular expression with oval bracket to extract match pattern"`            //regular expression
	Key      string `description:"state key to store a match"`                                               //state key to store a match
	Reset    bool   `description:"reset the key in the context before evaluating this data extraction rule"` //reset the key in the context before evaluating this data extraction rule
	Required bool   `description:"require that at least one pattern match is returned"`                      //require that at least one pattern match is returned
}

Extract represents a data extraction

func NewExtract

func NewExtract(key, regExpr string, reset bool, required bool) *Extract

NewExtract creates a new data extraction

type ExtractEvent added in v0.25.1

type ExtractEvent struct {
	Output           string
	StructuredOutput interface{}
	Data             interface{}
}

ExtractEvent represents data extraction event

func NewExtractEvent

func NewExtractEvent(output string, structuredOutput, extracted interface{}) *ExtractEvent

NewExtractEvent creates a new event.

type Extracts

type Extracts []*Extract

Extracts represents an expected data collection

func NewExtracts

func NewExtracts() Extracts

NewExtracts creates a new NewExtracts

func (*Extracts) Extract

func (d *Extracts) Extract(context *endly.Context, extracted map[string]interface{}, inputs ...string) error

Extracts extract data from provided inputs, the result is placed to expected map, or error

func (*Extracts) Reset

func (d *Extracts) Reset(state data.Map)

Reset removes key from supplied state map.

type InlineWorkflow

type InlineWorkflow struct {
	Init     interface{}
	Post     interface{}
	Logging  *bool
	Defaults map[string]interface{}
	Data     map[string]interface{}
	Pipeline []*MapEntry
	State    data.Map
	// contains filtered or unexported fields
}

func (*InlineWorkflow) AsWorkflow

func (p *InlineWorkflow) AsWorkflow(name string, baseURL string) (*Workflow, error)

type MapEntry

type MapEntry struct {
	Key   string      `description:"preserved order map entry key"`
	Value interface{} `description:"preserved order map entry value"`
}

type MetaTag added in v0.25.1

type MetaTag struct {
	Tag            string //tag
	TagIndex       string //tag index
	TagID          string //tag id
	TagDescription string //tag description
	Comments       string
}

MetaTag represent a node tag

type ModifiedStateEvent

type ModifiedStateEvent struct {
	Variables Variables
	In        map[string]interface{}
	Modified  map[string]interface{}
}

ModifiedStateEvent represent modified state event

func NewModifiedStateEvent

func NewModifiedStateEvent(variables Variables, in, out data.Map) *ModifiedStateEvent

NewModifiedStateEvent creates a new modified state event.

type OperatingSystem

type OperatingSystem struct {
	System       string
	Name         string
	Hardware     string
	Architecture string
	Arch         string //architecture abbreviation
	Version      string
}

Os represents an Os

func (*OperatingSystem) Matches

func (s *OperatingSystem) Matches(target *OsTarget) bool

Matches returns true if operating system matches provided target

type OsTarget

type OsTarget struct {
	System             string
	Name               string
	MinRequiredVersion string
	MaxAllowedVersion  string
}

OsTarget represents operating system target

type Path

type Path struct {
	Items []string
	// contains filtered or unexported fields
}

Path represents a system path

func NewPath

func NewPath(items ...string) *Path

NewSystemPath create a new system path.

func (*Path) EnvValue

func (p *Path) EnvValue() string

EnvValue returns evn values

func (*Path) Unshift

func (p *Path) Unshift(paths ...string)

Unshift add path at the begining to the system paths

type Process

type Process struct {
	Source   *url.Resource
	Owner    string
	TagIDs   map[string]bool
	HasTagID bool
	Workflow *Workflow
	Task     *Task
	TaskNode *TasksNode
	*Activities
	State      data.Map
	Terminated int32
	Scheduled  *Task
	*ExecutionError
}

Process represents a running instance of workflow/pipeline process.

func NewProcess

func NewProcess(source *url.Resource, workflow *Workflow, upstream *Process) *Process

NewProcess creates a new workflow, pipeline process

func (*Process) AddTagIDs

func (p *Process) AddTagIDs(tagIDs ...string)

Push adds a workflow to the workflow stack.

func (*Process) CanRun

func (p *Process) CanRun() bool

CanRun returns true if current workflow can run

func (*Process) IsTerminated

func (p *Process) IsTerminated() bool

IsTerminated returns true if current workflow has been terminated

func (*Process) Push

func (p *Process) Push(activity *Activity)

Push adds supplied activity

func (*Process) SetTask

func (p *Process) SetTask(task *Task)

SetTask sets process task

func (*Process) Terminate

func (p *Process) Terminate()

Terminate flags current workflow as terminated

type Processes

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

processes represents running workflow/pipe process stack.

func NewProcesses

func NewProcesses() *Processes

NewProcesses creates a new processes

func (*Processes) First

func (p *Processes) First() *Process

First returns the first process.

func (*Processes) FirstWorkflow

func (p *Processes) FirstWorkflow() *Process

FirstWorkflow returns the first workflow.

func (*Processes) Last

func (p *Processes) Last() *Process

Last returns the last process.

func (*Processes) LastWorkflow

func (p *Processes) LastWorkflow() *Process

LastWorkflow returns the last workflow.

func (*Processes) Pop

func (p *Processes) Pop() *Process

Pop removes the first workflow from the workflow stack.

func (*Processes) Push

func (p *Processes) Push(process *Process)

Push adds a workflow to the workflow stack.

func (*Processes) Recent

func (p *Processes) Recent(count int) []*Process

Recent returns the most reset process.

type Repeater

type Repeater struct {
	Extract     Extracts  //textual regexp based data extraction
	Variables   Variables //structure data based data extraction
	Repeat      int       //how many time send this request
	SleepTimeMs int       //Sleep time after request send, this only makes sense with repeat option
	Exit        string    //Exit criteria, it uses expected variable to determine repeat termination
}

Repeater represent repeated execution

func NewRepeater

func NewRepeater() *Repeater

NewRepeater creates a new repeatable struct

func (*Repeater) EvaluateExitCriteria

func (r *Repeater) EvaluateExitCriteria(callerInfo string, context *endly.Context, extracted map[string]interface{}) (bool, error)

EvaluateExitCriteria check is exit criteria is met.

func (*Repeater) Init

func (r *Repeater) Init() *Repeater

Get returns non empty instance of default instance

func (*Repeater) Run

func (r *Repeater) Run(service *endly.AbstractService, callerInfo string, context *endly.Context, handler func() (interface{}, error), extracted map[string]interface{}) error

Run repeats x times supplied handler

type ServiceRequest

type ServiceRequest struct {
	Service string      `description:"service ID"`
	Action  string      `description:"service's'action "`
	Request interface{} `description:"service request"`
}

ServiceRequest represent an action request

func (*ServiceRequest) Init

func (r *ServiceRequest) Init() *ServiceRequest

Init initialises action

func (*ServiceRequest) NewAction

func (r *ServiceRequest) NewAction() *Action

func (*ServiceRequest) Validate

func (r *ServiceRequest) Validate() error

Validate check is action request is valid

type Session

type Session struct {
	ID string
	ssh.MultiCommandSession
	DaemonType       int
	Service          ssh.Service
	Os               *OperatingSystem
	Username         string
	SuperUSerAuth    bool
	Path             *Path
	EnvVariables     map[string]string
	CurrentDirectory string
	Deployed         map[string]string
	Cacheable        map[string]interface{}
	Mutex            *sync.RWMutex
}

Session represents a system terminal session

func NewSession

func NewSession(id string, connection ssh.Service) (*Session, error)

NewSession create a new client session

type Sessions

type Sessions map[string]*Session

Sessions represents a map of client sessions keyed by session id

func (*Sessions) Has

func (s *Sessions) Has(id string) bool

Has checks if client session exists for provided id.

type Task

type Task struct {
	*AbstractNode
	Actions []*Action //actions
	*TasksNode
	Fail bool //controls if return fail status workflow on catch task
	// contains filtered or unexported fields
}

Task represents a group of action

func NewTask

func NewTask(name string, multiAction bool) *Task

NewTask creates a new task

func (*Task) AsyncActions added in v0.21.2

func (t *Task) AsyncActions() []*Action

AsyncActions returns async actions

func (*Task) HasTagID

func (t *Task) HasTagID(tagIDs map[string]bool) bool

HasTagID checks if task has supplied tagIDs

type TasksNode

type TasksNode struct {
	Tasks        []*Task //sub tasks
	OnErrorTask  string  //task that will run if error occur, the final workflow will return this task response
	DeferredTask string  //task that will always run if there has been previous  error or not
}

TasksNode represents a task node

func (*TasksNode) Has

func (t *TasksNode) Has(name string) bool

Task returns a task for supplied name

func (*TasksNode) Select

func (t *TasksNode) Select(selector TasksSelector) *TasksNode

Select selects tasks matching supplied selector

func (*TasksNode) Task

func (t *TasksNode) Task(name string) (*Task, error)

Task returns a task for supplied name

type TasksSelector

type TasksSelector string

TasksSelector represents a task selector

func (*TasksSelector) RunAll

func (t *TasksSelector) RunAll() bool

RunAll returns true if no individual tasks are selected

func (*TasksSelector) Tasks

func (t *TasksSelector) Tasks() []string

Tasks return tasks

type Template

type Template struct {
	SubPath     string            `description:"sub path for dynamic resource template expansion: i.e. use_cases/${index}*"`
	Tag         string            `description:"grouping tag i.e Test"`
	Range       string            `description:"range expression i.e 2..003  where upper bound number drives padding $index variable"`
	Description string            `description:"reference to file containing tagDescription i.e. @use_case,  file reference has to start with @"`
	Data        map[string]string `` /* 181-byte string literal not displayed */
	Template    []interface{}
	// contains filtered or unexported fields
}

Template represents inline workflow template to dynamically Expand actions - idea borrowed from neatly format: https://github.com/viant/neatly/

func (*Template) Expand

func (t *Template) Expand(task *Task, parentTag string, inline *InlineWorkflow) error

type Variable

type Variable struct {
	Name              string            `description:"name"`
	Value             interface{}       `description:"default value"`
	From              string            `description:"context state map key to pull data"`
	When              string            `` /* 139-byte string literal not displayed */
	Else              interface{}       `description:"if when criteria is not met then else can provide variable value alternative"`
	Persist           bool              `description:"stores in tmp directory to be used as backup if data is not in the cotnext"`
	Required          bool              `description:"flag that validates that from returns non empty value or error is generated"`
	EmptyIfUnexpanded bool              `description:"threat variable value empty if it was not expanded"`
	Replace           map[string]string `` /* 147-byte string literal not displayed */
}

Variable represents a variable

func NewVariable

func NewVariable(name, form, when string, required bool, value, elseValue interface{}, replace map[string]string, emptyIfUnexpanded bool) *Variable

NewVariable creates a new variable

func (*Variable) Apply

func (v *Variable) Apply(in, out data.Map) error

func (*Variable) Load

func (v *Variable) Load() error

Load loads persisted variable value.

func (*Variable) PersistValue

func (v *Variable) PersistValue() error

PersistValue persist variable

type VariableExpression

type VariableExpression string

VariableExpression represent a variable expression [!] VariableName = [when ?] value : otherwiseValue, exclamation mark flags variable as required

func (*VariableExpression) AsVariable

func (e *VariableExpression) AsVariable() (*Variable, error)

AsVariable converts expression to variable

type Variables

type Variables []*Variable

Variables a slice of variables

func GetVariables

func GetVariables(baseURLs []string, source interface{}) (Variables, error)

GetVariables returns variables from Variables ([]*Variable), []string (as expression) or from []interface{} (where interface is a map matching Variable struct)

func (*Variables) Apply

func (v *Variables) Apply(in, out data.Map) error

Apply evaluates all variable from in map to out map

func (Variables) String

func (v Variables) String() string

String returns a variable info

type Workflow

type Workflow struct {
	Source *url.Resource //source definition of the workflow
	Data   data.Map      //workflow data
	*AbstractNode
	*TasksNode //workflow tasks
}

Workflow represents a workflow

func (*Workflow) Init

func (w *Workflow) Init() error

Validate validates this workflow

func (*Workflow) Validate

func (w *Workflow) Validate() error

Validate validates this workflow

type WorkflowSelector

type WorkflowSelector string

WorkflowSelector represents an expression to invoke workflow with all or specified task: URL[:tasks]

func (WorkflowSelector) IsRelative

func (s WorkflowSelector) IsRelative() bool

IsRelative returns true if selector is relative path

func (WorkflowSelector) Name

func (s WorkflowSelector) Name() string

Name returns selector workflow name

func (WorkflowSelector) Tasks

func (s WorkflowSelector) Tasks() string

TasksSelector returns selector tasks

func (WorkflowSelector) URL

func (s WorkflowSelector) URL() string

URL returns workflow url

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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