// 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 }
// 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 }
// 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 }
// Configure initializes this consumer with values from a plugin config. func (cons *Socket) Configure(conf core.PluginConfig) error { err := cons.ConsumerBase.Configure(conf) if err != nil { return err } cons.acknowledge = shared.Unescape(conf.GetString("Acknowledge", "")) cons.address, cons.protocol = shared.ParseAddress(conf.GetString("Address", ":5880")) if cons.protocol != "unix" { if cons.acknowledge != "" { cons.protocol = "tcp" } else { cons.protocol = "udp" } } cons.delimiter = shared.Unescape(conf.GetString("Delimiter", "\n")) cons.offset = conf.GetInt("Offset", 0) cons.flags = 0 partitioner := strings.ToLower(conf.GetString("Partitioner", "delimiter")) switch partitioner { case "binary_be": cons.flags |= shared.BufferedReaderFlagBigEndian fallthrough case "binary", "binary_le": cons.flags |= shared.BufferedReaderFlagEverything switch conf.GetInt("Size", 4) { case 1: cons.flags |= shared.BufferedReaderFlagMLE8 case 2: cons.flags |= shared.BufferedReaderFlagMLE16 case 4: cons.flags |= shared.BufferedReaderFlagMLE32 case 8: cons.flags |= shared.BufferedReaderFlagMLE64 default: return fmt.Errorf("Size only supports the value 1,2,4 and 8") } case "fixed": cons.flags |= shared.BufferedReaderFlagMLEFixed cons.offset = conf.GetInt("Size", 1) case "ascii": cons.flags |= shared.BufferedReaderFlagMLE case "delimiter": // Nothing to add default: return fmt.Errorf("Unknown partitioner: %s", partitioner) } cons.quit = false return err }
// Configure initializes this producer with values from a plugin config. func (prod *Proxy) Configure(conf core.PluginConfig) error { err := prod.ProducerBase.Configure(conf) if err != nil { return err } prod.SetStopCallback(prod.close) prod.bufferSizeKB = conf.GetInt("ConnectionBufferSizeKB", 1<<10) // 1 MB prod.address, prod.protocol = shared.ParseAddress(conf.GetString("Address", ":5880")) if prod.protocol == "udp" { return fmt.Errorf("Proxy does not support UDP") } prod.timeout = time.Duration(conf.GetInt("TimeoutSec", 1)) * time.Second delimiter := shared.Unescape(conf.GetString("Delimiter", "\n")) offset := conf.GetInt("Offset", 0) flags := shared.BufferedReaderFlagEverything // pass all messages as-is partitioner := strings.ToLower(conf.GetString("Partitioner", "delimiter")) switch partitioner { case "binary_be": flags |= shared.BufferedReaderFlagBigEndian fallthrough case "binary", "binary_le": switch conf.GetInt("Size", 4) { case 1: flags |= shared.BufferedReaderFlagMLE8 case 2: flags |= shared.BufferedReaderFlagMLE16 case 4: flags |= shared.BufferedReaderFlagMLE32 case 8: flags |= shared.BufferedReaderFlagMLE64 default: return fmt.Errorf("Size only supports the value 1,2,4 and 8") } case "fixed": flags |= shared.BufferedReaderFlagMLEFixed offset = conf.GetInt("Size", 1) case "ascii": flags |= shared.BufferedReaderFlagMLE case "delimiter": // Nothing to add default: return fmt.Errorf("Unknown partitioner: %s", partitioner) } prod.reader = shared.NewBufferedReader(prod.bufferSizeKB, flags, offset, delimiter) return nil }
// Configure initializes this consumer with values from a plugin config. func (cons *Syslogd) Configure(conf core.PluginConfig) error { err := cons.ConsumerBase.Configure(conf) if err != nil { return err } cons.address, cons.protocol = shared.ParseAddress(conf.GetString("Address", "udp://0.0.0.0:514")) format := conf.GetString("Format", "RFC6587") switch cons.protocol { case "udp", "tcp", "unix": default: return fmt.Errorf("Syslog: unknown protocol type %s", cons.protocol) // ### return, unknown protocol ### } switch format { // http://www.ietf.org/rfc/rfc3164.txt case "RFC3164": cons.format = syslog.RFC3164 if cons.protocol == "tcp" { Log.Warning.Print("Syslog: RFC3164 demands UDP") cons.protocol = "udp" } // https://tools.ietf.org/html/rfc5424 case "RFC5424": cons.format = syslog.RFC5424 if cons.protocol == "tcp" { Log.Warning.Print("Syslog: RFC5424 demands UDP") cons.protocol = "udp" } // https://tools.ietf.org/html/rfc6587 case "RFC6587": cons.format = syslog.RFC6587 default: err = fmt.Errorf("Syslog: Format %s is not supported", format) } cons.sequence = new(uint64) return err }
// Configure initializes this consumer with values from a plugin config. func (cons *Socket) Configure(conf core.PluginConfig) error { err := cons.ConsumerBase.Configure(conf) if err != nil { return err } flags, err := strconv.ParseInt(conf.GetString("Permissions", "0770"), 8, 32) cons.fileFlags = os.FileMode(flags) if err != nil { return err } cons.clients = list.New() cons.clientLock = new(sync.Mutex) cons.acknowledge = shared.Unescape(conf.GetString("Acknowledge", "")) cons.address, cons.protocol = shared.ParseAddress(conf.GetString("Address", ":5880")) cons.reconnectTime = time.Duration(conf.GetInt("ReconnectAfterSec", 2)) * time.Second cons.ackTimeout = time.Duration(conf.GetInt("AckTimoutSec", 2)) * time.Second cons.readTimeout = time.Duration(conf.GetInt("ReadTimoutSec", 5)) * time.Second cons.clearSocket = conf.GetBool("RemoveOldSocket", true) if cons.protocol != "unix" { if cons.acknowledge != "" { cons.protocol = "tcp" } else { cons.protocol = "udp" } } cons.delimiter = shared.Unescape(conf.GetString("Delimiter", "\n")) cons.offset = conf.GetInt("Offset", 0) cons.flags = 0 partitioner := strings.ToLower(conf.GetString("Partitioner", "delimiter")) switch partitioner { case "binary_be": cons.flags |= shared.BufferedReaderFlagBigEndian fallthrough case "binary", "binary_le": cons.flags |= shared.BufferedReaderFlagEverything switch conf.GetInt("Size", 4) { case 1: cons.flags |= shared.BufferedReaderFlagMLE8 case 2: cons.flags |= shared.BufferedReaderFlagMLE16 case 4: cons.flags |= shared.BufferedReaderFlagMLE32 case 8: cons.flags |= shared.BufferedReaderFlagMLE64 default: return fmt.Errorf("Size only supports the value 1,2,4 and 8") } case "fixed": cons.flags |= shared.BufferedReaderFlagMLEFixed cons.offset = conf.GetInt("Size", 1) case "ascii": cons.flags |= shared.BufferedReaderFlagMLE case "delimiter": // Nothing to add default: return fmt.Errorf("Unknown partitioner: %s", partitioner) } return err }