nodeconfig

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RolePlatformNode           = "platform_node"
	RoleDependentNode          = "dependent_node"
	RoleSensorEffectorEdgeNode = "sensor_effector_edge_node"

	DataPlaneTCPClient  = "tcp_client"
	DataPlaneQUICClient = "quic_client"
)

Variables

This section is empty.

Functions

func AllowedNodeTypeNames

func AllowedNodeTypeNames() []string

Types

type CapabilityConfig

type CapabilityConfig struct {
	Category string `yaml:"category"`
	Type     string `yaml:"type"`
	Value    string `yaml:"value"`
	Units    string `yaml:"units"`
}

type Config

type Config struct {
	SapientRole            string         `yaml:"sapient_role"`
	PlatformNode           NodeRoleConfig `yaml:"platform_node"`
	DependentNode          NodeRoleConfig `yaml:"dependent_node"`
	SensorEffectorEdgeNode NodeRoleConfig `yaml:"sensor_effector_edge_node"`
	Logging                LoggingConfig  `yaml:"logging"`
	Metrics                MetricsConfig  `yaml:"metrics"`
}

func Default

func Default() Config

func Load

func Load(path string) (Config, error)

func (Config) ActiveRole

func (c Config) ActiveRole() *NodeRoleConfig

func (Config) ActiveRoleInstances

func (c Config) ActiveRoleInstances() []NodeRoleConfig

func (*Config) ApplySocketDir

func (c *Config) ApplySocketDir(dir string)

ApplySocketDir relocates every local_socket device path in the configuration into dir, preserving each socket's base filename. This gives concurrent instances of the same scenario their own isolated socket arrays: pass the same -socket-dir to sapient-node and sapient-scenario-runner so both sides agree on the relocated paths. An empty dir leaves configured paths unchanged (backward compatible). Call after Load so source/location types are already normalized.

func (Config) Validate

func (c Config) Validate() error

type DeviceCANConfig

type DeviceCANConfig struct {
	Interface string `yaml:"interface"`
	Bitrate   int    `yaml:"bitrate"`
}

type DeviceGPIOConfig

type DeviceGPIOConfig struct {
	Chip  string `yaml:"chip"`
	Lines []int  `yaml:"lines"`
	Edge  string `yaml:"edge"`
}

type DeviceI2CConfig

type DeviceI2CConfig struct {
	Bus     string `yaml:"bus"`
	Address string `yaml:"address"`
}

type DeviceSPIConfig

type DeviceSPIConfig struct {
	Device  string `yaml:"device"`
	SpeedHz int    `yaml:"speed_hz"`
	Mode    int    `yaml:"mode"`
}

type DeviceSerialConfig

type DeviceSerialConfig struct {
	BaudRate      int    `yaml:"baud_rate"`
	DataBits      int    `yaml:"data_bits"`
	Parity        string `yaml:"parity"`
	StopBits      int    `yaml:"stop_bits"`
	ReadTimeoutMS int    `yaml:"read_timeout_ms"`
}

type DeviceSourceConfig

type DeviceSourceConfig struct {
	Name            string                   `yaml:"name"`
	NodeType        string                   `yaml:"node_type"`
	Type            string                   `yaml:"type"`
	Device          string                   `yaml:"device"`
	Interface       string                   `yaml:"interface"`
	URL             string                   `yaml:"url"`
	Pipeline        string                   `yaml:"pipeline"`
	Network         string                   `yaml:"network"`
	MaxMessageBytes int                      `yaml:"max_message_bytes"`
	ProbeOnStart    bool                     `yaml:"probe_on_start"`
	Required        bool                     `yaml:"required"`
	ProbeTimeoutMS  int                      `yaml:"probe_timeout_ms"`
	Format          DeviceSourceFormatConfig `yaml:"format"`
	Serial          DeviceSerialConfig       `yaml:"serial"`
	GPIO            DeviceGPIOConfig         `yaml:"gpio"`
	I2C             DeviceI2CConfig          `yaml:"i2c"`
	SPI             DeviceSPIConfig          `yaml:"spi"`
	CAN             DeviceCANConfig          `yaml:"can"`
	Vendor          DeviceVendorConfig       `yaml:"vendor"`
	Options         map[string]string        `yaml:"options"`
}

type DeviceSourceFormatConfig

type DeviceSourceFormatConfig struct {
	Width        int    `yaml:"width"`
	Height       int    `yaml:"height"`
	FrameRateFPS int    `yaml:"frame_rate_fps"`
	PixelFormat  string `yaml:"pixel_format"`
}

type DeviceVendorConfig

type DeviceVendorConfig struct {
	Driver   string `yaml:"driver"`
	DeviceID string `yaml:"device_id"`
	Library  string `yaml:"library"`
}

type LoggingConfig

type LoggingConfig struct {
	Level          string `yaml:"level"`
	AsyncQueueSize int    `yaml:"async_queue_size"`
}

type MediaConfig

type MediaConfig struct {
	Enabled           bool                       `yaml:"enabled"`
	StorageBackend    string                     `yaml:"storage_backend"`
	FileRoot          string                     `yaml:"file_root"`
	FileBaseURL       string                     `yaml:"file_base_url"`
	SnapshotPath      string                     `yaml:"snapshot_path"`
	SnapshotURL       string                     `yaml:"snapshot_url"`
	SnapshotMIMEType  string                     `yaml:"snapshot_mime_type"`
	SnapshotQueueSize int                        `yaml:"snapshot_upload_queue_size"`
	VideoPath         string                     `yaml:"video_path"`
	VideoURL          string                     `yaml:"video_url"`
	VideoMIMEType     string                     `yaml:"video_mime_type"`
	VideoTransport    string                     `yaml:"video_transport"`
	VideoGuidance     sapientmedia.VideoGuidance `yaml:"video_guidance"`
	S3                S3MediaConfig              `yaml:"s3"`
}

type MetricsConfig

type MetricsConfig struct {
	Enabled bool   `yaml:"enabled"`
	Address string `yaml:"address"`
}

type NodeDeviceConfig

type NodeDeviceConfig struct {
	NodeID                 string               `yaml:"node_id"`
	Name                   string               `yaml:"name"`
	ShortName              string               `yaml:"short_name"`
	StatusMode             string               `yaml:"status_mode"`
	NodeTypes              []string             `yaml:"node_types"`
	Capabilities           []CapabilityConfig   `yaml:"capabilities"`
	StaticRegistrationFile string               `yaml:"static_registration_file"`
	Source                 DeviceSourceConfig   `yaml:"source"`
	Sources                []DeviceSourceConfig `yaml:"sources"`
	Location               NodeLocationConfig   `yaml:"location"`
	Media                  MediaConfig          `yaml:"media"`
}

type NodeLocationConfig

type NodeLocationConfig struct {
	Type            string                   `yaml:"type"`
	Device          string                   `yaml:"device"`
	Network         string                   `yaml:"network"`
	Format          string                   `yaml:"format"`
	MaxMessageBytes int                      `yaml:"max_message_bytes"`
	Coordinates     *NodeLocationCoordinates `yaml:"coordinates"`
	Options         map[string]string        `yaml:"options"`
}

type NodeLocationCoordinates

type NodeLocationCoordinates struct {
	LatDeg           float64 `yaml:"lat_deg"`
	LonDeg           float64 `yaml:"lon_deg"`
	AltM             float64 `yaml:"alt_m"`
	HorizontalErrorM float64 `yaml:"horizontal_error_m"`
	VerticalErrorM   float64 `yaml:"vertical_error_m"`
}

type NodeRoleConfig

type NodeRoleConfig struct {
	Upstream                 UpstreamConfig       `yaml:"upstream"`
	NodeID                   string               `yaml:"node_id"`
	Name                     string               `yaml:"name"`
	ShortName                string               `yaml:"short_name"`
	StatusMode               string               `yaml:"status_mode"`
	NodeTypes                []string             `yaml:"node_types"`
	Capabilities             []CapabilityConfig   `yaml:"capabilities"`
	DependentNodeIDs         []string             `yaml:"dependent_node_ids"`
	Devices                  []NodeDeviceConfig   `yaml:"devices"`
	StaticRegistrationFile   string               `yaml:"static_registration_file"`
	Source                   DeviceSourceConfig   `yaml:"source"`
	Sources                  []DeviceSourceConfig `yaml:"sources"`
	Location                 NodeLocationConfig   `yaml:"location"`
	Media                    MediaConfig          `yaml:"media"`
	StatusIntervalMS         int                  `yaml:"status_interval_ms"`
	ReconnectIntervalMS      int                  `yaml:"reconnect_interval_ms"`
	RegistrationAckTimeoutMS int                  `yaml:"registration_ack_timeout_ms"`
	WriteTimeoutMS           int                  `yaml:"write_timeout_ms"`
	DataPlane                RoleDataPlaneConfig  `yaml:"data_plane"`
}

func (NodeRoleConfig) ReconnectInterval

func (c NodeRoleConfig) ReconnectInterval() time.Duration

func (NodeRoleConfig) RegistrationAckTimeout

func (c NodeRoleConfig) RegistrationAckTimeout() time.Duration

func (NodeRoleConfig) StatusInterval

func (c NodeRoleConfig) StatusInterval() time.Duration

func (NodeRoleConfig) WriteTimeout

func (c NodeRoleConfig) WriteTimeout() time.Duration

type RoleDataPlaneConfig

type RoleDataPlaneConfig struct {
	Mode string `yaml:"mode"`
}

type S3MediaConfig

type S3MediaConfig struct {
	Endpoint           string `yaml:"endpoint"`
	Region             string `yaml:"region"`
	Bucket             string `yaml:"bucket"`
	Prefix             string `yaml:"prefix"`
	AccessKeyIDEnv     string `yaml:"access_key_id_env"`
	SecretAccessKeyEnv string `yaml:"secret_access_key_env"`
	ForcePathStyle     bool   `yaml:"force_path_style"`
}

type TLSConfig

type TLSConfig struct {
	Enabled    bool   `yaml:"enabled"`
	CertFile   string `yaml:"cert_file"`
	KeyFile    string `yaml:"key_file"`
	CAFile     string `yaml:"ca_file"`
	ServerName string `yaml:"server_name"`
	Insecure   bool   `yaml:"insecure"`
}

type UpstreamConfig

type UpstreamConfig struct {
	Address string    `yaml:"address"`
	TLS     TLSConfig `yaml:"tls"`
}

Jump to

Keyboard shortcuts

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