本文整理汇总了Golang中github.com/Terry-Mao/goconf.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: InitConfig
// InitConfig init configuration file.
func InitConfig() error {
gconf := goconf.New()
if err := gconf.Parse(confFile); err != nil {
glog.Errorf("goconf.Parse(\"%s\") error(%v)", confFile, err)
return err
}
// Default config
Conf = &Config{
HttpBind: []string{"localhost:80"},
AdminBind: []string{"localhost:81"},
MaxProc: runtime.NumCPU(),
PprofBind: []string{"localhost:8190"},
User: "nobody nobody",
PidFile: "/tmp/gopush-cluster-web.pid",
Dir: "./",
Router: "",
QQWryPath: "/tmp/QQWry.dat",
ZookeeperAddr: []string{":2181"},
ZookeeperTimeout: 30 * time.Second,
ZookeeperCometPath: "/gopush-cluster-comet",
ZookeeperMessagePath: "/gopush-cluster-message",
RPCRetry: 3 * time.Second,
RPCPing: 1 * time.Second,
}
if err := gconf.Unmarshal(Conf); err != nil {
glog.Errorf("goconf.Unmarshall() error(%v)", err)
return err
}
return nil
}
示例2: InitConfig
// InitConfig init configuration file.
func InitConfig() error {
gconf := goconf.New()
if err := gconf.Parse(confFile); err != nil {
return err
}
// Default config
Conf = &Config{
HttpBind: []string{"localhost:80"},
AdminBind: []string{"localhost:81"},
HttpServerTimeout: 10 * time.Second,
MaxProc: runtime.NumCPU(),
PprofBind: []string{"localhost:8190"},
User: "nobody nobody",
PidFile: "/tmp/gopush-cluster-web.pid",
Dir: "./",
Log: "./log/xml",
ZookeeperAddr: []string{":2181"},
ZookeeperTimeout: 30 * time.Second,
ZookeeperCometPath: "/gopush-cluster-comet",
ZookeeperMessagePath: "/gopush-cluster-message",
ZookeeperMigratePath: "/gopush-migrate-lock",
RPCRetry: 3 * time.Second,
RPCPing: 1 * time.Second,
}
if err := gconf.Unmarshal(Conf); err != nil {
return err
}
return nil
}
示例3: InitConfig
// InitConfig init the global config.
func InitConfig() (err error) {
Conf = NewConfig()
gconf = goconf.New()
if err = gconf.Parse(confFile); err != nil {
return err
}
if err = gconf.Unmarshal(Conf); err != nil {
return err
}
var serverIDi int64
for _, serverID := range gconf.Get("comets").Keys() {
addr, err := gconf.Get("comets").String(serverID)
if err != nil {
return err
}
serverIDi, err = strconv.ParseInt(serverID, 10, 32)
if err != nil {
return err
}
Conf.Comets[int32(serverIDi)] = addr
}
for _, serverID := range gconf.Get("router.addrs").Keys() {
addr, err := gconf.Get("router.addrs").String(serverID)
if err != nil {
return err
}
Conf.RouterRPCAddrs[serverID] = addr
}
return nil
}
示例4: NewConfig
// Initialize config
func NewConfig(file string) (*Config, error) {
gconf := goconf.New()
if err := gconf.Parse(file); err != nil {
return nil, err
}
// Default config
conf := &Config{
Addr: ":80",
AdminAddr: ":81",
MaxProc: runtime.NumCPU(),
PprofBind: []string{"localhost:8190"},
User: "nobody nobody",
PidFile: "/tmp/gopush-cluster-web.pid",
Dir: "./",
LogPath: "./web.log",
LogLevel: "DEBUG",
ZKAddr: []string{":2181"},
ZKTimeout: 30 * time.Second,
ZKCometPath: "/gopush-cluster",
ZKPIDPath: "/gopush-pid",
MsgAddr: ":8070",
MsgPing: 1 * time.Second,
MsgRetry: 3 * time.Second,
}
if err := gconf.Unmarshal(conf); err != nil {
return nil, err
}
return conf, nil
}
示例5: NewConfig
// Initialize config
func NewConfig(file string) (*Config, error) {
gconf := goconf.New()
if err := gconf.Parse(file); err != nil {
return nil, err
}
// Default config
conf := &Config{
Addr: ":80",
AdminAddr: ":81",
MaxProc: runtime.NumCPU(),
LogPath: "./web.log",
LogLevel: "DEBUG",
ZKAddr: ":2181",
ZKTimeout: 8 * time.Hour,
ZKCometPath: "/gopush-cluster",
ZKPIDPath: "/gopush-pid",
MsgAddr: ":8070",
MsgPing: 1 * time.Second,
MsgRetry: 3 * time.Second,
}
if err := gconf.Unmarshal(conf); err != nil {
return nil, err
}
return conf, nil
}
示例6: InitConfig
// NewConfig parse config file into Config.
func InitConfig() error {
gconf := goconf.New()
if err := gconf.Parse(confFile); err != nil {
glog.Errorf("goconf.Parse(\"%s\") error(%v)", confFile, err)
return err
}
Conf = &Config{
// base
RPCBind: []string{"localhost:8070"},
User: "nobody nobody",
PidFile: "/tmp/gopush-cluster-message.pid",
Dir: "./",
MaxProc: runtime.NumCPU(),
PprofBind: []string{"localhost:8170"},
// storage
StorageType: "redis",
// redis
RedisIdleTimeout: 28800 * time.Second,
RedisMaxIdle: 50,
RedisMaxActive: 1000,
RedisMaxStore: 20,
RedisSource: make(map[string]string),
// mysql
MySQLSource: make(map[string]string),
MySQLClean: 1 * time.Hour,
// zookeeper
ZookeeperAddr: []string{"localhost:2181"},
ZookeeperTimeout: 30 * time.Second,
ZookeeperPath: "/gopush-cluster-message",
}
if err := gconf.Unmarshal(Conf); err != nil {
glog.Errorf("goconf.Unmarshal() error(%v)", err)
return err
}
// redis section
redisAddrsSec := gconf.Get("redis.source")
if redisAddrsSec != nil {
for _, key := range redisAddrsSec.Keys() {
addr, err := redisAddrsSec.String(key)
if err != nil {
return fmt.Errorf("config section: \"redis.addrs\" key: \"%s\" error(%v)", key, err)
}
Conf.RedisSource[key] = addr
}
}
// mysql section
dbSource := gconf.Get("mysql.source")
if dbSource != nil {
for _, key := range dbSource.Keys() {
source, err := dbSource.String(key)
if err != nil {
return fmt.Errorf("config section: \"mysql.source\" key: \"%s\" error(%v)", key, err)
}
Conf.MySQLSource[key] = source
}
}
return nil
}
示例7: NewConfig
// Initialize config
func NewConfig(fileName string) (*Config, error) {
gconf := goconf.New()
if err := gconf.Parse(fileName); err != nil {
Log.Error("goconf.Parse(\"%s\") error(%v)", fileName, err)
return nil, err
}
conf := &Config{
Addr: ":8070",
PKey: "gopushpkey",
User: "nobody nobody",
PidFile: "/tmp/gopush-cluster-message.pid",
Dir: "./",
MaxProc: runtime.NumCPU(),
LogFile: "./message.log",
LogLevel: "DEBUG",
PprofBind: []string{"localhost:8170"},
StorageType: "redis",
RedisIdleTimeout: 28800 * time.Second,
RedisMaxIdle: 50,
RedisMaxActive: 1000,
RedisMaxStore: 20,
RedisAddrs: make(map[string]string),
MYSQLDelLoopTime: 1 * time.Hour,
DBSource: make(map[string]string),
}
if err := gconf.Unmarshal(conf); err != nil {
Log.Error("goconf.Unmarshal() error(%v)", err)
return nil, err
}
//Load redis addresses
redisAddrsSec := gconf.Get("redis.addr")
if redisAddrsSec != nil {
for _, key := range redisAddrsSec.Keys() {
addr, err := redisAddrsSec.String(key)
if err != nil {
return nil, fmt.Errorf("config section:\"redis.addrs\" key:\"%s\" error(%v)", key, err)
}
conf.RedisAddrs[key] = addr
}
}
//Load mysql sources
dbSource := gconf.Get("mysql.source")
if dbSource != nil {
for _, key := range redisAddrsSec.Keys() {
source, err := redisAddrsSec.String(key)
if err != nil {
return nil, fmt.Errorf("config section:\"mysql.source\" key:\"%s\" error(%v)", key, err)
}
conf.DBSource[key] = source
}
}
return conf, nil
}
示例8: InitConfig
// InitConfig init the global config.
func InitConfig() (err error) {
Conf = NewConfig()
gconf = goconf.New()
if err = gconf.Parse(confFile); err != nil {
return err
}
if err := gconf.Unmarshal(Conf); err != nil {
return err
}
return nil
}
示例9: parseArgs
func parseArgs() *goconf.Config {
flag.Parse()
args := flag.Args()
if len(args) <= 0 {
usage(errors.New("not found config file"))
}
conf := goconf.New()
if err := conf.Parse(args[0]); err != nil {
usage(err)
}
return conf
}
示例10: NewConfig
// NewConfig new a config.
func NewConfig(file string) (c *Config, err error) {
var gconf = goconf.New()
c = &Config{}
if err = gconf.Parse(file); err != nil {
return
}
if err = gconf.Unmarshal(c); err != nil {
return
}
c.setDefault()
return
}
示例11: InitConfig
// InitConfig init the global config.
func InitConfig() (err error) {
defer func() {
Conf.CheckPointThreshold = power2(Conf.CheckPointThreshold)
}()
Conf = NewConfig()
gconf = goconf.New()
if err = gconf.Parse(confFile); err != nil {
return err
}
if err := gconf.Unmarshal(Conf); err != nil {
return err
}
return nil
}
示例12: InitConfig
func InitConfig(configFile string) *Config {
conf := goconf.New()
if err := conf.Parse(configFile); err != nil {
panic(err)
}
myConfig := &Config{}
if err := conf.Unmarshal(myConfig); err != nil {
panic(err)
}
fmt.Printf("config is: %#v\n", myConfig)
return myConfig
}
示例13: InitConfig
// InitConfig init configuration file.
func InitConfig() error {
gconf := goconf.New()
if err := gconf.Parse(confFile); err != nil {
fmt.Println("confFile", confFile)
logger.Errorf("goconf.Parse(\"%s\") error(%v)", confFile, err)
return err
}
Conf = &Config{}
if err := gconf.Unmarshal(Conf); err != nil {
logger.Errorf("goconf.Unmarshall() error(%v)", err)
return err
}
return nil
}
示例14: initConfig
// initConfig parse config file into Config.
func initConfig() error {
gconf = goconf.New()
if err := gconf.Parse(confFile); err != nil {
return err
}
conf = &Config{
// base
Log: "./log/xml",
ZK: []string{},
ZKPath: "/redis-cluster/service_name",
}
if err := gconf.Unmarshal(conf); err != nil {
return err
}
return nil
}
示例15: InitConfig
// InitConfig get a new Config struct.
func InitConfig() error {
Conf = &Config{
// base
User: "nobody nobody",
PidFile: "/tmp/gopush-cluster-comet.pid",
Dir: "./",
MaxProc: runtime.NumCPU(),
WebsocketBind: []string{"localhost:6968"},
TCPBind: []string{"localhost:6969"},
RPCBind: []string{"localhost:6970"},
PprofBind: []string{"localhost:6971"},
StatBind: []string{"localhost:6972"},
KetamaBase: 255,
// zookeeper
ZookeeperAddr: []string{"localhost:2181"},
ZookeeperTimeout: 30 * time.Second,
ZookeeperCometPath: "/gopush-cluster-comet",
ZookeeperCometNode: "node1",
ZookeeperCometWeight: "1",
ZookeeperMessagePath: "/gopush-cluster-message",
// rpc
RPCPing: 1 * time.Second,
RPCRetry: 1 * time.Second,
// channel
SndbufSize: 2048,
RcvbufSize: 256,
Proto: []string{"tcp", "websocket"},
BufioInstance: runtime.NumCPU(),
BufioNum: 128,
TCPKeepalive: false,
TokenExpire: 30 * 24 * time.Hour,
MaxSubscriberPerChannel: 64,
ChannelBucket: runtime.NumCPU(),
Auth: false,
MsgBufNum: 30,
}
c := goconf.New()
if err := c.Parse(confFile); err != nil {
glog.Errorf("goconf.Parse(\"%s\") error(%v)", confFile, err)
return err
}
if err := c.Unmarshal(Conf); err != nil {
glog.Errorf("goconf.Unmarshall() error(%v)", err)
return err
}
return nil
}