52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package config
|
|
|
|
import (
|
|
"git.loafle.net/overflow/overflow_service_websocket/commons/config"
|
|
)
|
|
|
|
var _config *Config
|
|
|
|
type Config struct {
|
|
Websocket WebsocketConfig `json:"websocket"`
|
|
GRpc GRpcConfig `json:"gRpc"`
|
|
}
|
|
|
|
type WebsocketConfig struct {
|
|
WriteTimeout int8 `default:"0"`
|
|
ReadTimeout int8 `default:"0"`
|
|
PongTimeout int8 `default:"60"`
|
|
PingTimeout int8 `default:"10"`
|
|
MaxMessageSize int64 `default:"1024"`
|
|
ReadBufferSize int `default:"4096"`
|
|
WriteBufferSize int `default:"4096"`
|
|
}
|
|
|
|
type GRpcConfig struct {
|
|
Host string `required:"true"`
|
|
Port int16 `required:"true"`
|
|
Tls bool `default:"false"`
|
|
Pool PoolConfig `json:"pool"`
|
|
}
|
|
|
|
type PoolConfig struct {
|
|
InitialCapacity int `defalut:"1"`
|
|
MaxCapacity int `defalut:"1"`
|
|
IncreaseCapacity int `defalut:"1"`
|
|
}
|
|
|
|
func InitConfig(path string) error {
|
|
if nil != _config {
|
|
return nil
|
|
}
|
|
_config = &Config{}
|
|
err := config.Load(_config, path)
|
|
if nil != err {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func GetConfig() *Config {
|
|
return _config
|
|
}
|