本文整理匯總了Golang中github.com/funkygao/jsconf.Conf.Bool方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conf.Bool方法的具體用法?Golang Conf.Bool怎麽用?Golang Conf.Bool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/funkygao/jsconf.Conf
的用法示例。
在下文中一共展示了Conf.Bool方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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)
}
示例2: LoadServants
func LoadServants(cf *conf.Conf) {
Servants.WatchdogInterval = cf.Int("watchdog_interval", 60*10)
Servants.PeersCooperate = cf.Bool("peers_cooperate", false)
Servants.ProfilerMaxAnswerSize = cf.Int("prof_max_answer_size", 4<<10)
Servants.ProfilerRate = cf.Int("profiler_rate", 1) // default 1/1000
// mongodb section
Servants.Mongodb = new(ConfigMongodb)
section, err := cf.Section("mongodb")
if err != nil {
panic(err)
}
Servants.Mongodb.loadConfig(section)
// memcached section
Servants.Memcache = new(ConfigMemcache)
section, err = cf.Section("memcache")
if err != nil {
panic(err)
}
Servants.Memcache.loadConfig(section)
// lcache section
Servants.Lcache = new(ConfigLcache)
section, err = cf.Section("lcache")
if err != nil {
panic(err)
}
Servants.Lcache.loadConfig(section)
}
示例3: 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)
}
示例4: loadConfig
func (this *configRpc) loadConfig(section *conf.Conf) {
this.listenAddr = section.String("listen_addr", "")
if this.listenAddr == "" {
panic("Empty listen_addr")
}
this.clientTimeout = time.Duration(section.Int("client_timeout", 0)) * time.Second
this.framed = section.Bool("framed", false)
this.protocol = section.String("protocol", "binary")
log.Debug("rpc: %+v", *this)
}
示例5: Init
func (this *EsOutput) Init(config *conf.Conf) {
this.stopChan = make(chan bool)
api.Domain = config.String("domain", "localhost")
this.counters = sortedmap.NewSortedMap()
api.Port = config.String("port", "9200")
this.reportInterval = time.Duration(config.Int("report_interval", 30)) * time.Second
this.showProgress = config.Bool("show_progress", true)
this.flushInterval = time.Duration(config.Int("flush_interval", 30)) * time.Second
this.bulkMaxConn = config.Int("bulk_max_conn", 20)
this.bulkMaxDocs = config.Int("bulk_max_docs", 100)
this.bulkMaxBuffer = config.Int("bulk_max_buffer", 10<<20) // 10 MB
this.dryRun = config.Bool("dryrun", false)
}
示例6: load
func (this *pluginCommons) load(section *conf.Conf) {
this.name = section.String("name", "")
if this.name == "" {
pretty.Printf("%# v\n", *section)
panic(fmt.Sprintf("invalid plugin config: %v", *section))
}
this.class = section.String("class", "")
if this.class == "" {
this.class = this.name
}
this.comment = section.String("comment", "")
this.ticker = section.Int("ticker_interval", Globals().TickerLength)
this.disabled = section.Bool("disabled", false)
}
示例7: 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)
}
示例8: 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)
}
示例9: init
func (this *alarmWorkerConfig) init(config *conf.Conf) {
this.camelName = config.String("camel_name", "")
if this.camelName == "" {
panic("empty 'camel_name'")
}
this.title = config.String("title", "")
if this.title == "" {
this.title = this.camelName
}
this.colors = config.StringList("colors", nil)
this.printFormat = config.String("printf", "")
this.instantFormat = config.String("iprintf", "")
if this.printFormat == "" && this.instantFormat == "" {
panic(fmt.Sprintf("%s empty 'printf' and 'iprintf'", this.title))
}
this.severity = config.Int("severity", 1)
this.windowSize = time.Duration(config.Int("window_size", 0)) * time.Second
this.showSummary = config.Bool("show_summary", false)
this.beepThreshold = config.Int("beep_threshold", 0)
this.abnormalBase = config.Int("abnormal_base", 10)
this.abnormalSeverityFactor = config.Int("abnormal_severity_factor", 2)
this.abnormalPercent = config.Float("abnormal_percent", 1.5)
this.dbName = config.String("dbname", "")
this.tableName = this.dbName // table name is db name
this.createTable = config.String("create_table", "")
this.insertStmt = config.String("insert_stmt", "")
this.statsStmt = config.String("stats_stmt", "")
this.fields = make([]alarmWorkerConfigField, 0, 5)
for i := 0; i < len(config.List("fields", nil)); i++ {
section, err := config.Section(fmt.Sprintf("fields[%d]", i))
if err != nil {
panic(err)
}
field := alarmWorkerConfigField{}
field.init(section)
this.fields = append(this.fields, field)
}
if len(this.fields) == 0 {
panic(fmt.Sprintf("%s empty 'fields'", this.title))
}
}
示例10: fromConfig
func (this *ConfProject) fromConfig(c *conf.Conf) {
this.Name = c.String("name", "")
if this.Name == "" {
panic("project must has 'name'")
}
this.IndexPrefix = c.String("index_prefix", this.Name)
this.ShowError = c.Bool("show_error", true)
logfile := c.String("logfile", "var/"+this.Name+".log")
logWriter, err := os.OpenFile(logfile, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0644)
if err != nil {
panic(err)
}
logOptions := log.Ldate | log.Ltime
if Globals().Verbose {
logOptions |= log.Lshortfile
}
if Globals().Debug {
logOptions |= log.Lmicroseconds
}
this.Logger = log.New(logWriter, "", logOptions)
}
示例11: handleSection
// recursively
func handleSection(section *conf.Conf) {
ident := section.String(IDENT, "")
if ident != "" {
if _, present := graph[ident]; present {
fmt.Printf("ident[%s]duplicated\n", ident)
os.Exit(1)
}
ie := &identEntry{}
ie.matches = make([]string, 0, 10)
ie.disabled = section.Bool(DISABLED, false)
if section.StringList(MATCH, nil) == nil {
ie.isInput = true
}
graph[ident] = ie
pluginName := section.String(NAME, "")
if pluginName != "" {
identName[pluginName] = ident
}
}
matches := section.StringList(MATCH, nil)
if matches != nil {
pluginName := section.String(NAME, "")
if pluginName == "" {
fmt.Printf("plugin match %v has no 'name' key\n", matches)
os.Exit(1)
}
for _, id := range matches {
if _, present := graph[id]; present {
graph[id].matches = append(graph[id].matches, pluginName)
} else {
fmt.Printf("%15s -> %s\n", id, pluginName)
}
}
}
sub := section.Interface("", nil).(map[string]interface{})
if sub == nil {
return
}
for k, v := range sub {
if x, ok := v.([]interface{}); ok {
switch x[0].(type) {
case string, float64, int, bool, time.Time:
// this section will never find 'ident'
continue
}
for i := 0; i < len(section.List(k, nil)); i++ {
key := fmt.Sprintf("%s[%d]", k, i)
sec, err := section.Section(key)
if err != nil {
continue
}
handleSection(sec)
}
}
}
}
示例12: Init
func (this *DebugOutput) Init(config *conf.Conf) {
this.blackhole = config.Bool("blackhole", false)
}