Documentation
¶
Overview ¶
Package models defines core node-based workflow models for graph execution
Package models defines port-based workflow models for node connections.
Package models defines the core domain models for node-based workflow automation
Index ¶
- Constants
- func MakePortID(nodeID, portName string) string
- func ParsePortID(portID string) (string, string, bool)
- type CategoryType
- type Connection
- type EventDefinition
- type EventFormat
- type ExecutionContext
- type ExecutionStatus
- type Firing
- type InputPort
- type Job
- type NodeResult
- type NodeStatus
- type OutputPort
- type Port
- type PortDirection
- type RemoteNodeType
- type RetryPolicy
- type Schedule
- type TenantSource
- type TriggerNodeMatch
- type Workflow
- type WorkflowNode
- type WorkflowStatus
Constants ¶
const ( NodeTypeTriggerWebhook = "trigger:webhook" NodeTypeTriggerScheduler = "trigger:scheduler" NodeTypeTriggerKafka = "trigger:kafka" NodeTypeTriggerEvent = "trigger:event" )
Built-in trigger node types.
Variables ¶
This section is empty.
Functions ¶
func MakePortID ¶
MakePortID creates a port ID from node ID and port name.
Types ¶
type CategoryType ¶
type CategoryType string
CategoryType represents the category of node.
const ( CategoryTypeAction CategoryType = "action" // Regular action nodes (http, log, transform, etc.) CategoryTypeTrigger CategoryType = "trigger" // Trigger nodes (webhook, scheduler, kafka, etc.) )
type Connection ¶
type Connection struct {
ID string `json:"id"`
SourcePort string `json:"source_port" validate:"required"` // References Port.ID: "{node_id}:{port_name}"
TargetPort string `json:"target_port" validate:"required"` // References Port.ID: "{node_id}:{port_name}"
}
Connection connects two ports directly (fully normalized).
type EventDefinition ¶
type EventDefinition struct {
Key string `json:"key"`
Name string `json:"name" validate:"required"`
Description string `json:"description"`
Topic string `json:"topic" validate:"required"`
Format EventFormat `json:"format" validate:"required,oneof=json avro protobuf"`
Schema map[string]any `json:"schema,omitempty"`
TenantFrom TenantSource `json:"tenant_from" validate:"required,oneof=payload header"`
TenantKey string `json:"tenant_key" validate:"required"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type EventFormat ¶
type EventFormat string
const ( EventFormatJSON EventFormat = "json" EventFormatAvro EventFormat = "avro" EventFormatProtobuf EventFormat = "protobuf" )
type ExecutionContext ¶
type ExecutionContext struct {
ID string `json:"id"`
WorkflowID string `json:"workflow_id" validate:"required"`
Status ExecutionStatus `json:"status"`
NodeResults map[string]NodeResult `json:"node_results"`
TriggerData map[string]any `json:"trigger_data,omitempty"`
Variables map[string]any `json:"variables,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
CreatedAt time.Time `json:"created_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Secrets map[string]string `json:"-"`
}
ExecutionContext represents the state of a node-based workflow execution.
type ExecutionStatus ¶
type ExecutionStatus string
ExecutionStatus represents the lifecycle state of a workflow execution.
const ( ExecutionStatusRunning ExecutionStatus = "running" ExecutionStatusCompleted ExecutionStatus = "completed" ExecutionStatusFailed ExecutionStatus = "failed" ExecutionStatusCancelled ExecutionStatus = "cancelled" ExecutionStatusTimeout ExecutionStatus = "timeout" ExecutionStatusPaused ExecutionStatus = "paused" )
type InputPort ¶
type InputPort struct {
Port
}
InputPort extends Port with input-specific properties.
func (InputPort) Direction ¶
func (p InputPort) Direction() PortDirection
Direction returns the direction of the port based on its type.
type NodeResult ¶
type NodeResult struct {
NodeID string `json:"node_id"`
Data map[string]any `json:"data"`
Status string `json:"status"`
Timestamp time.Time `json:"timestamp"`
Error string `json:"error,omitempty"`
}
NodeResult represents the result of a node execution.
type NodeStatus ¶
type NodeStatus string
NodeStatus defines the possible states of a node execution.
const ( NodeStatusPending NodeStatus = "pending" NodeStatusRunning NodeStatus = "running" NodeStatusSuccess NodeStatus = "success" NodeStatusError NodeStatus = "error" NodeStatusWaiting NodeStatus = "waiting" NodeStatusRetrying NodeStatus = "retrying" )
type OutputPort ¶
type OutputPort struct {
Port
}
OutputPort extends Port with output-specific properties.
func (OutputPort) Direction ¶
func (p OutputPort) Direction() PortDirection
Direction returns the direction of the port based on its type.
type Port ¶
type Port struct {
ID string `json:"id"` // Globally unique: "{nodeID}:{portName}"
NodeID string `json:"node_id"` // Which node this port belongs to
Name string `json:"name"` // Port name (unique within node)
Description string `json:"description"`
Schema map[string]any `json:"schema,omitempty"`
}
Port represents a connection point on a node.
type PortDirection ¶
type PortDirection string
PortDirection represents the direction of data flow for a port.
const ( PortDirectionInput PortDirection = "input" PortDirectionOutput PortDirection = "output" )
type RemoteNodeType ¶
type RemoteNodeType struct {
ID string `json:"id"`
Name string `json:"name" validate:"required"`
Description string `json:"description"`
URL string `json:"url" validate:"required,http_url"`
Secret string `json:"secret,omitempty" validate:"omitempty,min=16"`
Schema map[string]any `json:"schema,omitempty"`
Outputs []string `json:"outputs"`
TimeoutSeconds int `json:"timeout_seconds" validate:"gte=0,lte=300"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type RetryPolicy ¶
type TenantSource ¶
type TenantSource string
const ( TenantFromPayload TenantSource = "payload" TenantFromHeader TenantSource = "header" )
type TriggerNodeMatch ¶
type TriggerNodeMatch struct {
// WorkflowID identifies the workflow that contains the matching trigger node
WorkflowID string `json:"workflow_id"`
// TriggerNode contains the full workflow node configuration that matched
TriggerNode *WorkflowNode `json:"trigger_node"`
}
TriggerNodeMatch represents a trigger node that matches a source event. This is used by the activator to identify which trigger nodes should be activated when a source event is received.
type Workflow ¶
type Workflow struct {
ID string `json:"id"`
Name string `json:"name" validate:"required,min=3"`
Description string `json:"description" validate:"required"`
Status WorkflowStatus `json:"status" validate:"required"`
WorkflowGroupID string `json:"workflow_group_id" validate:"omitempty,uuid"` // Stable ID linking all versions
Nodes []*WorkflowNode `json:"nodes"` // Node instances in the workflow
Connections []*Connection `json:"connections"` // Connections between nodes
Variables map[string]any `json:"variables"`
Metadata map[string]any `json:"metadata,omitempty"`
Owner string `json:"owner"`
TenantID string `json:"tenant_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
PublishedAt *time.Time `json:"published_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
Workflow represents a node-based workflow with simplified versioning support.
type WorkflowNode ¶
type WorkflowNode struct {
ID string `json:"id" validate:"required"`
Type string `json:"type" validate:"required"`
Category CategoryType `json:"category" validate:"required"`
Config map[string]any `json:"config"`
PositionX int `json:"position_x"`
PositionY int `json:"position_y"`
Name string `json:"name" validate:"required,min=1"`
SourceID *string `json:"source_id,omitempty"` // For trigger nodes only
ProviderID *string `json:"provider_id,omitempty"` // For trigger nodes only
EventType *string `json:"event_type,omitempty"` // For trigger nodes only
Retry *RetryPolicy `json:"retry,omitempty"`
}
WorkflowNode represents a node instance in a workflow.
func (*WorkflowNode) IsActionNode ¶
func (n *WorkflowNode) IsActionNode() bool
Helper methods for category checking.
func (*WorkflowNode) IsTriggerNode ¶
func (n *WorkflowNode) IsTriggerNode() bool
type WorkflowStatus ¶
type WorkflowStatus string
WorkflowStatus represents the lifecycle state of a workflow.
const ( WorkflowStatusDraft WorkflowStatus = "draft" // Editable, not executable WorkflowStatusPublished WorkflowStatus = "published" // Current active, executable WorkflowStatusUnpublished WorkflowStatus = "unpublished" // Historical, not executable )