// New returns a new "prefer org" resolver.
180484
func New(dispatcher service.Dispatcher, context context.Client, channelID string, opts ...options.Opt) *PeerResolver {
	params := defaultParams(context, channelID)
	options.Apply(params, opts)

	mspID := context.Identifier().MSPID

	logger.Debugf("Creating new PreferOrg peer resolver with options: MSP ID [%s]", mspID)

	return &PeerResolver{
		params:              params,
		mspID:               mspID,
		blockHeightResolver: minblockheight.New(dispatcher, context, channelID, opts...),
	}
}
821884
func New(config Config) gin.HandlerFunc {
	policy := newPolicy(config)
	return func(c *gin.Context) {
		if !policy.applyToContext(c) {
			return
		}
	}
}
757495
func New(addr string, options ...Option) (*Client, error) {
	o, err := resolveOptions(options)
	if err != nil {
		return nil, err
	}

	var w statsdWriter

	if !strings.HasPrefix(addr, UnixAddressPrefix) {
		w, err = newUDPWriter(addr)
	} else if o.AsyncUDS {
		w, err = newAsyncUdsWriter(addr[len(UnixAddressPrefix)-1:])
	} else {
		w, err = newBlockingUdsWriter(addr[len(UnixAddressPrefix)-1:])
	}
	if err != nil {
		return nil, err
	}
	w.SetWriteTimeout(o.WriteTimeoutUDS)

	c := Client{
		Namespace: o.Namespace,
		Tags:      o.Tags,
		writer:    w,
	}

	// Inject DD_ENTITY_ID as a constant tag if found
	entityID := os.Getenv(entityIDEnvName)
	if entityID != "" {
		entityTag := fmt.Sprintf("%s:%s", entityIDTagName, entityID)
		c.Tags = append(c.Tags, entityTag)
	}

	if o.Buffered {
		c.bufferLength = o.MaxMessagesPerPayload
		c.commands = make([][]byte, 0, o.MaxMessagesPerPayload)
		c.flushTime = time.Millisecond * 100
		c.stop = make(chan struct{}, 1)
		go c.watch()
	}

	return &c, nil
}
1071479
func New(initializer Initializer, opts ...options.Opt) *Reference {
	return NewWithData(func(interface{}) (interface{}, error) {
		return initializer()
	}, opts...)
}
281867
func New(hostResolverConfig *types.HostResolverConfig) *RequestDecorator {
	requestDecorator := &RequestDecorator{}
	if hostResolverConfig != nil {
		requestDecorator.hostResolver = &Resolver{
			CnameFlattening: hostResolverConfig.CnameFlattening,
			ResolvConfig:    hostResolverConfig.ResolvConfig,
			ResolvDepth:     hostResolverConfig.ResolvDepth,
		}
	}
	return requestDecorator
}
74886
func New(ic *plugin.InitContext) (interface{}, error) {
	var ns *metrics.Namespace
	config := ic.Config.(*Config)
	if !config.NoPrometheus {
		ns = metrics.NewNamespace("container", "", nil)
	}
	collector := newCollector(ns)
	oom, err := newOOMCollector(ns)
	if err != nil {
		return nil, err
	}
	if ns != nil {
		metrics.Register(ns)
	}
	ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
	return &cgroupsMonitor{
		collector: collector,
		oom:       oom,
		context:   ic.Context,
		publisher: ic.Events,
	}, nil
}
1187229
func New(dispatcher Dispatcher, opts ...options.Opt) *Service {
	params := defaultParams()
	options.Apply(params, opts)

	return &Service{
		params:     *params,
		dispatcher: dispatcher,
	}
}
1178388
func New(cfg *UtxoSweeperConfig) *UtxoSweeper {

	return &UtxoSweeper{
		cfg:           cfg,
		newInputs:     make(chan *sweepInputMessage),
		spendChan:     make(chan *chainntnfs.SpendDetail),
		quit:          make(chan struct{}),
		pendingInputs: make(map[wire.OutPoint]*pendingInput),
	}
}
675353
func (d DefaultJSONLoaderFactory) New(source string) JSONLoader {
	return &jsonReferenceLoader{
		fs:     osFS,
		source: source,
	}
}
467341
func New(ctx context.Context, cfg *config.Config, sv semver.Version) (*Action, error) {
	return newAction(ctx, cfg, sv)
}
240976
func New(priority Priority, prefix string) (w *Writer, err error) {
	return Dial("", "", priority, prefix)
}
288187
func New(address, facility string, extra map[string]interface{}, level logrus.Level) (logrus.Hook, error) {
	w, err := gelf.NewWriter(address)
	if err != nil {
		return nil, err
	}

	hostname, err := hostname()
	if err != nil {
		return nil, err
	}

	return &Hook{
		levels:   levelThreshold(level),
		w:        w,
		hostname: hostname,
		facility: facility,
		extra:    extra,
	}, err
}
565946
func New(cfg engine.Frontend, be *backend.T, opts proxy.Options,
	mwCfgs map[engine.MiddlewareKey]engine.Middleware,
	listeners plugin.FrontendListeners,
) *T {
	if mwCfgs == nil {
		mwCfgs = make(map[engine.MiddlewareKey]engine.Middleware)
	}
	fe := T{
		cfg:       cfg,
		trustXFDH: opts.TrustForwardHeader,
		mwCfgs:    mwCfgs,
		backend:   be,
		listeners: listeners,
	}
	return &fe
}
945535
func (s *Scheme) New(kind unversioned.GroupVersionKind) (Object, error) {
	obj, err := s.raw.NewObject(kind)
	if err != nil {
		return nil, err
	}
	return obj.(Object), nil
}
1171490
func New(
	ctx context.Context,
	limit Limit,
	burst int,
	options ...interface{},
) (limiter *BucketRateLimiter) {
	ctx, cancel := context.WithCancel(ctx)
	cleanTimeout := time.Minute
	tickerInterval := time.Minute

	for _, option := range options {
		switch opt := option.(type) {
		case OptionCleanTimeout:
			cleanTimeout = time.Duration(opt)
		case OptionCleanTicker:
			tickerInterval = time.Duration(opt)
		}
	}

	egCleaner, _ := errgroup.WithContext(ctx)
	limiter = &BucketRateLimiter{
		ctx:            ctx,
		cancel:         cancel,
		limit:          limit,
		burst:          burst,
		cleanTimeout:   cleanTimeout,
		tickerInterval: tickerInterval,

		buckets:   map[string]*limiterWrap{},
		egCleaner: egCleaner,
		mutex:     sync.Mutex{},
	}
	egCleaner.Go(limiter.cleanerLoop)
	return
}
1170251
func New(c *clientv3.Client, codec runtime.Codec, prefix string, transformer value.Transformer, pagingEnabled bool) storage.Interface {
	return newStore(c, pagingEnabled, codec, prefix, transformer)
}
1040444
func New(opts ...Option) (*Client, error) {
	var err error

	c := &Client{
		logf: func(string, ...interface{}) {},
	}

	// apply opts
	for _, o := range opts {
		err = o(c)
		if err != nil {
			return nil, err
		}
	}

	// ensure errf is set
	if c.errf == nil {
		c.errf = func(s string, v ...interface{}) {
			c.logf("ERROR: "+s, v...)
		}
	}

	if c.domain == "" || c.client == nil {
		return nil, errors.New("godop missing domain or godo client")
	}

	return c, nil
}