types

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: GPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

const (
	DataTypeAny     DataType = "any"
	DataTypeString  DataType = "string"
	DataTypeNumber  DataType = "number"
	DataTypeBoolean DataType = "boolean"
	DataTypeObject  DataType = "object"
	DataTypeArray   DataType = "array"
)

func InferDataType

func InferDataType(v any) DataType

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

func NewMessage(payload interface{}, payloadType DataType) *Message

NewMessage creates a new Message with a generated UUID and timestamp.

func (*Message) Clone

func (m *Message) Clone() *Message

Clone creates a deep copy of the message.

func (*Message) GetMeta

func (m *Message) GetMeta(key string) (interface{}, bool)

GetMeta retrieves a metadata value from the message.

func (*Message) SetMeta

func (m *Message) SetMeta(key string, value interface{})

SetMeta sets a metadata value on the message.

func (*Message) WithPayload

func (m *Message) WithPayload(payload interface{}, payloadType DataType) *Message

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.

type User

type User struct {
	Username string `json:"username"`
	// PasswordHash is the bcrypt hash of the password (never exposed in JSON).
	PasswordHash string `json:"-"`
}

User represents a user in the system. This type is defined in types to avoid import cycles between api and storage.

Jump to

Keyboard shortcuts

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