本文整理汇总了Golang中github.com/Terry-Mao/goconf.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:qmdx,项目名称:gopush-cluster,代码行数:31,代码来源:config.go
示例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
}
开发者ID:xuguangtech,项目名称:gopush-cluster,代码行数:30,代码来源:config.go
示例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
}
开发者ID:hzmnet,项目名称:goim,代码行数:32,代码来源:config.go
示例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
}
开发者ID:Jnnnh,项目名称:gopush-cluster,代码行数:33,代码来源:config.go
示例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
}
开发者ID:Brant-Zhang,项目名称:gopush-cluster,代码行数:29,代码来源:config.go
示例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
}
开发者ID:rogerwei,项目名称:gopush-cluster,代码行数:59,代码来源:config.go
示例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
}
开发者ID:voidException,项目名称:gopush-cluster,代码行数:58,代码来源:config.go
示例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
}
开发者ID:1d7500,项目名称:goim,代码行数:12,代码来源:config.go
示例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
}
开发者ID:yuya008,项目名称:godis,代码行数:12,代码来源:godis.go
示例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
}
开发者ID:ezhishui,项目名称:bfs,代码行数:13,代码来源:config.go
示例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
}
开发者ID:hushi55,项目名称:Grep,代码行数:17,代码来源:config.go
示例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
}
开发者ID:sumory,项目名称:runbot,代码行数:16,代码来源:config.go
示例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
}
开发者ID:ming-hai,项目名称:appmsgsrv,代码行数:17,代码来源:config.go
示例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
}
开发者ID:felixhao,项目名称:goredis-failover,代码行数:17,代码来源:config.go
示例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
}
开发者ID:youynu,项目名称:gopush-cluster,代码行数:48,代码来源:config.go
示例16: NewConfig
func NewConfig(confFile string) *Config {
temp := &ConfigTemp{}
conf := goconf.New()
if err := conf.Parse(confFile); err != nil {
glog.Error(err.Error())
return temp.Parse()
}
// temp := &ConfigTemp{}
if err := conf.Unmarshal(temp); err != nil {
glog.Error(err.Error())
return temp.Parse()
}
return temp.Parse()
}
开发者ID:nprog,项目名称:IntelligentEngine,代码行数:17,代码来源:config.go
示例17: InitConfig
// InitConfig get a new Config struct.
func InitConfig(file string) (*Config, error) {
cf := &Config{
// base
User: "nobody nobody",
PidFile: "/tmp/gopush-cluster-comet.pid",
Dir: "./",
MaxProc: runtime.NumCPU(),
LogFile: "./comet.log",
LogLevel: "ERROR",
WebsocketBind: []string{"localhost:6968"},
TCPBind: []string{"localhost:6969"},
RPCBind: []string{"localhost:6970"},
PprofBind: []string{"localhost:6971"},
StatBind: []string{"localhost:6972"},
// zookeeper
ZookeeperAddr: []string{"localhost:2181"},
ZookeeperTimeout: 30 * time.Second,
ZookeeperPath: "/gopush-cluster",
ZookeeperNode: "node1",
// rpc
RPCMessageAddr: "localhost:6972",
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,
}
c := goconf.New()
if err := c.Parse(file); err != nil {
Log.Error("goconf.Parse(\"%s\") error(%v)", file, err)
return nil, err
}
if err := c.Unmarshal(cf); err != nil {
Log.Error("goconf.Unmarshall() error(%v)", err)
return nil, err
}
return cf, nil
}
开发者ID:Jnnnh,项目名称:gopush-cluster,代码行数:47,代码来源:config.go
示例18: 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
}
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
}
开发者ID:dulumao,项目名称:goim,代码行数:19,代码来源:config.go
示例19: InitConfig
// InitConfig get a new Config struct.
func InitConfig(file string) (*Config, error) {
cf := &Config{
// base
Addr: "localhost:6969",
Key: "Terry-Mao",
Heartbeat: 30,
}
c := goconf.New()
if err := c.Parse(file); err != nil {
glog.Errorf("goconf.Parse(\"%s\") failed (%s)", file, err.Error())
return nil, err
}
if err := c.Unmarshal(cf); err != nil {
glog.Errorf("goconf.Unmarshal() failed (%s)", err.Error())
return nil, err
}
return cf, nil
}
开发者ID:rogerwei,项目名称:gopush-cluster,代码行数:19,代码来源:config.go
示例20: InitConfig
// InitConfig get a new Config struct.
func InitConfig(file string) (*Config, error) {
cf := &Config{
// base
LogFile: "./comet-test.log",
LogLevel: "ERROR",
Addr: "localhost:6969",
Key: "Terry-Mao",
Heartbeat: 30,
}
c := goconf.New()
if err := c.Parse(file); err != nil {
Log.Error("goconf.Parse(\"%s\") failed (%s)", file, err.Error())
return nil, err
}
if err := c.Unmarshal(cf); err != nil {
Log.Error("goconf.Unmarshal() failed (%s)", err.Error())
return nil, err
}
return cf, nil
}
开发者ID:kooxiv,项目名称:gopush-cluster,代码行数:21,代码来源:config.go
注:本文中的github.com/Terry-Mao/goconf.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论