go-zero/rest/config.go

40 lines
952 B
Go
Raw Normal View History

2020-07-31 11:14:48 +08:00
package rest
2020-07-26 17:09:05 +08:00
import (
"time"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/service"
2020-07-26 17:09:05 +08:00
)
type (
PrivateKeyConf struct {
Fingerprint string
KeyFile string
}
SignatureConf struct {
Strict bool `json:",default=false"`
Expiry time.Duration `json:",default=1h"`
PrivateKeys []PrivateKeyConf
}
2020-07-31 11:14:48 +08:00
// why not name it as Conf, because we need to consider usage like:
// type Config struct {
// rpcx.RpcConf
2020-07-31 11:45:16 +08:00
// rest.RestConf
2020-07-31 11:14:48 +08:00
// }
// if with the name Conf, there will be two Conf inside Config.
2020-07-31 11:45:16 +08:00
RestConf struct {
2020-07-26 17:09:05 +08:00
service.ServiceConf
Host string `json:",default=0.0.0.0"`
Port int
Verbose bool `json:",optional"`
MaxConns int `json:",default=10000"`
MaxBytes int64 `json:",default=1048576,range=[0:8388608]"`
// milliseconds
Timeout int64 `json:",default=3000"`
CpuThreshold int64 `json:",default=900,range=[0:1000]"`
Signature SignatureConf `json:",optional"`
}
)