當前位置: 首頁>>代碼示例>>Golang>>正文


Golang goconf.New函數代碼示例

本文整理匯總了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
}
開發者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


注:本文中的github.com/Terry-Mao/goconf.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。