-
Notifications
You must be signed in to change notification settings - Fork 7
Make MuxManagerStartDelay configurable #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package common | ||
|
|
||
| import "time" | ||
|
|
||
| type Policy struct { | ||
| // MuxManagerStartDelay is how long the MuxManager's Start() waits for the | ||
| // underlying MuxProvider to publish initial connections before returning. | ||
| // A value of 0 tells Start() to skip the wait entirely. | ||
| MuxManagerStartDelay time.Duration | ||
| } | ||
|
|
||
| func (p *Policy) UpdateMuxManagerStartDelay(d time.Duration) { | ||
| p.MuxManagerStartDelay = d | ||
| } | ||
|
|
||
| // GlobalPolicy is the process-wide policy singleton. | ||
| var GlobalPolicy = &Policy{ | ||
| MuxManagerStartDelay: time.Minute, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,9 @@ package config | |
|
|
||
| import ( | ||
| "bytes" | ||
| "fmt" | ||
| "os" | ||
| "time" | ||
|
|
||
| "github.com/urfave/cli/v2" | ||
| "gopkg.in/yaml.v3" | ||
|
|
@@ -48,8 +50,18 @@ type ( | |
| Logging LoggingConfig `yaml:"logging"` | ||
| LogConfigs map[string]LoggingConfig `yaml:"logConfigs"` | ||
| ClusterConnections []ClusterConnConfig `yaml:"clusterConnections"` | ||
| // MuxManagerStartDelay overrides the time the mux manager waits for | ||
| // initial connections before serving. Accepts Go duration strings | ||
| // (e.g. "30s", "1m", or "0s" to skip the wait entirely). When the | ||
| // field is omitted, the in-process default (time.Minute) is used. | ||
| MuxManagerStartDelay *Duration `yaml:"muxManagerStartDelay,omitempty"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. top-level? |
||
| } | ||
|
|
||
| // Duration is a time.Duration that unmarshals from YAML duration strings | ||
| // (e.g. "30s", "1m500ms") rather than the integer-nanoseconds form yaml.v3 | ||
| // would otherwise produce. | ||
| Duration time.Duration | ||
|
|
||
| SATranslationConfig struct { | ||
| NamespaceMappings []SANamespaceMapping `yaml:"namespaceMappings"` | ||
| cachedBiMap SearchAttributeTranslation | ||
|
|
@@ -201,6 +213,25 @@ func (c *ProfilingConfig) UnmarshalYAML(unmarshal func(interface{}) error) error | |
| return unmarshal((*plain)(c)) | ||
| } | ||
|
|
||
| func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error { | ||
| var s string | ||
| if err := unmarshal(&s); err != nil { | ||
| return err | ||
| } | ||
| if s == "" { | ||
| return nil | ||
| } | ||
| parsed, err := time.ParseDuration(s) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid duration %q: %w", s, err) | ||
| } | ||
| *d = Duration(parsed) | ||
| return nil | ||
| } | ||
|
|
||
| // AsDuration returns the value as a standard time.Duration. | ||
| func (d Duration) AsDuration() time.Duration { return time.Duration(d) } | ||
|
|
||
| func (s *SATranslationConfig) IsEnabled() bool { | ||
| return len(s.NamespaceMappings) > 0 | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| muxManagerStartDelay: "0s" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will 0 lead to race conditions - otherwise why was it set?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only for testing. In test code, the value is ready set to 0 |
||
| clusterConnections: | ||
| - name: "b-inbound-server/b-outbound-server" | ||
| local: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to introduce a global policy here - I don't want to conflate our existing configuration approach