mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user