// Configure initializes this filter with values from a plugin config.
435912
func (filter *JSON) Configure(conf core.PluginConfigReader) {
	rejectValues := conf.GetStringMap("Reject", make(map[string]string))
	acceptValues := conf.GetStringMap("Accept", make(map[string]string))

	// Compile regexp from map[string]string to map[string]*regexp.Regexp
	filter.rejectValues = make(map[string]*regexp.Regexp)
	filter.acceptValues = make(map[string]*regexp.Regexp)

	for key, val := range rejectValues {
		exp, err := regexp.Compile(val)
		if !conf.Errors.Push(err) {
			filter.rejectValues[key] = exp
		}
	}

	for key, val := range acceptValues {
		exp, err := regexp.Compile(val)
		if !conf.Errors.Push(err) {
			filter.acceptValues[key] = exp
		}
	}

	applyTo := conf.GetString("ApplyTo", "")
	filter.getAppliedContent = core.GetAppliedContentGetFunction(applyTo)
}
1272712
func (prod *Scribe) Configure(conf core.PluginConfigReader) {
	prod.SetStopCallback(prod.close)
	host := conf.GetString("Address", "localhost:1463")
	prod.category = conf.GetStreamMap("Categories", "")
	prod.windowSize = prod.maxWindowSize
	prod.categoryGuard = new(sync.RWMutex)
	prod.metricsRegistry = core.NewMetricsRegistryForPlugin(prod)
	prod.metricCount = make(map[core.MessageStreamID]metrics.Counter)

	// Initialize scribe connection

	var err error
	prod.socket, err = thrift.NewTSocketTimeout(host, prod.connectionTimeout)
	conf.Errors.Push(err)

	prod.transport = thrift.NewTFramedTransport(prod.socket)
	binProtocol := thrift.NewTBinaryProtocol(prod.transport, false, false)
	prod.scribe = scribe.NewScribeClientProtocol(prod.transport, binProtocol, binProtocol)

	prod.metricWindowSize = metrics.NewGauge()
	prod.metricsRegistry.Register("windowsize", prod.metricWindowSize)

	for streamID, category := range prod.category {
		counter := metrics.NewCounter()
		prod.metricCount[streamID] = counter
		prod.metricsRegistry.Register(category, counter)
	}
}
1169554
func (router *Distribute) Configure(conf core.PluginConfigReader) {
	router.boundStreamIDs = conf.GetStreamArray("TargetStreams", []core.MessageStreamID{})
}
1212072
func (c *BatchedWriterConfig) Configure(conf core.PluginConfigReader) {
	c.BatchFlushCount = tmath.MinI(c.BatchFlushCount, c.BatchMaxCount)
}
660374
func (prod *SimpleProducer) Configure(conf PluginConfigReader) {
	prod.id = conf.GetID()
	prod.Logger = conf.GetLogger()
	prod.runState = NewPluginRunState()
	prod.control = make(chan PluginControl, 1)

	// Simple health check for the plugin state
	//   Path: "/<plugin_id>/pluginState"
	prod.AddHealthCheckAt("/pluginState", func() (code int, body string) {
		if prod.IsActive() {
			return thealthcheck.StatusOK,
				fmt.Sprintf("ACTIVE: %s", prod.runState.GetStateString())
		}
		return thealthcheck.StatusServiceUnavailable,
			fmt.Sprintf("NOT_ACTIVE: %s", prod.runState.GetStateString())
	})
}
336967
func (format *GrokToJSON) Configure(conf core.PluginConfigReader) {
	grokParser, err := grok.New(grok.Config{
		RemoveEmptyValues:   conf.GetBool("RemoveEmptyValues", true),
		NamedCapturesOnly:   conf.GetBool("NamedCapturesOnly", true),
		SkipDefaultPatterns: conf.GetBool("SkipDefaultPatterns", false),
	})
	if err != nil {
		conf.Errors.Push(err)
	}

	//format.grok = grok
	patterns := conf.GetStringArray("Patterns", []string{})
	for _, p := range patterns {
		exp, err := grokParser.Compile(p)
		if err != nil {
			conf.Errors.Push(err)
		}
		format.exp = append(format.exp, exp)
	}
}
751245
func (writer *influxDBWriter10) configure(conf core.PluginConfigReader, 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 = tio.NewByteStream(4096)
	writer.connectionUp = false
	writer.timeBasedDBName = conf.GetBool("TimeBasedName", true)
	writer.Control = prod.Control
	writer.logger = prod.Logger

	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 = '?'

	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 = '&'
	}

	writer.writeURL = fmt.Sprintf("%s%cprecision=ms", writer.writeURL, writer.separator)
	return conf.Errors.OrNil()
}
190580
func (prod *Console) Configure(conf core.PluginConfigReader) {
	console := conf.GetString("Console", "stdout")

	switch strings.ToLower(console) {
	default:
		fallthrough
	case "stdout":
		prod.console = os.Stdout
	case "stderr":
		prod.console = os.Stderr
	}
}
1002210
func (j *Jim) Configure(logf func(string, ...interface{})) {
	j.logf = logf
	rand.Seed(time.Now().Unix())
}
335921
func (s *Recipes) SetConfigure(v []*string) *Recipes {
	s.Configure = v
	return s
}
363052
func (cons *AwsKinesis) Configure(conf core.PluginConfigReader) {
	cons.offsets = make(map[string]string)
	cons.offsetsGuard = new(sync.RWMutex)

	// Offset
	offsetValue := strings.ToLower(conf.GetString("DefaultOffset", kinesisOffsetNewest))
	switch offsetValue {
	case kinesisOffsetNewest:
		cons.offsetType = kinesis.ShardIteratorTypeLatest
		cons.defaultOffset = ""

	case kinesisOffsetOldest:
		cons.offsetType = kinesis.ShardIteratorTypeTrimHorizon
		cons.defaultOffset = ""

	default:
		cons.offsetType = kinesis.ShardIteratorTypeAtSequenceNumber
		_, err := strconv.ParseUint(offsetValue, 10, 64)
		if err != nil {
			cons.Logger.Errorf("Default offset must be \"%s\", \"%s\" or a number. %s given", kinesisOffsetNewest, kinesisOffsetOldest, offsetValue)
			offsetValue = "0"
		}
		cons.defaultOffset = offsetValue
	}

	if cons.offsetFile != "" {
		fileContents, err := ioutil.ReadFile(cons.offsetFile)
		if err != nil {
			cons.Logger.Errorf("Failed to open kinesis offset file: %s", err.Error())
		} else {
			cons.offsetType = kinesis.ShardIteratorTypeAfterSequenceNumber
			conf.Errors.Push(json.Unmarshal(fileContents, &cons.offsets))
		}
	}
}
455563
func (prod *BatchedProducer) Configure(conf PluginConfigReader) {
	prod.SetStopCallback(prod.DefaultClose)

	prod.batchFlushCount = tmath.MinI(prod.batchFlushCount, prod.batchMaxCount)
	prod.Batch = NewMessageBatch(prod.batchMaxCount)
}
515966
func (p *Provider) Configure(providers.ConfigureRequest) providers.ConfigureResponse {
	// At this moment there is nothing to configure for the terraform provider,
	// so we will happily return without taking any action
	var res providers.ConfigureResponse
	return res
}
886523
func (format *ProcessJSON) Configure(conf core.PluginConfigReader) {
	directives := conf.GetStringArray("Directives", []string{})
	format.directives = make([]transformDirective, 0, len(directives))
	geoIPFile := conf.GetString("GeoIPFile", "")

	if geoIPFile != "" {
		var err error
		format.db, err = geoip2.Open(geoIPFile)
		conf.Errors.Push(err)
	}

	if len(directives) > 0 {
		format.directives = make([]transformDirective, 0, len(directives))
		for _, d := range directives {
			directive := strings.Replace(d, "\\:", "\r", -1)
			parts := strings.Split(directive, ":")
			for i, value := range parts {
				parts[i] = strings.Replace(value, "\r", ":", -1)
			}

			if len(parts) >= 2 {
				newDirective := transformDirective{
					key:       parts[0],
					operation: strings.ToLower(parts[1]),
				}

				for i := 2; i < len(parts); i++ {
					newDirective.parameters = append(newDirective.parameters, tstrings.Unescape(parts[i]))
				}

				format.directives = append(format.directives, newDirective)
			}
		}
	}
}
1228799
func (format *TemplateJSON) Configure(conf core.PluginConfigReader) {
	var err error
	tpl := conf.GetString("Template", "")
	format.template, err = template.New("Template").Parse(tpl)
	conf.Errors.Push(err)
}
755893
func Configure(cmds map[string]CommandConfig) {
	for k, v := range cmds {
		ConfigureCommand(k, v)
	}
}
555952
func (filter *Stream) Configure(conf core.PluginConfigReader) {
	filter.blacklist = conf.GetStreamArray("Block", []core.MessageStreamID{})
	filter.whitelist = conf.GetStreamArray("Only", []core.MessageStreamID{})
}