package main
import (
"io/ioutil"
"launchpad.net/goyaml"
)
// ProxyConfig Type
type ProxyConfig struct { Bind string `yaml:"bind"` //代理服务监听端口
WaitQueueLen int `yaml:"wait_queue_len"`// 等待队列长度
MaxConn int `yaml:"max_conn"` //并发最大连接
Timeout int `yaml:"timeout"` // 请求超时时间
FailOver int `yaml:"failover"` // 后端服务允许失败次数
Backend []string `yaml:"backend"` // 后端服务列表
Log LogConfig `yaml:"log"` //日志配置项
Stats string `yaml:"stats"` //运行状态
}
// LogConfig Type
type LogConfig struct { Level string `yaml:"level"` //日志级别
Path string `yaml:"path"` //日志文件位置
}
//日志文件解析 并把解析结果存入pConfig中
func parseConfigFile(filepath string) error { if config, err := ioutil.ReadFile(filepath); err == nil { if err = goyaml.Unmarshal(config, &pConfig); err != nil { return err
}
} else { return err
}
return nil
}