This commit is contained in:
crusader 2017-07-13 21:36:20 +09:00
parent f49a711b5a
commit af9138ab6f
3 changed files with 56 additions and 0 deletions

13
config.yml Normal file
View File

@ -0,0 +1,13 @@
websocket:
writeTimeout: 0
readTimeout: 0
pongTimeout: 60
pingTimeout: 10
maxMessageSize: 1024
readBufferSize: 4096
writeBufferSize: 4096
grpc:
host: localhost
port: 8000
tls: false

42
config/config.go Normal file
View File

@ -0,0 +1,42 @@
package config
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
type Config struct {
websocket Websocket `yaml:"websocket"`
grpc GRPC `yaml:"grpc"`
}
type Websocket struct {
writeTimeout int8 `yaml:"writeTimeout"`
readTimeout int8 `yaml:"readTimeout"`
pongTimeout int8 `yaml:"pongTimeout"`
pingTimeout int8 `yaml:"pingTimeout"`
maxMessageSize int64 `yaml:"maxMessageSize"`
readBufferSize int `yaml:"readBufferSize"`
writeBufferSize int `yaml:"writeBufferSize"`
}
type GRPC struct {
host string `yaml:"host"`
port int16 `yaml:"port"`
tls bool `yaml:"tls"`
}
func LoadConfig(filename string) (*Config, error) {
bytes, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
c := new(Config)
err = yaml.Unmarshal(bytes, &c)
if err != nil {
return nil, err
}
return c, nil
}

View File

@ -16,3 +16,4 @@ import:
- package: git.loafle.net/overflow/overflow_api_server - package: git.loafle.net/overflow/overflow_api_server
subpackages: subpackages:
- golang - golang
- package: gopkg.in/yaml.v2