@@ -11,14 +11,16 @@ import (
1111
1212// Configuration structure
1313type Config struct {
14- CanPorts []string
15- Port string
16- AutoSetup bool // Auto setup CAN interfaces on startup
17- Bitrate int // Default bitrate for CAN interfaces
18- SamplePoint string // Default sample point
19- RestartMs int // Default restart timeout
20- SetupRetry int // Number of setup retry attempts
21- SetupDelay time.Duration // Delay between setup retries
14+ CanPorts []string
15+ Port string
16+ AutoSetup bool // Auto setup CAN interfaces on startup
17+ Bitrate int // Default bitrate for CAN interfaces
18+ SamplePoint string // Default sample point
19+ RestartMs int // Default restart timeout
20+ SetupRetry int // Number of setup retry attempts
21+ SetupDelay time.Duration // Delay between setup retries
22+ EnableFinder bool // Enable service finder
23+ SetupFinderInterval time.Duration // Interval for service finder
2224}
2325
2426// ConfigProvider interface for dependency injection
@@ -115,6 +117,8 @@ func (cp *ConfigParser) ParseConfig() (*Config, error) {
115117 var restartMs int
116118 var setupRetry int
117119 var setupDelaySeconds int
120+ var setupFinderEnabled bool
121+ var setupFinderInterval int
118122
119123 flag .StringVar (& canPortsFlag , "can-ports" , "" , "Comma-separated list of CAN interfaces (e.g., can0,can1)" )
120124 flag .StringVar (& serverPort , "port" , "5260" , "HTTP server port" )
@@ -124,6 +128,8 @@ func (cp *ConfigParser) ParseConfig() (*Config, error) {
124128 flag .IntVar (& restartMs , "restart-ms" , 100 , "Default CAN restart timeout (ms)" )
125129 flag .IntVar (& setupRetry , "setup-retry" , 3 , "Number of setup retry attempts" )
126130 flag .IntVar (& setupDelaySeconds , "setup-delay" , 2 , "Delay between setup retries (seconds)" )
131+ flag .BoolVar (& setupFinderEnabled , "enable-finder" , true , "Enable service finder" )
132+ flag .IntVar (& setupFinderInterval , "finder-interval" , 5 , "Interval for service finder in seconds" )
127133 flag .Parse ()
128134
129135 // Environment variables (override command line)
@@ -174,13 +180,22 @@ func (cp *ConfigParser) ParseConfig() (*Config, error) {
174180 if serverPort == "" {
175181 return nil , fmt .Errorf ("server port cannot be empty" )
176182 }
183+
184+ if setupFinderEnabled {
185+ if setupFinderInterval <= 0 {
186+ return nil , fmt .Errorf ("finder interval must be positive, got %d" , config .SetupFinderInterval )
187+ }
188+ }
189+
177190 config .Port = serverPort
178191 config .AutoSetup = autoSetup
179192 config .Bitrate = bitrate
180193 config .SamplePoint = samplePoint
181194 config .RestartMs = restartMs
182195 config .SetupRetry = setupRetry
183196 config .SetupDelay = time .Duration (setupDelaySeconds ) * time .Second
197+ config .EnableFinder = setupFinderEnabled
198+ config .SetupFinderInterval = time .Duration (setupFinderInterval ) * time .Second
184199
185200 return config , nil
186201}
0 commit comments