ing
This commit is contained in:
parent
f49a711b5a
commit
af9138ab6f
13
config.yml
Normal file
13
config.yml
Normal 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
42
config/config.go
Normal 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
|
||||||
|
}
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user