-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!(nodbuilder): making lifecycle timeouts configurable (#2347)
Closes #2315 Doing this proactively even though it is a good-first issue in case other dagstore startup issues are not fixed in time. Breaks the config.
- Loading branch information
1 parent
4c87c69
commit 400517e
Showing
3 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package node | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
var defaultLifecycleTimeout = time.Minute * 2 | ||
|
||
type Config struct { | ||
StartupTimeout time.Duration | ||
ShutdownTimeout time.Duration | ||
} | ||
|
||
// DefaultConfig returns the default node configuration for a given node type. | ||
func DefaultConfig(tp Type) Config { | ||
var timeout time.Duration | ||
switch tp { | ||
case Light: | ||
timeout = time.Second * 20 | ||
default: | ||
timeout = defaultLifecycleTimeout | ||
} | ||
return Config{ | ||
StartupTimeout: timeout, | ||
ShutdownTimeout: timeout, | ||
} | ||
} | ||
|
||
func (c *Config) Validate() error { | ||
if c.StartupTimeout == 0 { | ||
return fmt.Errorf("invalid startup timeout: %v", c.StartupTimeout) | ||
} | ||
if c.ShutdownTimeout == 0 { | ||
return fmt.Errorf("invalid shutdown timeout: %v", c.ShutdownTimeout) | ||
} | ||
return nil | ||
} |