// NewCircuitBreakerOptions returns a new CircuitBreakerOption
540593
func createCircuitBreakerOptions(expression string) cbreaker.CircuitBreakerOption {
	return cbreaker.Fallback(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
		tracing.SetErrorWithEvent(req, "blocked by circuit-breaker (%q)", expression)
		rw.WriteHeader(http.StatusServiceUnavailable)

		if _, err := rw.Write([]byte(http.StatusText(http.StatusServiceUnavailable))); err != nil {
			log.FromContext(req.Context()).Error(err)
		}
	}))
}
1295649
func contribOptionsOverride(opts *generator.GenOpts) {
	switch opts.Template {
	case "stratoscale":
		// Stratoscale template needs to regenerate the configureapi on every run.
		opts.RegenerateConfigureAPI = true
		// It also does not use the main.go
		opts.IncludeMain = false
	}
}
1206673
func (h *WebHook) NewConnectOptions() (runtime.Object, bool, string) {
	return &kapi.PodProxyOptions{}, true, "path"
}
1284816
func NewOptional(it graph.Iterator) *Optional {
	return &Optional{
		uid:   NextUID(),
		subIt: it,
	}
}
908667
func (e *DeviceWrap) SwitchConfigAndActiveDevice(m libkb.MetaContext) (err error) {
	defer m.Trace("DeviceWrap#SetActiveDevice", func() error { return err })()

	if err = e.refreshMe(m); err != nil {
		return err
	}

	salt, err := e.args.Me.GetSalt()
	if err != nil {
		return err
	}
	me := e.args.Me
	// Atomically swap to the new config and active device
	if err := m.SwitchUserNewConfigActiveDevice(me.ToUserVersion(), me.GetNormalizedName(), salt,
		e.deviceID, e.signingKey, e.encryptionKey, e.args.DeviceName); err != nil {
		return err
	}

	// Sync down secrets for future offline login attempts to work.
	// This will largely just download what we just uploaded, but it's
	// easy to do this way.
	_, w := m.ActiveDevice().SyncSecrets(m)
	if w != nil {
		m.Warning("Error sync secrets: %s", w.Error())
	}
	return nil
}
186156
func NewDevice(opts ...Option) (*Device, error) {
	d := &Device{
		rspc:   make(chan msg),
		conns:  make(map[string]*conn),
		chConn: make(chan *conn),
		chars:  make(map[int]*ble.Characteristic),
		base:   1,
	}
	if err := d.Option(opts...); err != nil {
		return nil, err
	}

	d.pm = xpc.XpcConnect("com.apple.blued", d)
	d.cm = xpc.XpcConnect("com.apple.blued", d)

	return d, errors.Wrap(d.Init(), "can't init")
}
79655
func (r *AttachREST) NewConnectOptions() (runtime.Object, bool, string) {
	return &api.PodAttachOptions{}, false, ""
}
382564
func NewCreateOptions(ioStreams genericclioptions.IOStreams) *CreateOptions {
	return &CreateOptions{
		PrintFlags:  genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),
		RecordFlags: genericclioptions.NewRecordFlags(),

		Recorder: genericclioptions.NoopRecorder{},

		IOStreams: ioStreams,
	}
}
1315914
func NewCreateRoleOptions(ioStreams genericclioptions.IOStreams) *CreateRoleOptions {
	return &CreateRoleOptions{
		PrintFlags: genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme),

		IOStreams: ioStreams,
	}
}
261418
func NewOptions() Options {
	logger := log.NewLevelLogger(log.SimpleLogger, log.LevelInfo)
	return &options{
		logger:         logger,
		zap:            zap.L(),
		scope:          tally.NoopScope,
		samplingRate:   defaultSamplingRate,
		reportInterval: defaultReportingInterval,
	}
}
683423
func (c Configuration) NewOptions(scope tally.Scope) Options {
	opts := NewOptions().SetMetricsScope(scope)
	if c.InitialBackoff != 0 {
		opts = opts.SetInitialBackoff(c.InitialBackoff)
	}
	if c.BackoffFactor != 0.0 {
		opts = opts.SetBackoffFactor(c.BackoffFactor)
	}
	if c.MaxBackoff != 0 {
		opts = opts.SetMaxBackoff(c.MaxBackoff)
	}
	if c.MaxRetries != 0 {
		opts = opts.SetMaxRetries(c.MaxRetries)
	}
	if c.Forever != nil {
		opts = opts.SetForever(*c.Forever)
	}
	if c.Jitter != nil {
		opts = opts.SetJitter(*c.Jitter)
	}

	return opts
}
883951
func NewOptions() Options {
	return &options{
		scope:          tally.NoopScope,
		initialBackoff: defaultInitialBackoff,
		backoffFactor:  defaultBackoffFactor,
		maxBackoff:     defaultMaxBackoff,
		maxRetries:     defaultMaxRetries,
		forever:        defaultForever,
		jitter:         defaultJitter,
		rngFn:          rand.Int63n,
	}
}
461659
func WithMaxConnectAttempts(value uint) options.Opt {
	return func(p options.Params) {
		if setter, ok := p.(maxConnectAttemptsSetter); ok {
			setter.SetMaxConnectAttempts(value)
		}
	}
}
1304065
func NewOptions() *Options {
	return &Options{
		config:      new(kubeproxyconfig.KubeProxyConfiguration),
		healthzPort: ports.ProxyHealthzPort,
		metricsPort: ports.ProxyStatusPort,
		scheme:      scheme.Scheme,
		codecs:      scheme.Codecs,
		CleanupIPVS: true,
		errCh:       make(chan error),
	}
}
817880
func NewOptionList(permissibleOptions []string, defaultOptions string) (*OptionList, error) {
	permissible := make(map[string]struct{})
	ol := &OptionList{
		allOptions:  permissibleOptions,
		permissible: permissible,
		typeName:    "OptionList",
	}

	for _, o := range permissibleOptions {
		ol.permissible[o] = struct{}{}
	}

	if err := ol.Set(defaultOptions); err != nil {
		return nil, errwrap.Wrap(errors.New("problem setting defaults"), err)
	}

	return ol, nil
}
928451
func NewHCI(opts ...Option) (*HCI, error) {
	h := &HCI{
		id: -1,

		chCmdPkt:  make(chan *pkt),
		chCmdBufs: make(chan []byte, 8),
		sent:      make(map[int]*pkt),

		evth: map[int]handlerFn{},
		subh: map[int]handlerFn{},

		muConns:      &sync.Mutex{},
		conns:        make(map[uint16]*Conn),
		chMasterConn: make(chan *Conn),
		chSlaveConn:  make(chan *Conn),

		done: make(chan bool),
	}
	h.params.init()
	if err := h.Option(opts...); err != nil {
		return nil, errors.Wrap(err, "can't set options")
	}

	return h, nil
}
1311934
func UserConnectOption(user *url.Userinfo) ConnectOption {
	return func(opts *ConnectOptions) {
		opts.User = user
	}
}