Documentation
¶
Overview ¶
Package types provides shared type definitions for the PiWorker flow system. This package exists to break import cycles between the flow and node packages.
Index ¶
Constants ¶
const ErrorPort = "error"
ErrorPort is the output port every node that processes messages has besides the ones it declares (ADR-0036): when the node fails, the runtime sends the failure out of it. A node type cannot declare an output with this ID.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataType ¶
type DataType string
DataType represents the type of data a port can handle.
func InferDataType ¶
InferDataType is the payload type hint of a Go value as nodes produce and decode them (JSON-shaped values and Go numbers); DataTypeAny for anything else.
type Message ¶
type Message struct {
ID string `json:"id"`
Payload interface{} `json:"payload"` // The actual data
PayloadType DataType `json:"payloadType"` // Type hint for the payload
Topic string `json:"topic"` // Optional topic for routing
Meta map[string]interface{} `json:"meta"` // Additional metadata
Timestamp time.Time `json:"timestamp"`
SourceNode string `json:"sourceNode"` // ID of the node that produced this message
SourcePort string `json:"sourcePort"` // ID of the port that produced this message
}
Message represents data flowing between nodes.
func NewMessage ¶
NewMessage creates a new Message with a generated UUID and timestamp.
func (*Message) WithPayload ¶
WithPayload returns a new message with the updated payload.
type NodeCategory ¶
type NodeCategory string
NodeCategory represents the functional category of a node.
const ( // NodeCategoryInput represents trigger/input nodes that initiate flow execution. NodeCategoryInput NodeCategory = "input" // NodeCategoryProcessing represents nodes that transform or process data. NodeCategoryProcessing NodeCategory = "processing" // NodeCategoryOutput represents nodes that perform actions or produce output. NodeCategoryOutput NodeCategory = "output" )
type Port ¶
type Port struct {
ID string `json:"id"`
Name string `json:"name"`
DataType DataType `json:"dataType"`
Multiple bool `json:"multiple"` // Whether this port can have multiple connections
Required bool `json:"required"` // Whether this port must be connected (for inputs)
}
Port represents an input or output connection point on a node.