-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgen_code.go
30 lines (25 loc) · 950 Bytes
/
gen_code.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package config
import (
"time"
)
// GenCodeConfig struct.
type GenCodeConfig struct {
Upstream UpstreamConfig `yaml:"upstream" mapstructure:"upstream"`
Downstream interface{} `yaml:"downstream" mapstructure:"downstream"`
}
// UpstreamConfig struct.
type UpstreamConfig struct {
ContextTimeout time.Duration `yaml:"contextTimeout" mapstructure:"contextTimeout" validate:"nonnil"`
HTTP CommonHTTPServerConfig `yaml:"http" mapstructure:"http"`
GRPC GRPCServerConfig `yaml:"grpc" mapstructure:"grpc"`
Temporal TemporalServerConfig `yaml:"temporal" mapstructure:"temporal"`
}
func (c *UpstreamConfig) Validate() error {
// TODO: Actually validate
return nil
}
func SetGenCodeConfigDefaults(prefix string, set func(key string, value interface{})) {
set(prefix+"Upstream.ContextTimeout", "30s")
set(prefix+"Upstream.HTTP.ReadTimeout", "30s")
set(prefix+"Upstream.HTTP.WriteTimeout", "30s")
}