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


Golang Conf.Duration方法代碼示例

本文整理匯總了Golang中github.com/funkygao/jsconf.Conf.Duration方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conf.Duration方法的具體用法?Golang Conf.Duration怎麽用?Golang Conf.Duration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/funkygao/jsconf.Conf的用法示例。


在下文中一共展示了Conf.Duration方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: LoadConfig

func (this *ConfigMongodb) LoadConfig(cf *conf.Conf) {
	this.ShardBaseNum = cf.Int("shard_base_num", 100000)
	this.DebugProtocol = cf.Bool("debug_protocol", false)
	this.DebugHeartbeat = cf.Bool("debug_heartbeat", false)
	this.ShardStrategy = cf.String("shard_strategy", "legacy")
	this.ConnectTimeout = cf.Duration("connect_timeout", 4*time.Second)
	this.IoTimeout = cf.Duration("io_timeout", 30*time.Second)
	this.MaxIdleConnsPerServer = cf.Int("max_idle_conns_per_server", 2)
	this.MaxConnsPerServer = cf.Int("max_conns_per_server",
		this.MaxIdleConnsPerServer*5)
	this.HeartbeatInterval = cf.Int("heartbeat_interval", 120)
	section, err := cf.Section("breaker")
	if err == nil {
		this.Breaker.loadConfig(section)
	}
	this.Servers = make(map[string]*ConfigMongodbServer)
	for i := 0; i < len(cf.List("servers", nil)); i++ {
		section, err := cf.Section(fmt.Sprintf("servers[%d]", i))
		if err != nil {
			panic(err)
		}

		server := new(ConfigMongodbServer)
		server.ShardBaseNum = this.ShardBaseNum
		server.loadConfig(section)
		this.Servers[server.Pool] = server
	}

	log.Debug("mongodb conf: %+v", *this)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:30,代碼來源:mongodb.go

示例2: LoadConfig

func (this *ConfigMemcache) LoadConfig(cf *conf.Conf) {
	this.Servers = make(map[string]*ConfigMemcacheServer)
	this.HashStrategy = cf.String("hash_strategy", "standard")
	this.Timeout = cf.Duration("timeout", 4*time.Second)
	this.ReplicaN = cf.Int("replica_num", 1)
	section, err := cf.Section("breaker")
	if err == nil {
		this.Breaker.loadConfig(section)
	}
	this.MaxIdleConnsPerServer = cf.Int("max_idle_conns_per_server", 3)
	this.MaxConnsPerServer = cf.Int("max_conns_per_server",
		this.MaxIdleConnsPerServer*10)
	for i := 0; i < len(cf.List("servers", nil)); i++ {
		section, err := cf.Section(fmt.Sprintf("servers[%d]", i))
		if err != nil {
			panic(err)
		}

		server := new(ConfigMemcacheServer)
		server.loadConfig(section)
		this.Servers[server.Address()] = server
	}

	log.Debug("memcache conf: %+v", *this)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:25,代碼來源:memcache.go

示例3: LoadConfig

func (this *ConfigLock) LoadConfig(cf *conf.Conf) {
	this.MaxItems = cf.Int("max_items", 1<<20)
	this.Expires = cf.Duration("expires", time.Second*10)

	this.enabled = true

	log.Debug("lock conf: %+v", *this)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:8,代碼來源:lock.go

示例4: loadConfig

func (this *ConfigRedisServer) loadConfig(cf *conf.Conf) {
	this.Addr = cf.String("addr", "")
	if this.Addr == "" {
		panic("Empty redis server addr")
	}
	this.MaxIdle = cf.Int("max_idle", 10)
	this.MaxActive = cf.Int("max_active", this.MaxIdle*2)
	this.IdleTimeout = cf.Duration("idle_timeout", 10*time.Minute)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:9,代碼來源:redis.go

示例5: LoadConfig

func (this *ConfigProxy) LoadConfig(selfAddr string, cf *conf.Conf) {
	if selfAddr == "" {
		panic("proxy self addr unknown")
	}
	this.PoolCapacity = cf.Int("pool_capacity", 10)
	this.IdleTimeout = cf.Duration("idle_timeout", 0)
	this.IoTimeout = cf.Duration("io_timeout", time.Second*10)
	this.BorrowTimeout = cf.Duration("borrow_timeout", time.Second*10)
	this.DiagnosticInterval = cf.Duration("diagnostic_interval", time.Second*5)
	this.TcpNoDelay = cf.Bool("tcp_nodelay", true)
	this.BufferSize = cf.Int("buffer_size", 4<<10)
	this.SelfAddr = selfAddr
	parts := strings.SplitN(this.SelfAddr, ":", 2)
	if parts[0] == "" {
		// auto get local ip when self_addr like ":9001"
		ips, _ := ip.LocalIpv4Addrs()
		if len(ips) == 0 {
			panic("cannot get local ip address")
		}

		this.SelfAddr = ips[0] + ":" + parts[1]
	}

	log.Debug("proxy conf: %+v", *this)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:25,代碼來源:proxy.go

示例6: LoadConfig

func (this *ConfigMysql) LoadConfig(cf *conf.Conf) {
	this.GlobalPools = make(map[string]bool)
	for _, p := range cf.StringList("global_pools", nil) {
		this.GlobalPools[p] = true
	}
	this.ShardStrategy = cf.String("shard_strategy", "standard")
	this.MaxIdleTime = cf.Duration("max_idle_time", 0)
	this.Timeout = cf.Duration("timeout", 10*time.Second)
	this.AllowNullableColumns = cf.Bool("allow_nullable_columns", true)
	this.MaxIdleConnsPerServer = cf.Int("max_idle_conns_per_server", 2)
	this.MaxConnsPerServer = cf.Int("max_conns_per_server",
		this.MaxIdleConnsPerServer*5)
	this.CachePrepareStmtMaxItems = cf.Int("cache_prepare_stmt_max_items", 0)
	this.HeartbeatInterval = cf.Int("heartbeat_interval", 120)
	this.CacheStore = cf.String("cache_store", "mem")
	this.CacheStoreMemMaxItems = cf.Int("cache_store_mem_max_items", 10<<20)
	this.CacheStoreRedisPool = cf.String("cache_store_redis_pool", "db_cache")
	this.CacheKeyHash = cf.Bool("cache_key_hash", false)
	this.LookupPool = cf.String("lookup_pool", "ShardLookup")
	this.JsonMergeMaxOutstandingItems = cf.Int("json_merge_max_outstanding_items", 8<<20)
	this.LookupCacheMaxItems = cf.Int("lookup_cache_max_items", 1<<20)
	section, err := cf.Section("breaker")
	if err == nil {
		this.Breaker.loadConfig(section)
	}
	section, err = cf.Section("lookup_tables")
	if err == nil {
		this.lookupTables = *section
	} else {
		panic(err)
	}

	this.Servers = make(map[string]*ConfigMysqlServer)
	for i := 0; i < len(cf.List("servers", nil)); i++ {
		section, err := cf.Section(fmt.Sprintf("servers[%d]", i))
		if err != nil {
			panic(err)
		}

		server := new(ConfigMysqlServer)
		server.conf = this
		server.loadConfig(section)
		this.Servers[server.Pool] = server
	}

	log.Debug("mysql conf: %+v", *this)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:47,代碼來源:mysql.go

示例7: LoadConfig

func (this *ConfigRpc) LoadConfig(section *conf.Conf) {
	this.ListenAddr = section.String("listen_addr", "")
	if this.ListenAddr == "" {
		panic("Empty listen_addr")
	}

	this.SessionTimeout = section.Duration("session_timeout", 30*time.Second)
	this.IoTimeout = section.Duration("io_timeout", 2*time.Second)
	this.StatsOutputInterval = section.Duration("stats_output_interval", 10*time.Second)
	this.Framed = section.Bool("framed", false)
	this.BufferSize = section.Int("buffer_size", 4<<10)
	this.Protocol = section.String("protocol", "binary")
	this.PreforkMode = section.Bool("prefork_mode", false)
	this.MaxOutstandingSessions = section.Int("max_outstanding_sessions", 20000)
	this.HostMaxCallPerMinute = section.Int("host_max_call_per_minute", 100*60)

	log.Debug("rpc conf: %+v", *this)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:18,代碼來源:rpc.go

示例8: LoadConfig

func (this *ConfigServant) LoadConfig(selfAddr string, cf *conf.Conf) {
	this.IdgenWorkerId = cf.Int("idgen_worker_id", 1)
	this.SessionMaxItems = cf.Int("session_max_items", 20<<10)
	this.CallSlowThreshold = cf.Duration("call_slow_threshold", 2*time.Second)
	this.StatsOutputInterval = cf.Duration("stats_output_interval", 10*time.Minute)
	this.ProfilerMaxBodySize = cf.Int("profiler_max_body_size", 1<<10)
	this.ProfilerRate = cf.Int("profiler_rate", 1) // default 1/1000

	// mongodb section
	this.Mongodb = new(ConfigMongodb)
	section, err := cf.Section("mongodb")
	if err == nil {
		this.Mongodb.LoadConfig(section)
	}

	this.Mysql = new(ConfigMysql)
	section, err = cf.Section("mysql")
	if err == nil {
		this.Mysql.LoadConfig(section)
	}

	this.Redis = new(ConfigRedis)
	section, err = cf.Section("redis")
	if err == nil {
		this.Redis.LoadConfig(section)
	}

	// memcached section
	this.Memcache = new(ConfigMemcache)
	section, err = cf.Section("memcache")
	if err == nil {
		this.Memcache.LoadConfig(section)
	}

	// lcache section
	this.Lcache = new(ConfigLcache)
	section, err = cf.Section("lcache")
	if err == nil {
		this.Lcache.LoadConfig(section)
	}

	// couchbase section
	this.Couchbase = new(ConfigCouchbase)
	section, err = cf.Section("couchbase")
	if err == nil {
		this.Couchbase.LoadConfig(section)
	}

	// proxy section
	this.Proxy = new(ConfigProxy)
	section, err = cf.Section("proxy")
	if err == nil {
		this.Proxy.LoadConfig(selfAddr, section)
	}

	this.Lock = new(ConfigLock)
	section, err = cf.Section("lock")
	if err == nil {
		this.Lock.LoadConfig(section)
	}

	log.Debug("servants conf: %+v", *this)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:63,代碼來源:servant.go

示例9: loadConfig

func (this *ConfigBreaker) loadConfig(cf *conf.Conf) {
	this.FailureAllowance = uint(cf.Int("failure_allowance", 5))
	this.RetryTimeout = cf.Duration("retry_interval", 10*time.Second)
}
開發者ID:lucmichalski,項目名稱:fae,代碼行數:4,代碼來源:breaker.go


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