overflow_service_websocket/config/config.go
2017-07-28 16:52:16 +09:00

57 lines
1.1 KiB
Go

package config
import (
"git.loafle.net/overflow/overflow_service_websocket/commons/config"
)
var _config *Config
type Config struct {
Server ServerConfig `json:"server"`
Websocket WebsocketConfig `json:"websocket"`
GRpc GRpcConfig `json:"gRpc"`
}
type ServerConfig struct {
Addr string `required:"true"`
Tls bool `default:"false"`
}
type WebsocketConfig struct {
WriteTimeout uint8 `default:"0"`
ReadTimeout uint8 `default:"0"`
PongTimeout uint8 `default:"60"`
PingTimeout uint8 `default:"10"`
MaxMessageSize int64 `default:"1024"`
ReadBufferSize int `default:"4096"`
WriteBufferSize int `default:"4096"`
UseBinaryMessage bool `required:"false" default:"false"`
}
type GRpcConfig struct {
ServerConfig
Pool PoolConfig `json:"pool"`
}
type PoolConfig struct {
InitialCapacity uint8 `defalut:"1"`
MaxCapacity uint8 `defalut:"1"`
IncreaseCapacity uint8 `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
}