本文整理汇总了Golang中github.com/funkygao/jsconf.Conf.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Conf.String方法的具体用法?Golang Conf.String怎么用?Golang Conf.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/funkygao/jsconf.Conf
的用法示例。
在下文中一共展示了Conf.String方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例2: Init
func (this *SkyOutput) Init(config *conf.Conf) {
const TYPE_SEP = ":"
this.uidFieldType, this.actionFieldType = als.KEY_TYPE_INT, als.KEY_TYPE_STRING
this.uidField = config.String("uid_field", "_log_info.uid")
if strings.Contains(this.uidField, TYPE_SEP) {
p := strings.SplitN(this.uidField, TYPE_SEP, 2)
this.uidField, this.uidFieldType = p[0], p[1]
}
this.actionField = config.String("action_field", "action")
if this.actionField == "" {
panic("empty action field")
}
if strings.Contains(this.actionField, TYPE_SEP) {
p := strings.SplitN(this.actionField, TYPE_SEP, 2)
this.actionField, this.actionFieldType = p[0], p[1]
}
this.project = config.String("project", "")
var (
host string = config.String("host", "localhost")
port int = config.Int("port", 8585)
)
client := sky.NewClient(host)
client.Port = port
if !client.Ping() {
panic(fmt.Sprintf("sky server not running: %s:%d", host, port))
}
this.table, _ = client.GetTable(config.String("table", ""))
if this.table == nil {
panic("must create table in advance")
}
}
示例3: Init
func (this *SyslogngInput) Init(config *conf.Conf) {
this.ident = config.String("ident", "")
if this.ident == "" {
panic("empty ident")
}
this.addr = config.String("addr", ":9787")
}
示例4: load
func (this *esConverter) load(section *conf.Conf) {
this.keys = section.StringList("keys", nil)
this.typ = section.String("type", "")
this.currency = section.String("currency", "")
this.rang = section.IntList("range", nil)
this.normalizers = section.StringList("normalizers", nil)
}
示例5: Init
func (this *SelfSysInput) Init(config *conf.Conf) {
this.stopChan = make(chan bool)
this.ident = config.String("ident", "")
if this.ident == "" {
panic("empty ident")
}
}
示例6: Init
func (this *CardinalityOutput) Init(config *conf.Conf) {
this.checkpoint = config.String("checkpoint", "")
this.counters = stats.NewCardinalityCounter()
if this.checkpoint != "" {
this.counters.Load(this.checkpoint)
}
}
示例7: loadConfig
func (this *ConfigMysqlServer) loadConfig(section *conf.Conf) {
this.Pool = section.String("pool", "")
this.Host = section.String("host", "")
this.Port = section.String("port", "3306")
this.DbName = section.String("db", "")
this.User = section.String("username", "")
this.Pass = section.String("password", "")
this.Charset = section.String("charset", "utf8")
if this.Host == "" ||
this.Port == "" ||
this.Pool == "" ||
this.DbName == "" {
panic("required field missing")
}
this.dsn = ""
if this.User != "" {
this.dsn = this.User + ":"
if this.Pass != "" {
this.dsn += this.Pass
}
}
this.dsn += fmt.Sprintf("@tcp(%s:%s)/%s?", this.Host, this.Port, this.DbName)
if this.Charset != "" {
this.dsn += "charset=" + this.Charset
}
if this.conf.Timeout > 0 {
this.dsn += "&timeout=" + this.conf.Timeout.String()
}
}
示例8: 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)
}
示例9: loadConfig
func (this *ConfigMongodbServer) loadConfig(section *conf.Conf) {
this.Pool = section.String("pool", "")
this.Host = section.String("host", "")
this.Port = section.String("port", "27017")
this.DbName = section.String("db", "")
this.ShardBaseNum = section.Int("shard_base_num", this.ShardBaseNum)
this.User = section.String("user", "")
this.Pass = section.String("pass", "")
this.ReplicaSet = section.String("replicaSet", "")
if this.Host == "" ||
this.Port == "" ||
this.Pool == "" ||
this.DbName == "" {
panic("required field missing")
}
// http://docs.mongodb.org/manual/reference/connection-string/
this.uri = "mongodb://" + this.Host + ":" + this.Port + "/"
if this.DbName != "" {
this.uri += this.DbName + "/"
}
if this.ReplicaSet != "" {
this.uri += "?replicaSet=" + this.ReplicaSet
}
}
示例10: Init
func (this *FlashlogInput) Init(config *conf.Conf) {
this.dsn = config.String("dsn",
"flashlog:[email protected](/var/run/mysqld/mysqld.sock)/flashlog?charset=utf8")
this.ident = config.String("ident", "")
if this.ident == "" {
panic("empty ident")
}
}
示例11: 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)
}
示例12: 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)
}
示例13: loadConfig
func (this *ConfigMemcacheServer) loadConfig(section *conf.Conf) {
this.host = section.String("host", "")
if this.host == "" {
panic("Empty memcache server host")
}
this.hort = section.String("port", "")
if this.hort == "" {
panic("Empty memcache server port")
}
log.Debug("memcache server: %+v", *this)
}
示例14: 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)
}
示例15: 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)
}