// ConfigureCommand applies settings for a circuit
499733
func ConfigureCommand(name string, config CommandConfig) {
	settingsMutex.Lock()
	defer settingsMutex.Unlock()

	timeout := DefaultTimeout
	if config.Timeout != 0 {
		timeout = config.Timeout
	}

	max := DefaultMaxConcurrent
	if config.MaxConcurrentRequests != 0 {
		max = config.MaxConcurrentRequests
	}

	volume := DefaultVolumeThreshold
	if config.RequestVolumeThreshold != 0 {
		volume = config.RequestVolumeThreshold
	}

	sleep := DefaultSleepWindow
	if config.SleepWindow != 0 {
		sleep = config.SleepWindow
	}

	errorPercent := DefaultErrorPercentThreshold
	if config.ErrorPercentThreshold != 0 {
		errorPercent = config.ErrorPercentThreshold
	}

	circuitSettings[name] = &Settings{
		Timeout:                time.Duration(timeout) * time.Millisecond,
		MaxConcurrentRequests:  max,
		RequestVolumeThreshold: uint64(volume),
		SleepWindow:            time.Duration(sleep) * time.Millisecond,
		ErrorPercentThreshold:  errorPercent,
	}
}
1107378
func (s *SpheroDriver) ConfigureLocator(d LocatorConfig) {
	buf := new(bytes.Buffer)
	binary.Write(buf, binary.BigEndian, d)

	s.packetChannel <- s.craftPacket(buf.Bytes(), 0x02, 0x13)
}
192313
func (t *ProgressEmitter) CommitConfiguration(from, to config.Configuration) bool {
	t.mut.Lock()
	defer t.mut.Unlock()

	switch {
	case t.disabled && to.Options.ProgressUpdateIntervalS >= 0:
		t.disabled = false
		l.Debugln("progress emitter: enabled")
		fallthrough
	case !t.disabled && from.Options.ProgressUpdateIntervalS != to.Options.ProgressUpdateIntervalS:
		t.interval = time.Duration(to.Options.ProgressUpdateIntervalS) * time.Second
		if t.interval < time.Second {
			t.interval = time.Second
		}
		l.Debugln("progress emitter: updated interval", t.interval)
	case !t.disabled && to.Options.ProgressUpdateIntervalS < 0:
		t.clearLocked()
		t.disabled = true
		l.Debugln("progress emitter: disabled")
	}
	t.minBlocks = to.Options.TempIndexMinBlocks

	return true
}
369521
func (router *RoundRobin) Configure(conf core.PluginConfigReader) {
	router.index = 0
	router.indexByStream = make(map[core.MessageStreamID]*int32)
	router.mapInitLock = new(sync.Mutex)
}
697705
func (p *gateway) configure(loadedConfig *config.GatewayConfig) error {
	if loadedConfig == nil {
		return fmt.Errorf("unable to configure gateway with nil config")
	}
	// save config to the gateway
	p.config = loadedConfig

	// set debug context from loaded config
	if loadedConfig.DebugFlag != nil && *loadedConfig.DebugFlag != "" {
		p.debugContext.SetFlagStr(*loadedConfig.DebugFlag)
	}

	// set debugSink ctx flag
	p.debugSink.CtxFlagCheck = &p.debugContext

	// TODO: allow arbitrary logger to be passed into configure function
	// set lumberjack log formatting using a child derived from the default logger
	// this is used as a back up by p.getLogger when we try to create a logger using the loaded config
	p.logger = log.NewContext(log.DefaultLogger.CreateChild()).With(logkey.Time, log.DefaultTimestamp, logkey.Caller, log.DefaultCaller)

	// NOTE: the main reason to do that ^ and apply the keys is so that our log messages look consistent.
	// there is are messages logged by p.getLogger before the keys are applied in the following statement

	// create a new logger using the loaded config
	p.logger = log.NewContext(p.getLogger(loadedConfig)).With(logkey.Time, log.DefaultTimestamp, logkey.Caller, log.DefaultCaller)

	// assign logger to debug sink
	p.debugSink.Logger = p.logger

	// setup logger on versionMetric which reports our SHA1
	p.versionMetric.Logger = p.logger

	return nil
}
854787
func Configuration(c Config) httpcli.ConfigMapOption {
	return func(cm httpcli.ConfigMap) {
		cm[httpcli.AuthIAM] = c
	}
}
639441
func (w *Worker) Configure() error {
	err := pitaya.StartWorker(pitaya.GetConfig())
	if err != nil {
		return err
	}

	pitaya.RegisterRPCJob(&RPCJob{})
	return nil
}
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)
	}
}
705265
func (db *DB) configure(prefix string) {
	// Initialize all the metrics collector at the requested prefix
	db.compTimeMeter = metrics.NewRegisteredMeter(prefix+"compact/time", nil)
	db.compReadMeter = metrics.NewRegisteredMeter(prefix+"compact/input", nil)
	db.compWriteMeter = metrics.NewRegisteredMeter(prefix+"compact/output", nil)
	db.diskReadMeter = metrics.NewRegisteredMeter(prefix+"disk/read", nil)
	db.diskWriteMeter = metrics.NewRegisteredMeter(prefix+"disk/write", nil)
	db.writeDelayMeter = metrics.NewRegisteredMeter(prefix+"compact/writedelay/duration", nil)
	db.writeDelayNMeter = metrics.NewRegisteredMeter(prefix+"compact/writedelay/counter", nil)
}
555952
func (filter *Stream) Configure(conf core.PluginConfigReader) {
	filter.blacklist = conf.GetStreamArray("Block", []core.MessageStreamID{})
	filter.whitelist = conf.GetStreamArray("Only", []core.MessageStreamID{})
}
1236500
func (cons *PcapHTTPConsumer) Configure(conf core.PluginConfigReader) {
	cons.sessions = make(pcapSessionMap)
	cons.sessionGuard = new(sync.Mutex)
}
819736
func Configure() *Configuration {
	return &Configuration{
		buckets:        16,
		itemsToPrune:   500,
		deleteBuffer:   1024,
		getsPerPromote: 3,
		promoteBuffer:  1024,
		maxSize:        5000,
		tracking:       false,
	}
}
39599
func (s *CreateCrawlerInput) SetConfiguration(v string) *CreateCrawlerInput {
	s.Configuration = &v
	return s
}
1199333
func (prod *Socket) Configure(conf core.PluginConfigReader) {
	prod.SetStopCallback(prod.close)

	prod.protocol, prod.address = tnet.ParseAddress(conf.GetString("Address", ":5880"), "tcp")
	prod.batchFlushCount = tmath.MinI(prod.batchFlushCount, prod.batchMaxCount)

	switch prod.protocol {
	case "udp":
		if prod.acknowledge != "" {
			prod.Logger.Warning("Acknowledge is only supported for TCP connections. TCP connection forced.")
			prod.protocol = "tcp"
		}
	case "unix", "tcp":
		// Everything is fine
	default:
		prod.protocol = "tcp"
	}

	prod.batch = core.NewMessageBatch(prod.batchMaxCount)
	prod.assembly = core.NewWriterAssembly(nil, prod.TryFallback, prod)
	prod.assembly.SetValidator(prod.validate)
	prod.assembly.SetErrorHandler(prod.onWriteError)
}
436619
func (format *Identifier) Configure(conf core.PluginConfigReader) {
	idType := strings.ToLower(conf.GetString("Generator", "time"))
	format.seq = new(uint64)

	switch idType {
	case "hash":
		format.hash = format.idHash
	case "seq":
		format.hash = format.idSeq
	case "seqhex":
		format.hash = format.idSeqHex
	case "time":
		format.hash = format.idTime
	default:
		format.hash = func(msg *core.Message) []byte {
			return []byte(idType)
		}
	}
}
1169554
func (router *Distribute) Configure(conf core.PluginConfigReader) {
	router.boundStreamIDs = conf.GetStreamArray("TargetStreams", []core.MessageStreamID{})
}
755893
func Configure(cmds map[string]CommandConfig) {
	for k, v := range cmds {
		ConfigureCommand(k, v)
	}
}