Documentation ¶
Index ¶
- Constants
- Variables
- func ConnectNodes(parent, child Node)
- func DisconnectNodes(parent, child Node)
- func LoggerEventHandlerAdapter(h *EventHandler)
- func WriteJSONError(rw http.ResponseWriter, code int, err error)
- type BaseNode
- func (n *BaseNode) AddChild(i Node)
- func (n *BaseNode) AddParent(i Node)
- func (n *BaseNode) ChildIsStarted(m NodeMetadata)
- func (n *BaseNode) ChildIsStopped(m NodeMetadata)
- func (n *BaseNode) Children() (ns []Node)
- func (n *BaseNode) Context() context.Context
- func (n *BaseNode) Continue()
- func (n *BaseNode) DelChild(i Node)
- func (n *BaseNode) DelParent(i Node)
- func (n *BaseNode) HandlePause()
- func (n *BaseNode) Metadata() NodeMetadata
- func (n *BaseNode) ParentIsStarted(m NodeMetadata)
- func (n *BaseNode) ParentIsStopped(m NodeMetadata)
- func (n *BaseNode) Parents() (ns []Node)
- func (n *BaseNode) Pause()
- func (n *BaseNode) Start(ctx context.Context, tc CreateTaskFunc, execFunc BaseNodeExecFunc)
- func (n *BaseNode) Stater() *astikit.Stater
- func (n *BaseNode) Status() string
- func (n *BaseNode) Stop()
- type BaseNodeExecFunc
- type BaseNodeStartFunc
- type CreateTaskFunc
- type Event
- type EventCallback
- type EventGenerator
- type EventGeneratorNode
- type EventGeneratorWorkflow
- type EventHandler
- func (h *EventHandler) Add(target interface{}, eventName string, c EventCallback)
- func (h *EventHandler) AddForAll(c EventCallback)
- func (h *EventHandler) AddForEventName(eventName string, c EventCallback)
- func (h *EventHandler) AddForTarget(target interface{}, c EventCallback)
- func (h *EventHandler) Emit(e Event)
- type EventStat
- type ExposedError
- type ExposedReferences
- type ExposedStat
- type ExposedStatMetadata
- type ExposedStats
- type ExposedWorkflow
- type ExposedWorkflowBase
- type ExposedWorkflowEdge
- type ExposedWorkflowNode
- type Node
- type NodeChild
- type NodeChildMapper
- type NodeDescriptor
- type NodeMetadata
- type NodeOptions
- type NodeParent
- type NodeParentMapper
- type Starter
- type Stater
- type Workflow
- func (w *Workflow) AddChild(n Node)
- func (w *Workflow) Children() []Node
- func (w *Workflow) Continue()
- func (w *Workflow) DelChild(n Node)
- func (w *Workflow) Name() string
- func (w *Workflow) Pause()
- func (w *Workflow) Start()
- func (w *Workflow) StartNodes(ns ...Node)
- func (w *Workflow) StartNodesInSubTask(ns ...Node) (t *astikit.Task)
- func (w *Workflow) StartWithOptions(o WorkflowStartOptions)
- func (w *Workflow) Status() string
- func (w *Workflow) Stop()
- type WorkflowPool
- type WorkflowStartGroup
- type WorkflowStartOptions
Constants ¶
const ( StatusPaused = "paused" StatusRunning = "running" StatusStopped = "stopped" )
Statuses
Variables ¶
var ( EventNameError = "astiencoder.error" EventNameNodeContinued = "astiencoder.node.continued" EventNameNodePaused = "astiencoder.node.paused" EventNameNodeStarted = "astiencoder.node.started" EventNameNodeStats = "astiencoder.node.stats" EventNameNodeStopped = "astiencoder.node.stopped" EventNameWorkflowContinued = "astiencoder.workflow.continued" EventNameWorkflowPaused = "astiencoder.workflow.paused" EventNameWorkflowStarted = "astiencoder.workflow.started" EventNameWorkflowStats = "astiencoder.workflow.stats" EventNameWorkflowStopped = "astiencoder.workflow.stopped" EventTypeContinued = "continued" EventTypePaused = "paused" EventTypeStarted = "started" EventTypeStats = "stats" EventTypeStopped = "stopped" )
Default event names
var (
ErrWorkflowNotFound = errors.New("astiencoder: workflow.not.found")
)
Errors
Functions ¶
func LoggerEventHandlerAdapter ¶
func LoggerEventHandlerAdapter(h *EventHandler)
LoggerEventHandlerAdapter adapts the event handler so that it logs the events properly
func WriteJSONError ¶
func WriteJSONError(rw http.ResponseWriter, code int, err error)
WriteJSONError writes a JSON error
Types ¶
type BaseNode ¶
type BaseNode struct {
// contains filtered or unexported fields
}
BaseNode represents a base node
func NewBaseNode ¶
func NewBaseNode(o NodeOptions, eg EventGenerator, eh *EventHandler) (n *BaseNode)
NewBaseNode creates a new base node
func (*BaseNode) ChildIsStarted ¶
func (n *BaseNode) ChildIsStarted(m NodeMetadata)
ChildIsStarted implements the NodeParent interface
func (*BaseNode) ChildIsStopped ¶
func (n *BaseNode) ChildIsStopped(m NodeMetadata)
ChildIsStopped implements the NodeParent interface
func (*BaseNode) Metadata ¶
func (n *BaseNode) Metadata() NodeMetadata
Metadata implements the Node interface
func (*BaseNode) ParentIsStarted ¶
func (n *BaseNode) ParentIsStarted(m NodeMetadata)
ParentIsStarted implements the NodeChild interface
func (*BaseNode) ParentIsStopped ¶
func (n *BaseNode) ParentIsStopped(m NodeMetadata)
ParentIsStopped implements the NodeChild interface
func (*BaseNode) Start ¶
func (n *BaseNode) Start(ctx context.Context, tc CreateTaskFunc, execFunc BaseNodeExecFunc)
Start starts the node
func (*BaseNode) Stater ¶
func (n *BaseNode) Stater() *astikit.Stater
Stater returns the node stater
type BaseNodeExecFunc ¶
type BaseNodeExecFunc func(t *astikit.Task)
BaseNodeExecFunc represents a node exec func
type BaseNodeStartFunc ¶
type BaseNodeStartFunc func()
BaseNodeStartFunc represents a node start func
type CreateTaskFunc ¶
type CreateTaskFunc func() *astikit.Task
CreateTaskFunc is a method that can create a task
type Event ¶
type Event struct { Name string Payload interface{} Target interface{} }
Event is an event coming out of the encoder
func EventError ¶
EventError returns an error event
type EventCallback ¶
EventCallback represents an event callback
type EventGenerator ¶
EventGenerator represents an object capable of generating an event based on its type
type EventGeneratorNode ¶
type EventGeneratorNode struct {
// contains filtered or unexported fields
}
EventGeneratorNode represents a node event generator
func NewEventGeneratorNode ¶
func NewEventGeneratorNode(n Node) *EventGeneratorNode
NewEventGeneratorNode creates a new node event generator
func (EventGeneratorNode) Event ¶
func (g EventGeneratorNode) Event(eventType string, payload interface{}) Event
Event implements the EventGenerator interface
type EventGeneratorWorkflow ¶
type EventGeneratorWorkflow struct {
// contains filtered or unexported fields
}
EventGeneratorWorkflow represents a workflow event generator
func NewEventGeneratorWorkflow ¶
func NewEventGeneratorWorkflow(w *Workflow) *EventGeneratorWorkflow
NewEventGeneratorWorkflow creates a new workflow event generator
func (EventGeneratorWorkflow) Event ¶
func (g EventGeneratorWorkflow) Event(eventType string, payload interface{}) Event
Event implements the EventGenerator interface
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
EventHandler represents an event handler
func NewEventHandler ¶
func NewEventHandler() *EventHandler
NewEventHandler creates a new event handler
func (*EventHandler) Add ¶
func (h *EventHandler) Add(target interface{}, eventName string, c EventCallback)
Add adds a new callback for a specific target and event name
func (*EventHandler) AddForAll ¶
func (h *EventHandler) AddForAll(c EventCallback)
AddForAll adds a new callback for all events
func (*EventHandler) AddForEventName ¶
func (h *EventHandler) AddForEventName(eventName string, c EventCallback)
AddForEventName adds a new callback for a specific event name
func (*EventHandler) AddForTarget ¶
func (h *EventHandler) AddForTarget(target interface{}, c EventCallback)
AddForTarget adds a new callback for a specific target
type ExposedError ¶
type ExposedError struct {
Message string `json:"message"`
}
ExposedError represents an exposed error.
type ExposedReferences ¶
ExposedReferences represents the exposed references.
type ExposedStat ¶
type ExposedStat struct { Description string `json:"description"` Label string `json:"label"` Unit string `json:"unit"` Value interface{} `json:"value"` }
ExposedStat represents an exposed stat
type ExposedStatMetadata ¶
type ExposedStatMetadata struct { Description string `json:"description"` Label string `json:"label"` Unit string `json:"unit"` }
ExposedStatMetadata represents exposed stat metadata
type ExposedStats ¶
type ExposedStats struct { Name string `json:"name"` Stats []ExposedStat `json:"stats"` }
ExposedStats represents exposed stats
type ExposedWorkflow ¶
type ExposedWorkflow struct { ExposedWorkflowBase Edges []ExposedWorkflowEdge `json:"edges"` Nodes []ExposedWorkflowNode `json:"nodes"` }
ExposedWorkflow represents an exposed workflow
type ExposedWorkflowBase ¶
ExposedWorkflowBase represents a base exposed encoder workflow
type ExposedWorkflowEdge ¶
ExposedWorkflowEdge represents an exposed workflow edge
type ExposedWorkflowNode ¶
type ExposedWorkflowNode struct { Description string `json:"description"` Label string `json:"label"` Name string `json:"name"` Stats []ExposedStatMetadata `json:"stats"` Status string `json:"status"` }
ExposedWorkflowNode represents an exposed workflow node
type Node ¶
type Node interface { NodeChild NodeDescriptor NodeParent Starter Stater }
Node represents a node
type NodeChild ¶
type NodeChild interface { NodeChildMapper ParentIsStarted(m NodeMetadata) ParentIsStopped(m NodeMetadata) }
NodeChild represents an object with parent nodes
type NodeChildMapper ¶
NodeChildMapper represents an object that can play with its parents map
type NodeDescriptor ¶
type NodeDescriptor interface {
Metadata() NodeMetadata
}
NodeDescriptor represents an object that can describe a node
type NodeMetadata ¶
NodeMetadata represents node metadata
func (NodeMetadata) Extend ¶
func (m NodeMetadata) Extend(name, label, description string) NodeMetadata
Extend extends the node metadata
type NodeOptions ¶
type NodeOptions struct { Metadata NodeMetadata NoIndirectStop bool }
NodeOptions represents node options
type NodeParent ¶
type NodeParent interface { NodeParentMapper ChildIsStarted(m NodeMetadata) ChildIsStopped(m NodeMetadata) }
NodeParent represents an object with child nodes
type NodeParentMapper ¶
NodeParentMapper represents an object that can play with its children map
type Starter ¶
type Starter interface { Continue() Pause() Start(ctx context.Context, t CreateTaskFunc) Status() string Stop() }
Starter represents an object that can start/pause/continue/stop
type Stater ¶
type Stater interface {
Stater() *astikit.Stater
}
Stater represents an object that can return its stater
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow represents a workflow
func NewWorkflow ¶
func NewWorkflow(ctx context.Context, name string, e *EventHandler, tf CreateTaskFunc, c *astikit.Closer) (w *Workflow)
NewWorkflow creates a new workflow
func (*Workflow) StartNodesInSubTask ¶
StartNodesInSubTask starts nodes in a new sub task
func (*Workflow) StartWithOptions ¶
func (w *Workflow) StartWithOptions(o WorkflowStartOptions)
StartWithOptions starts the workflow with options
type WorkflowPool ¶
type WorkflowPool struct {
// contains filtered or unexported fields
}
WorkflowPool represents a workflow pool
func NewWorkflowPool ¶
func NewWorkflowPool() *WorkflowPool
NewWorkflowPool creates a new workflow pool
func (*WorkflowPool) AddWorkflow ¶
func (wp *WorkflowPool) AddWorkflow(w *Workflow)
AddWorkflow adds a new workflow
func (*WorkflowPool) Serve ¶
func (wp *WorkflowPool) Serve(eh *EventHandler, pathWeb string, fn func(http.Handler)) (err error)
Serve spawns the workflow pool server
func (*WorkflowPool) Workflow ¶
func (wp *WorkflowPool) Workflow(name string) (w *Workflow, err error)
Workflow retrieves a workflow from the pool
func (*WorkflowPool) Workflows ¶
func (wp *WorkflowPool) Workflows() (ws []*Workflow)
Workflows returns all the workflows
type WorkflowStartGroup ¶
type WorkflowStartGroup struct { Callback func(t *astikit.Task) Nodes []Node }
WorkflowStartGroup represents a workflow start group
type WorkflowStartOptions ¶
type WorkflowStartOptions struct {
Groups []WorkflowStartGroup
}
WorkflowStartOptions represents workflow start options