本文整理汇总了Golang中github.com/trivago/gollum/core.PluginConfig.GetString方法的典型用法代码示例。如果您正苦于以下问题:Golang PluginConfig.GetString方法的具体用法?Golang PluginConfig.GetString怎么用?Golang PluginConfig.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/trivago/gollum/core.PluginConfig
的用法示例。
在下文中一共展示了PluginConfig.GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: configure
// Configure sets the database connection values
func (writer *influxDBWriter09) configure(conf core.PluginConfig, prod *InfluxDB) error {
writer.host = conf.GetString("Host", "localhost:8086")
writer.username = conf.GetString("User", "")
writer.password = conf.GetString("Password", "")
writer.databaseTemplate = conf.GetString("Database", "default")
writer.buffer = shared.NewByteStream(4096)
writer.connectionUp = false
writer.Control = prod.Control
writer.writeURL = fmt.Sprintf("http://%s/write", writer.host)
writer.queryURL = fmt.Sprintf("http://%s/query", writer.host)
writer.pingURL = fmt.Sprintf("http://%s/ping", writer.host)
writer.separator = '?'
writer.timeBasedDBName = conf.GetBool("TimeBasedName", true)
if writer.username != "" {
credentials := fmt.Sprintf("?u=%s&p=%s", url.QueryEscape(writer.username), url.QueryEscape(writer.password))
writer.writeURL += credentials
writer.queryURL += credentials
writer.separator = '&'
}
if retentionPolicy := conf.GetString("RetentionPolicy", ""); retentionPolicy != "" {
writer.messageHeader = fmt.Sprintf("{\"database\":\"%%s\",\"retentionPolicy\":\"%s\",\"points\":[", retentionPolicy)
} else {
writer.messageHeader = "{\"database\":\"%s\",\"points\":["
}
prod.SetCheckFuseCallback(writer.isConnectionUp)
return nil
}
示例2: Configure
// Configure initializes this producer with values from a plugin config.
func (prod *Scribe) Configure(conf core.PluginConfig) error {
err := prod.ProducerBase.Configure(conf)
if err != nil {
return err
}
host := conf.GetString("Address", "localhost:1463")
bufferSizeMax := conf.GetInt("BatchSizeMaxKB", 8<<10) << 1 // 8 MB
prod.category = make(map[core.MessageStreamID]string, 0)
prod.batchSize = conf.GetInt("BatchSizeByte", 8192)
prod.batchTimeout = time.Duration(conf.GetInt("BatchTimeoutSec", 5)) * time.Second
prod.batch = createScribeMessageBatch(bufferSizeMax)
prod.bufferSizeKB = conf.GetInt("ConnectionBufferSizeKB", 1<<10) // 1 MB
prod.category = conf.GetStreamMap("Category", "")
// Initialize scribe connection
prod.socket, err = thrift.NewTSocket(host)
if err != nil {
Log.Error.Print("Scribe socket error:", err)
return err
}
prod.transport = thrift.NewTFramedTransport(prod.socket)
binProtocol := thrift.NewTBinaryProtocol(prod.transport, false, false)
prod.scribe = scribe.NewScribeClientProtocol(prod.transport, binProtocol, binProtocol)
return nil
}
示例3: Configure
// Configure initializes this producer with values from a plugin config.
func (prod *Redis) Configure(conf core.PluginConfig) error {
err := prod.ProducerBase.Configure(conf)
if err != nil {
return err
}
fieldFormat, err := core.NewPluginWithType(conf.GetString("FieldFormatter", "format.Identifier"), conf)
if err != nil {
return err // ### return, plugin load error ###
}
prod.fieldFormat = fieldFormat.(core.Formatter)
prod.password = conf.GetString("Password", "")
prod.database = int64(conf.GetInt("Database", 0))
prod.key = conf.GetString("Key", "default")
prod.fieldFromParsed = conf.GetBool("FieldAfterFormat", false)
prod.address, prod.protocol = shared.ParseAddress(conf.GetString("Address", ":6379"))
switch strings.ToLower(conf.GetString("Storage", "hash")) {
case "hash":
prod.store = prod.storeHash
case "list":
prod.store = prod.storeList
case "set":
prod.store = prod.storeSet
case "sortedset":
prod.store = prod.storeSortedSet
default:
fallthrough
case "string":
prod.store = prod.storeString
}
return nil
}
示例4: Configure
// Configure initializes this producer with values from a plugin config.
func (prod *Socket) Configure(conf core.PluginConfig) error {
err := prod.ProducerBase.Configure(conf)
if err != nil {
return err
}
prod.SetStopCallback(prod.close)
prod.batchMaxCount = conf.GetInt("BatchMaxCount", 8192)
prod.batchFlushCount = conf.GetInt("BatchFlushCount", prod.batchMaxCount/2)
prod.batchFlushCount = shared.MinI(prod.batchFlushCount, prod.batchMaxCount)
prod.batchTimeout = time.Duration(conf.GetInt("BatchTimeoutSec", 5)) * time.Second
prod.bufferSizeByte = conf.GetInt("ConnectionBufferSizeKB", 1<<10) << 10 // 1 MB
prod.acknowledge = shared.Unescape(conf.GetString("Acknowledge", ""))
prod.ackTimeout = time.Duration(conf.GetInt("AckTimeoutMs", 2000)) * time.Millisecond
prod.address, prod.protocol = shared.ParseAddress(conf.GetString("Address", ":5880"))
if prod.protocol != "unix" {
if prod.acknowledge != "" {
prod.protocol = "tcp"
} else {
prod.protocol = "udp"
}
}
prod.batch = core.NewMessageBatch(prod.batchMaxCount)
prod.assembly = core.NewWriterAssembly(nil, prod.Drop, prod.GetFormatter())
prod.assembly.SetValidator(prod.validate)
prod.assembly.SetErrorHandler(prod.onWriteError)
prod.SetCheckFuseCallback(prod.tryConnect)
return nil
}
示例5: Configure
// Configure initializes this producer with values from a plugin config.
func (prod *Socket) Configure(conf core.PluginConfig) error {
err := prod.ProducerBase.Configure(conf)
if err != nil {
return err
}
bufferSizeMax := conf.GetInt("BatchSizeMaxKB", 8<<10) << 10
prod.batchSize = conf.GetInt("BatchSizeByte", 8192)
prod.batchTimeout = time.Duration(conf.GetInt("BatchTimeoutSec", 5)) * time.Second
prod.bufferSizeKB = conf.GetInt("ConnectionBufferSizeKB", 1<<10) // 1 MB
prod.acknowledge = shared.Unescape(conf.GetString("Acknowledge", ""))
prod.address, prod.protocol = shared.ParseAddress(conf.GetString("Address", ":5880"))
if prod.protocol != "unix" {
if prod.acknowledge != "" {
prod.protocol = "tcp"
} else {
prod.protocol = "udp"
}
}
prod.batch = core.NewMessageBatch(bufferSizeMax, prod.ProducerBase.GetFormatter())
return nil
}
示例6: Configure
// Configure initializes this producer with values from a plugin config.
func (prod *Spooling) Configure(conf core.PluginConfig) error {
conf.Override("Formatter", "format.Serialize")
err := prod.ProducerBase.Configure(conf)
if err != nil {
return err
}
prod.SetStopCallback(prod.close)
prod.path = conf.GetString("Path", "/var/run/gollum/spooling")
prod.maxFileSize = int64(conf.GetInt("MaxFileSizeMB", 512)) << 20
prod.maxFileAge = time.Duration(conf.GetInt("MaxFileAgeMin", 1)) * time.Minute
prod.batchMaxCount = conf.GetInt("BatchMaxCount", 100)
prod.batchTimeout = time.Duration(conf.GetInt("BatchTimeoutSec", 5)) * time.Second
prod.outfile = make(map[core.MessageStreamID]*spoolFile)
prod.rotation = fileRotateConfig{
timeout: prod.maxFileAge,
sizeByte: prod.maxFileSize,
atHour: -1,
atMinute: -1,
enabled: true,
compress: false,
}
return nil
}
示例7: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *CollectdToInflux08) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("CollectdToInfluxFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.base = plugin.(core.Formatter)
return nil
}
示例8: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *Runlength) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("RunlengthFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.base = plugin.(core.Formatter)
return nil
}
示例9: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *Hostname) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("HostnameFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.separator = conf.GetString("HostnameSeparator", " ")
format.base = plugin.(core.Formatter)
return nil
}
示例10: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *Serialize) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("SerializeFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.encode = conf.GetBool("SerializeStringEncode", true)
format.base = plugin.(core.Formatter)
return nil
}
示例11: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *CollectdToInflux10) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("CollectdToInflux1009", "format.Forward"), conf)
if err != nil {
return err
}
format.base = plugin.(core.Formatter)
format.tagString = strings.NewReplacer(",", "\\,", " ", "\\ ")
format.stringString = strings.NewReplacer("\"", "\\\"")
return nil
}
示例12: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *StreamName) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("StreamNameFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.separator = conf.GetString("StreamNameSeparator", " ")
format.usePrevious = conf.GetBool("StreamNameHistory", false)
format.base = plugin.(core.Formatter)
return nil
}
示例13: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *Timestamp) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("TimestampFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.base = plugin.(core.Formatter)
format.timestampFormat = conf.GetString("Timestamp", "2006-01-02 15:04:05 MST | ")
return nil
}
示例14: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *StreamRoute) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("StreamRouteFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.delimiter = []byte(conf.GetString("StreamRouteDelimiter", ":"))
format.base = plugin.(core.Formatter)
return nil
}
示例15: Configure
// Configure initializes this consumer with values from a plugin config.
func (cons *Http) Configure(conf core.PluginConfig) error {
err := cons.ConsumerBase.Configure(conf)
if err != nil {
return err
}
cons.address = conf.GetString("Address", ":80")
cons.readTimeoutSec = time.Duration(conf.GetInt("ReadTimeoutSec", 3)) * time.Second
cons.withHeaders = conf.GetBool("WithHeaders", true)
return err
}