config

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config provides JSON-based configuration for DDS participants.

Load a configuration file with LoadConfig or parse JSON from an io.Reader with ParseConfig. Call ParticipantConfig.Validate to resolve duration strings before passing the config to an RTPS option such as rtps.WithConfig.

Example config file:

{
    "domain": 0,
    "heartbeat_period": "200ms",
    "spdp_interval": "2s",
    "spdp_jitter": "500ms",
    "no_multicast": false,
    "peer_locators": ["192.168.1.10:7410"],
    "log_level": "info"
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParticipantConfig

type ParticipantConfig struct {
	// Domain is the DDS domain ID (0–232). 0 is valid and is the default.
	Domain int `json:"domain"`

	// HeartbeatPeriod is the interval between periodic HEARTBEAT submessages
	// sent by reliable writers. Default: 200ms.
	HeartbeatPeriod string `json:"heartbeat_period,omitempty"`

	// SPDPInterval is the interval between SPDP participant announcements.
	// Default: 2s.
	SPDPInterval string `json:"spdp_interval,omitempty"`

	// SPDPJitter is the maximum random delay before each SPDP announcement,
	// used to spread simultaneous startup floods. Default: 0 (no jitter).
	SPDPJitter string `json:"spdp_jitter,omitempty"`

	// NoMulticast disables SPDP multicast discovery. Combine with PeerLocators
	// to supply peers explicitly when multicast is unavailable.
	NoMulticast bool `json:"no_multicast,omitempty"`

	// PeerLocators is a list of static unicast peer addresses (host:port) for
	// unicast-only or TSN deployments where SPDP multicast is undesirable.
	PeerLocators []string `json:"peer_locators,omitempty"`

	// LogLevel is the minimum log level: "debug", "info", "warn", or "error".
	// An empty string means "use the application default".
	LogLevel string `json:"log_level,omitempty"`

	// Resolved durations — set by Validate, not from JSON.
	HeartbeatPeriodDur time.Duration `json:"-"`
	SPDPIntervalDur    time.Duration `json:"-"`
	SPDPJitterDur      time.Duration `json:"-"`
}

ParticipantConfig is the JSON-serialisable configuration for a DDS participant.

All duration fields accept Go duration strings (e.g. "200ms", "2s", "500ms"). Zero values use the implementation default.

func LoadConfig

func LoadConfig(path string) (*ParticipantConfig, error)

LoadConfig reads and parses a JSON participant configuration from the file at path. It calls Validate before returning, so HeartbeatPeriodDur, SPDPIntervalDur, and SPDPJitterDur are always populated on success.

func ParseConfig

func ParseConfig(r io.Reader) (*ParticipantConfig, error)

ParseConfig decodes a JSON participant configuration from r. It calls Validate before returning.

func (*ParticipantConfig) Validate

func (c *ParticipantConfig) Validate() error

Validate checks all fields for validity and resolves the duration string fields (HeartbeatPeriod, SPDPInterval, SPDPJitter) into their time.Duration counterparts. It returns an error on the first invalid field encountered.

Jump to

Keyboard shortcuts

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