Documentation ¶
Index ¶
- Constants
- Variables
- func ConnectNodes(parent, child Node)
- func DisconnectNodes(parent, child Node)
- func EventTypeToNodeEventName(eventType string) string
- func EventTypeToWorkflowEventName(eventType string) string
- func LoggerEventHandlerAdapter(i astikit.StdLogger, h *EventHandler)
- type BaseNode
- func (n *BaseNode) AddChild(i Node)
- func (n *BaseNode) AddParent(i Node)
- func (n *BaseNode) AddStats(ss ...astikit.StatOptions)
- 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) Status() string
- func (n *BaseNode) Stop()
- type BaseNodeExecFunc
- type BaseNodeStartFunc
- type CreateTaskFunc
- type Event
- type EventCallback
- 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 EventTypeTransformer
- type Node
- type NodeChild
- type NodeChildMapper
- type NodeDescriptor
- type NodeMetadata
- type NodeOptions
- type NodeParent
- type NodeParentMapper
- type Server
- type ServerNode
- type ServerOptions
- type ServerStat
- type ServerWelcome
- type ServerWorkflow
- 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) NewRecording(o WorkflowRecordingOptions) (r *WorkflowRecording)
- 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 WorkflowRecording
- type WorkflowRecordingOptions
- type WorkflowStartGroup
- type WorkflowStartOptions
Constants ¶
const ( StatusPaused = "paused" StatusRunning = "running" StatusStopped = "stopped" )
Statuses
const (
StatNamePSUtil = "astiencoder.ps.util"
)
Variables ¶
var ( EventNameError = "astiencoder.error" EventNameNodeContinued = "astiencoder.node.continued" EventNameNodePaused = "astiencoder.node.paused" EventNameNodeStarted = "astiencoder.node.started" EventNameNodeStopped = "astiencoder.node.stopped" EventNameStats = "astiencoder.stats" EventNameWorkflowContinued = "astiencoder.workflow.continued" EventNameWorkflowPaused = "astiencoder.workflow.paused" EventNameWorkflowStarted = "astiencoder.workflow.started" EventNameWorkflowStopped = "astiencoder.workflow.stopped" EventTypeContinued = "continued" EventTypePaused = "paused" EventTypeStarted = "started" EventTypeStopped = "stopped" )
Default event names
Functions ¶
func EventTypeToNodeEventName ¶ added in v0.12.0
EventTypeToNodeEventName is the node EventTypeTransformer
func EventTypeToWorkflowEventName ¶ added in v0.12.0
EventTypeToWorkflowEventName is the workflow EventTypeTransformer
func LoggerEventHandlerAdapter ¶
func LoggerEventHandlerAdapter(i astikit.StdLogger, h *EventHandler)
LoggerEventHandlerAdapter adapts the event handler so that it logs the events properly
Types ¶
type BaseNode ¶
type BaseNode struct {
// contains filtered or unexported fields
}
BaseNode represents a base node
func NewBaseNode ¶
func NewBaseNode(o NodeOptions, eh *EventHandler, s *Stater, target interface{}, et EventTypeTransformer) *BaseNode
NewBaseNode creates a new base node
func (*BaseNode) AddStats ¶ added in v0.12.0
func (n *BaseNode) AddStats(ss ...astikit.StatOptions)
AddStats adds stats
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
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 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 EventStat ¶
type EventStat struct { Description string Label string Name string Target interface{} Unit string Value interface{} }
EventStat represents a stat event
type EventTypeTransformer ¶ added in v0.12.0
EventTypeTransformer represents a function capable of transforming an event type to an event name
type Node ¶
type Node interface { NodeChild NodeDescriptor NodeParent Starter }
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, tags ...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 Server ¶ added in v0.9.0
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶ added in v0.9.0
func NewServer(o ServerOptions) *Server
func (*Server) EventHandlerAdapter ¶ added in v0.9.0
func (s *Server) EventHandlerAdapter(eh *EventHandler)
func (*Server) SetWorkflow ¶ added in v0.9.0
type ServerNode ¶ added in v0.9.0
type ServerOptions ¶ added in v0.9.0
type ServerOptions struct {
Logger astikit.StdLogger
}
type ServerStat ¶ added in v0.9.0
type ServerWelcome ¶ added in v0.9.0
type ServerWelcome struct {
Workflow *ServerWorkflow `json:"workflow,omitempty"`
}
type ServerWorkflow ¶ added in v0.9.0
type ServerWorkflow struct { Name string `json:"name"` Nodes []ServerNode `json:"nodes"` Status string `json:"status"` }
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 struct {
// contains filtered or unexported fields
}
Stater represents an object that can compute and handle stats
func NewStater ¶ added in v0.12.0
func NewStater(period time.Duration, eh *EventHandler) (s *Stater)
NewStater creates a new stater
func (*Stater) AddStats ¶ added in v0.12.0
func (s *Stater) AddStats(target interface{}, os ...astikit.StatOptions)
AddStats adds stats
func (*Stater) DelStats ¶ added in v0.12.0
func (s *Stater) DelStats(target interface{}, os ...astikit.StatOptions)
DelStats deletes stats
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow represents a workflow
func NewWorkflow ¶
func NewWorkflow(ctx context.Context, name string, eh *EventHandler, tf CreateTaskFunc, c *astikit.Closer, s *Stater) (w *Workflow)
NewWorkflow creates a new workflow
func (*Workflow) NewRecording ¶ added in v0.9.0
func (w *Workflow) NewRecording(o WorkflowRecordingOptions) (r *WorkflowRecording)
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 WorkflowRecording ¶ added in v0.9.0
type WorkflowRecording struct {
// contains filtered or unexported fields
}
func (*WorkflowRecording) Start ¶ added in v0.9.0
func (r *WorkflowRecording) Start(ctx context.Context) (err error)
func (*WorkflowRecording) Stop ¶ added in v0.9.0
func (r *WorkflowRecording) Stop()
type WorkflowRecordingOptions ¶ added in v0.9.0
type WorkflowRecordingOptions struct { Dst string Logger astikit.StdLogger }
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