// Configure initializes this producer with values from a plugin config.
351904
func (prod *Websocket) Configure(conf core.PluginConfigReader) {
	prod.SetStopCallback(prod.close)

	prod.upgrader = websocket.Upgrader{}

	if prod.ignoreOrigin {
		prod.upgrader.CheckOrigin = func(r *http.Request) bool { return prod.ignoreOrigin }
	}
}
685764
func (w *unixConfigure) Configure() error {
	if err := w.ConfigureBasic(); err != nil {
		return err
	}
	if err := w.ConfigureJuju(); err != nil {
		return err
	}
	return w.ConfigureCustomOverrides()
}
1156237
func (s *SwarmingClient) Configure(c context.Context, dir, user string) error {
	// 0755 allows the directory structure to be read and listed by all users.
	// Useful when SSHing fo the instance.
	if err := os.MkdirAll(dir, 0755); err != nil {
		return errors.Annotate(err, "failed to create: %s", dir).Err()
	}
	if err := s.chown(c, dir, user); err != nil {
		return errors.Annotate(err, "failed to chown: %s", dir).Err()
	}
	zip := filepath.Join(dir, "swarming_bot.zip")
	switch _, err := os.Stat(zip); {
	case os.IsNotExist(err):
	case err != nil:
		return errors.Annotate(err, "failed to stat: %s", zip).Err()
	default:
		logging.Infof(c, "already installed: %s", zip)
		return nil
	}
	if err := s.fetch(c, zip, user); err != nil {
		return err
	}
	return s.autostart(c, zip, user)
}
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
	}
}
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)
	}
}
335921
func (s *Recipes) SetConfigure(v []*string) *Recipes {
	s.Configure = v
	return s
}
208429
func (format *SimpleFormatter) Configure(conf PluginConfigReader) {
	format.Logger = conf.GetSubLogger("Formatter")

	applyTo := conf.GetString("ApplyTo", "")
	format.GetAppliedContent = GetAppliedContentGetFunction(applyTo)
	format.SetAppliedContent = GetAppliedContentSetFunction(applyTo)
}
908056
func (router *SimpleRouter) Configure(conf PluginConfigReader) {
	router.id = conf.GetID()
	router.Logger = conf.GetLogger()

	if router.streamID == WildcardStreamID && strings.Index(router.id, GeneratedRouterPrefix) != 0 {
		router.Logger.Info("A wildcard stream configuration only affects the wildcard stream, not all routers")
	}
}
1063412
func (cons *Proxy) Configure(conf core.PluginConfigReader) {
	cons.protocol, cons.address = tnet.ParseAddress(conf.GetString("Address", ":5880"), "tcp")
	if cons.protocol == "udp" {
		conf.Errors.Pushf("UDP is not supported")
	}

	cons.flags = tio.BufferedReaderFlagEverything

	partitioner := strings.ToLower(conf.GetString("Partitioner", "delimiter"))
	switch partitioner {
	case "binary_be":
		cons.flags |= tio.BufferedReaderFlagBigEndian
		fallthrough

	case "binary", "binary_le":
		switch cons.size {
		case 1:
			cons.flags |= tio.BufferedReaderFlagMLE8
		case 2:
			cons.flags |= tio.BufferedReaderFlagMLE16
		case 4:
			cons.flags |= tio.BufferedReaderFlagMLE32
		case 8:
			cons.flags |= tio.BufferedReaderFlagMLE64
		default:
			conf.Errors.Pushf("Size only supports the value 1,2,4 and 8")
		}

	case "fixed":
		cons.flags |= tio.BufferedReaderFlagMLEFixed
		cons.offset = cons.size

	case "ascii":
		cons.flags |= tio.BufferedReaderFlagMLE

	case "delimiter":
		// Nothing to add

	default:
		conf.Errors.Pushf("Unknown partitioner: %s", partitioner)
	}
}
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)
	}
}
766293
func (format *RegExp) Configure(conf core.PluginConfigReader) {
	var err error
	if conf.GetBool("Posix", true) {
		format.expression, err = regexp.CompilePOSIX(conf.GetString("Expression", "(.*)"))
	} else {
		format.expression, err = regexp.Compile(conf.GetString("Expression", "(.*)"))
	}
	conf.Errors.Push(err)
}
1321822
func (cons *SystemdConsumer) Configure(conf core.PluginConfigReader) error {
	var err error
	cons.journal, err = sdjournal.NewJournal()
	if err != nil {
		return err
	}

	if sdUnit := conf.GetString("SystemdUnit", ""); sdUnit != "" {
		err = cons.journal.AddMatch("_SYSTEMD_UNIT=" + sdUnit)
		if err != nil {
			return err
		}
	}

	// Offset
	offsetValue := strings.ToLower(conf.GetString("DefaultOffset", sdOffsetTail))

	if cons.offsetFile != "" {
		fileContents, err := ioutil.ReadFile(cons.offsetFile)
		if err != nil {
			cons.Logger.WithError(err).Error("Error reading offset file")
		}
		if string(fileContents) != "" {
			offsetValue = string(fileContents)
		}
	}

	switch offsetValue {
	case sdOffsetHead:
		if err = cons.journal.SeekHead(); err != nil {
			return err
		}

	case sdOffsetTail:
		if err = cons.journal.SeekTail(); err != nil {
			return err
		}
		// start *after* the newest record
		if _, err = cons.journal.Next(); err != nil {
			return err
		}

	default:
		offset, err := strconv.ParseUint(offsetValue, 10, 64)
		if err != nil {
			return err
		}
		if err = cons.journal.SeekRealtimeUsec(offset); err != nil {
			return err
		}
		// start *after* the specified time
		if _, err = cons.journal.Next(); err != nil {
			return err
		}
	}

	// Register close to the control message handler
	cons.SetStopCallback(cons.close)
	return conf.Errors.OrNil()
}
1091916
func (prod *AwsFirehose) Configure(conf core.PluginConfigReader) {
	prod.lastSendTime = time.Now()
	prod.metricsRegistry = core.NewMetricsRegistryForPlugin(prod)
	prod.metricCount = make(map[string]metrics.Counter)

	if prod.recordMaxMessages < 1 {
		prod.recordMaxMessages = 1
		prod.Logger.Warning("RecordMaxMessages was < 1. Defaulting to 1.")
	}

	if prod.recordMaxMessages > 1 && len(prod.delimiter) == 0 {
		prod.delimiter = []byte("\n")
		prod.Logger.Warning("RecordMessageDelimiter was empty. Defaulting to \"\\n\".")
	}

	prod.streamMap = conf.GetStreamMap("StreamMapping", "default")
	for _, firehoseStreamName := range prod.streamMap {
		counter := metrics.NewCounter()
		prod.metricCount[firehoseStreamName] = counter
		prod.metricsRegistry.Register(firehoseStreamName, counter)
	}
}
63854
func (format *Double) Configure(conf core.PluginConfigReader) {
	format.applyTo = conf.GetString("ApplyTo", "")
}
555952
func (filter *Stream) Configure(conf core.PluginConfigReader) {
	filter.blacklist = conf.GetStreamArray("Block", []core.MessageStreamID{})
	filter.whitelist = conf.GetStreamArray("Only", []core.MessageStreamID{})
}
931784
func (c *Client) Configure(opts ...ClientOption) error {
	if c.Ctx == nil {
		c.Ctx = context.Background()
	}
	c.Options = opts
	for _, opt := range opts {
		err := opt(c)
		if err != nil {
			return err
		}
	}
	// Default decompressor values
	if c.Decompressors == nil {
		c.Decompressors = Decompressors
	}
	// Default detector values
	if c.Detectors == nil {
		c.Detectors = Detectors
	}
	// Default getter values
	if c.Getters == nil {
		c.Getters = Getters
	}

	for _, getter := range c.Getters {
		getter.SetClient(c)
	}
	return nil
}
777728
func (prod *Redis) Configure(conf core.PluginConfigReader) {
	prod.SetStopCallback(prod.close)

	prod.protocol, prod.address = tnet.ParseAddress(conf.GetString("Address", ":6379"), "tcp")

	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: // string
		prod.store = prod.storeString
	}
}