orchard controller run: introduce --experimental-ping-interval (#316)

* orchard controller run: introduce --experimental-ping-interval

* Ensure that --experimental-ping-interval is always larger than 5s
This commit is contained in:
Nikolay Edigaryev
2025-05-15 21:14:17 +04:00
committed by GitHub
parent d52aa91927
commit a37a8914cd
6 changed files with 25 additions and 3 deletions
+14
View File
@@ -15,6 +15,7 @@ import (
"os"
"path/filepath"
"strconv"
"time"
)
var ErrRunFailed = errors.New("failed to run controller")
@@ -26,6 +27,7 @@ var noTLS bool
var sshNoClientAuth bool
var experimentalRPCV2 bool
var noExperimentalRPCV2 bool
var experimentalPingInterval time.Duration
func newRunCommand() *cobra.Command {
cmd := &cobra.Command{
@@ -65,6 +67,10 @@ func newRunCommand() *cobra.Command {
_ = cmd.PersistentFlags().MarkHidden("experimental-rpc-v2")
cmd.PersistentFlags().BoolVar(&noExperimentalRPCV2, "no-experimental-rpc-v2", false,
"disable experimental RPC v2 (https://github.com/cirruslabs/orchard/issues/235)")
cmd.PersistentFlags().DurationVar(&experimentalPingInterval, "experimental-ping-interval", 0,
"interval between WebSocket PING's sent by the controller to workers and clients, "+
"useful when facing intermediate load balancers/proxies that have timeouts "+
"smaller than the controller's default 30 second interval")
return cmd
}
@@ -156,6 +162,14 @@ func runController(cmd *cobra.Command, args []string) (err error) {
controllerOpts = append(controllerOpts, controller.WithExperimentalRPCV2())
}
if experimentalPingInterval != 0 {
if experimentalPingInterval < 5*time.Second {
return fmt.Errorf("--experimental-ping-interval's value cannot be less than 5 seconds")
}
controllerOpts = append(controllerOpts, controller.WithPingInterval(experimentalPingInterval))
}
controllerInstance, err := controller.New(controllerOpts...)
if err != nil {
return err