本文整理汇总了Golang中github.com/trivago/gollum/core.NewPluginWithType函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPluginWithType函数的具体用法?Golang NewPluginWithType怎么用?Golang NewPluginWithType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewPluginWithType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例5: 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
}
示例6: 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
}
示例7: 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
}
示例8: 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
}
示例9: 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
}
示例10: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *Envelope) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("EnvelopeFormatter", "format.Forward"), conf)
if err != nil {
return err
}
format.base = plugin.(core.Formatter)
format.prefix = shared.Unescape(conf.GetString("EnvelopePrefix", ""))
format.postfix = shared.Unescape(conf.GetString("EnvelopePostfix", "\n"))
return nil
}
示例11: TestConsumerInterface
func TestConsumerInterface(t *testing.T) {
conf := core.NewPluginConfig(reflect.TypeOf(t).Name())
consumers := shared.TypeRegistry.GetRegistered("consumer.")
if len(consumers) == 0 {
t.Error("No consumers defined")
}
for _, name := range consumers {
_, err := core.NewPluginWithType(name, conf)
if err != nil {
t.Errorf("Failed to create consumer %s: %s", name, err.Error())
}
}
}
示例12: TestFormatters
func TestFormatters(t *testing.T) {
conf := core.NewPluginConfig(reflect.TypeOf(t).Name())
formatters := shared.TypeRegistry.GetRegistered("format.")
if len(formatters) == 0 {
t.Error("No formatters defined")
}
for _, name := range formatters {
_, err := core.NewPluginWithType(name, conf)
if err != nil {
t.Errorf("Failed to create formatter %s: %s", name, err.Error())
}
}
}
示例13: TestStreamInterface
func TestStreamInterface(t *testing.T) {
conf := core.NewPluginConfig(reflect.TypeOf(t).Name())
conf.Stream = []string{"test"}
streams := shared.TypeRegistry.GetRegistered("stream.")
if len(streams) == 0 {
t.Error("No streams defined")
}
for _, name := range streams {
_, err := core.NewPluginWithType(name, conf)
if err != nil {
t.Errorf("Failed to create stream %s: %s", name, err.Error())
}
}
}
示例14: Configure
// Configure initializes this formatter with values from a plugin config.
func (format *Base64Decode) Configure(conf core.PluginConfig) error {
plugin, err := core.NewPluginWithType(conf.GetString("Base64Formatter", "format.Forward"), conf)
if err != nil {
return err
}
format.base = plugin.(core.Formatter)
dict := conf.GetString("Base64Dictionary", "")
if dict == "" {
format.dictionary = base64.StdEncoding
} else {
if len(dict) != 64 {
return fmt.Errorf("Base64 dictionary must contain 64 characters.")
}
format.dictionary = base64.NewEncoding(dict)
}
return nil
}
示例15: TestFormatters
func TestFormatters(t *testing.T) {
conf := core.NewPluginConfig(reflect.TypeOf(t).Name())
formatters := shared.RuntimeType.GetRegistered("format.")
if len(formatters) == 0 {
t.Error("No formatters defined")
}
for _, name := range formatters {
plugin, err := core.NewPluginWithType(name, conf)
if err != nil {
t.Errorf("Failed to create formatter %s: %s", name, err.Error())
} else {
if !testFormatter(plugin.(core.Formatter)) {
t.Errorf("Formatter %s tests failed", name)
}
}
}
}