本文整理匯總了Golang中github.com/funkygao/jsconf.Conf.Section方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conf.Section方法的具體用法?Golang Conf.Section怎麽用?Golang Conf.Section使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/funkygao/jsconf.Conf
的用法示例。
在下文中一共展示了Conf.Section方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LoadConfig
func (this *ConfigRedis) LoadConfig(cf *conf.Conf) {
section, err := cf.Section("breaker")
if err == nil {
this.Breaker.loadConfig(section)
}
this.Servers = make(map[string]map[string]*ConfigRedisServer)
for i := 0; i < len(cf.List("pools", nil)); i++ {
section, err := cf.Section(fmt.Sprintf("pools[%d]", i))
if err != nil {
panic(err)
}
pool := section.String("name", "")
if pool == "" {
panic("Empty redis pool name")
}
this.Servers[pool] = make(map[string]*ConfigRedisServer)
// get servers in each pool
for j := 0; j < len(section.List("servers", nil)); j++ {
server, err := section.Section(fmt.Sprintf("servers[%d]", j))
if err != nil {
panic(err)
}
redisServer := new(ConfigRedisServer)
redisServer.loadConfig(server)
this.Servers[pool][redisServer.Addr] = redisServer
}
}
log.Debug("redis conf: %+v", *this)
}
示例2: 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)
}
示例3: Init
func (this *EsFilter) Init(config *conf.Conf) {
this.ident = config.String("ident", "")
if this.ident == "" {
panic("empty ident")
}
this.converters = make([]esConverter, 0, 10)
this.indexPattern = config.String("index_pattern", "")
for i := 0; i < len(config.List("converts", nil)); i++ {
section, err := config.Section(fmt.Sprintf("%s[%d]", "converts", i))
if err != nil {
panic(err)
}
c := esConverter{}
c.load(section)
this.converters = append(this.converters, c)
}
geodbFile := config.String("geodbfile", "")
if err := als.LoadGeoDb(geodbFile); err != nil {
panic(err)
}
globals := engine.Globals()
if globals.Verbose {
globals.Printf("Loaded geodb %s\n", geodbFile)
}
}
示例4: 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)
}
示例5: LoadConfig
func (this *Engine) LoadConfig(cf *conf.Conf) *Engine {
config.LoadEngineConfig(cf)
if section, err := cf.Section("plugin"); err == nil {
plugin.LoadPlugins(section)
}
return this
}
示例6: loadConfig
func (this *apiConfig) loadConfig(section *conf.Conf) {
this.controller = section.String("controller", "")
this.action = section.String("action", "")
io, err := section.Section("io")
if err != nil {
panic(err)
}
this.input = io.Object("input", nil)
this.output = io.Object("output", nil)
}
示例7: loadConfig
func (this *ConfigMongodb) loadConfig(cf *conf.Conf) {
this.ShardBaseNum = cf.Int("shard_base_num", 100000)
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.loadConfig(section)
this.Servers[server.ShardName] = server
}
log.Debug("mongodb: %+v", *this)
}
示例8: loadConfig
func (this *ConfigMemcache) loadConfig(cf *conf.Conf) {
this.Servers = make(map[string]*ConfigMemcacheServer)
this.HashStrategy = cf.String("hash_strategy", "standard")
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: %+v", *this)
}
示例9: Init
func (this *CardinalityFilter) Init(config *conf.Conf) {
this.ident = config.String("ident", "")
if this.ident == "" {
panic("empty ident")
}
for i := 0; i < len(config.List("converts", nil)); i++ {
section, err := config.Section(fmt.Sprintf("%s[%d]", "converts", i))
if err != nil {
panic(err)
}
c := cardinalityConverter{}
c.load(section)
this.converters = append(this.converters, c)
}
}
示例10: 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))
}
}
示例11: LoadPlugins
func LoadPlugins(cf *conf.Conf) {
for i := 0; i < PackRecyclePoolSize; i++ {
pack := NewPipelinePack(packRecycleChan)
packRecycleChan <- pack
}
for i := 0; i < len(cf.List("plugins", nil)); i++ {
section, err := cf.Section(fmt.Sprintf("plugins[%d]", i))
if err != nil {
panic(err)
}
name := section.String("name", "")
if name == "" {
panic("empty plugin name")
}
loadOnePlugin(name, section)
}
}
示例12: Init
func (this *EsBufferFilter) Init(config *conf.Conf) {
this.ident = config.String("ident", "")
if this.ident == "" {
panic("empty ident")
}
this.stopChan = make(chan interface{})
this.wokers = make([]*esBufferWorker, 0, 10)
for i := 0; i < len(config.List("workers", nil)); i++ {
section, err := config.Section(fmt.Sprintf("workers[%d]", i))
if err != nil {
panic(err)
}
worker := new(esBufferWorker)
worker.init(section, this.ident, this.stopChan)
this.wokers = append(this.wokers, worker)
}
}
示例13: loadConfig
func (this *ConfigMongodb) loadConfig(cf *conf.Conf) {
this.ShardBaseNum = cf.Int("shard_base_num", 100000)
this.ConnectTimeout = cf.Int("connect_timeout", 4)
this.IoTimeout = cf.Int("io_timeout", 30)
this.MaxIdleConnsPerServer = cf.Int("max_idle_conns_per_server", 2)
this.HeartbeatInterval = cf.Int("heartbeat_interval", 120)
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.Kind] = server
}
log.Debug("mongodb: %+v", *this)
}
示例14: Init
func (this *AlarmOutput) Init(config *conf.Conf) {
this.stopChan = make(chan interface{})
this.projects = make(map[string]alarmProjectConf)
for i := 0; i < len(config.List("projects", nil)); i++ {
section, err := config.Section(fmt.Sprintf("projects[%d]", i))
if err != nil {
panic(err)
}
project := alarmProjectConf{}
project.stopChan = this.stopChan
project.fromConfig(section)
if _, present := this.projects[project.name]; present {
panic("dup project: " + project.name)
}
this.projects[project.name] = project
}
if len(this.projects) == 0 {
panic("empty projects")
}
}
示例15: LoadServants
func LoadServants(cf *conf.Conf) {
// 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)
}