// New returns a new Discovery given a URL, heartbeat and ttl settings.
// Returns an error if the URL scheme is not supported.
976025
func New(rawurl string, heartbeat time.Duration, ttl time.Duration, clusterOpts map[string]string) (Backend, error) {
	scheme, uri := parse(rawurl)
	if backend, exists := backends[scheme]; exists {
		logrus.WithFields(logrus.Fields{"name": scheme, "uri": uri}).Debugf("Initializing discovery service")
		err := backend.Initialize(uri, heartbeat, ttl, clusterOpts)
		return backend, err
	}

	return nil, ErrNotSupported
}
96123
func New(id, location string, interval time.Duration, pool *redis.Pool) *Heartbeater {
	h := &Heartbeater{
		ID:       id,
		Location: location,
		interval: interval,
		pool:     pool,
	}
	h.Strategy = HashExpireyStrategy{h.MaxAge()}

	return h
}
1107399
func New(r registry.Registry, opts ...Option) Cache {
	rand.Seed(time.Now().UnixNano())
	options := Options{
		TTL: DefaultTTL,
	}

	for _, o := range opts {
		o(&options)
	}

	return &cache{
		Registry: r,
		opts:     options,
		watched:  make(map[string]bool),
		cache:    make(map[string][]*registry.Service),
		ttls:     make(map[string]time.Time),
		exit:     make(chan bool),
	}
}
1189058
func New(host, basePath string, schemes []string) *Runtime {
	var rt Runtime
	rt.DefaultMediaType = runtime.JSONMime

	// TODO: actually infer this stuff from the spec
	rt.Consumers = map[string]runtime.Consumer{
		runtime.JSONMime:    runtime.JSONConsumer(),
		runtime.XMLMime:     runtime.XMLConsumer(),
		runtime.TextMime:    runtime.TextConsumer(),
		runtime.HTMLMime:    runtime.TextConsumer(),
		runtime.CSVMime:     runtime.CSVConsumer(),
		runtime.DefaultMime: runtime.ByteStreamConsumer(),
	}
	rt.Producers = map[string]runtime.Producer{
		runtime.JSONMime:    runtime.JSONProducer(),
		runtime.XMLMime:     runtime.XMLProducer(),
		runtime.TextMime:    runtime.TextProducer(),
		runtime.HTMLMime:    runtime.TextProducer(),
		runtime.CSVMime:     runtime.CSVProducer(),
		runtime.DefaultMime: runtime.ByteStreamProducer(),
	}
	rt.Transport = http.DefaultTransport
	rt.Jar = nil
	rt.Host = host
	rt.BasePath = basePath
	rt.Context = context.Background()
	rt.clientOnce = new(sync.Once)
	if !strings.HasPrefix(rt.BasePath, "/") {
		rt.BasePath = "/" + rt.BasePath
	}

	rt.Debug = logger.DebugEnabled()
	rt.logger = logger.StandardLogger{}

	if len(schemes) > 0 {
		rt.schemes = schemes
	}
	return &rt
}
471125
func New(sendErrorCallback func(ehttp.ResponseWriter, *http.Request, error), errorContentType string, recoverPanic bool, logger *log.Logger) *Router {
	return &Router{
		Router:       httprouter.New(),
		mux:          ehttp.NewServeMux(sendErrorCallback, errorContentType, recoverPanic, logger),
		recoverPanic: recoverPanic,
	}
}
109813
func New(path string, mapping mapping.IndexMapping) (Index, error) {
	return newIndexUsing(path, mapping, Config.DefaultIndexType, Config.DefaultKVStore, nil)
}
256734
func New(manager *plugins.Manager, opts ...func(*Discovery)) (*Discovery, error) {

	result := &Discovery{
		manager: manager,
	}

	for _, f := range opts {
		f(result)
	}

	config, err := ParseConfig(manager.Config.Discovery, manager.Services())

	if err != nil {
		return nil, err
	} else if config == nil {
		if _, err := getPluginSet(result.factories, manager, manager.Config); err != nil {
			return nil, err
		}
		return result, nil
	}

	if manager.Config.PluginsEnabled() {
		return nil, fmt.Errorf("plugins cannot be specified in the bootstrap configuration when discovery enabled")
	}

	result.config = config
	result.downloader = download.New(config.Config, manager.Client(config.service), config.path).WithCallback(result.oneShot)
	result.status = &bundle.Status{
		Name: *config.Name,
	}

	return result, nil
}
612416
func (c *InfluxClient) New(src chronograf.Source, logger chronograf.Logger) (chronograf.TimeSeries, error) {
	client := &influx.Client{
		Logger: logger,
	}
	if err := client.Connect(context.TODO(), &src); err != nil {
		return nil, err
	}
	if src.Type == chronograf.InfluxEnterprise && src.MetaURL != "" {
		tls := strings.Contains(src.MetaURL, "https")
		insecure := src.InsecureSkipVerify
		return enterprise.NewClientWithTimeSeries(logger, src.MetaURL, influx.DefaultAuthorization(&src), tls, insecure, client)
	}
	return client, nil
}
1346664
func New(url string, client *http.Client) *Firebase {
	fb := &Firebase{
		url:            sanitizeURL(url),
		params:         _url.Values{},
		clientTimeout:  TimeoutDuration,
		stopWatching:   make(chan struct{}),
		watchHeartbeat: defaultHeartbeat,
		eventFuncs:     map[string]chan struct{}{},
	}
	if client == nil {
		var tr *http.Transport
		tr = &http.Transport{
			Dial: func(network, address string) (net.Conn, error) {
				start := time.Now()
				c, err := net.DialTimeout(network, address, fb.clientTimeout)
				tr.ResponseHeaderTimeout = fb.clientTimeout - time.Since(start)
				return c, err
			},
		}

		client = &http.Client{
			Transport:     tr,
			CheckRedirect: redirectPreserveHeaders,
		}
	}

	fb.client = client
	return fb
}
1176710
func New(ctx context.Context, next http.Handler, config config.Retry, listener Listener, name string) (http.Handler, error) {
	logger := middlewares.GetLogger(ctx, name, typeName)
	logger.Debug("Creating middleware")

	if config.Attempts <= 0 {
		return nil, fmt.Errorf("incorrect (or empty) value for attempt (%d)", config.Attempts)
	}

	return &retry{
		attempts: config.Attempts,
		next:     next,
		listener: listener,
		name:     name,
	}, nil
}
1272297
func New(config *localconfig.TopLevel, metricsProvider metrics.Provider, healthChecker healthChecker, migCtrl migration.Controller) (consensus.Consenter, *Metrics) {
	if config.Kafka.Verbose {
		logging.SetLevel(logging.DEBUG, "orderer.consensus.kafka.sarama")
	}

	brokerConfig := newBrokerConfig(
		config.Kafka.TLS,
		config.Kafka.SASLPlain,
		config.Kafka.Retry,
		config.Kafka.Version,
		defaultPartition)

	bootFile := ""
	if config.General.GenesisMethod == "file" {
		bootFile = config.General.GenesisFile
	}

	return &consenterImpl{
		brokerConfigVal: brokerConfig,
		tlsConfigVal:    config.Kafka.TLS,
		retryOptionsVal: config.Kafka.Retry,
		kafkaVersionVal: config.Kafka.Version,
		topicDetailVal: &sarama.TopicDetail{
			NumPartitions:     1,
			ReplicationFactor: config.Kafka.Topic.ReplicationFactor,
		},
		healthChecker:     healthChecker,
		migController:     migCtrl,
		bootstrapFileName: bootFile,
	}, NewMetrics(metricsProvider, brokerConfig.MetricRegistry)
}
1366377
func New(path string) (*Framework, error) {
	conf, err := config.NewConfig(path)
	if err != nil {
		return nil, err
	}

	return NewWithConfig(conf)
}
340129
func New(global interface{}, localPath string, flag interface{}) (_ interface{}, err error) {
	// Local config
	if localPath != "" {
		if _, err = toml.DecodeFile(localPath, global); err != nil {
			err = errors.Wrapf(err, "asticonfig: toml decoding %s failed", localPath)
			return
		}
	}

	// Merge configs
	if err = mergo.Merge(flag, global); err != nil {
		err = errors.Wrap(err, "asticonfig: merging configs failed")
		return
	}
	return flag, nil
}
510771
func New(u *url.URL, settings []vim.BaseOptionValue) (string, http.Handler) {
	s := &handler{
		ServeMux:    http.NewServeMux(),
		URL:         *u,
		Category:    make(map[string]*tags.Category),
		Tag:         make(map[string]*tags.Tag),
		Association: make(map[string]map[internal.AssociatedObject]bool),
		Session:     make(map[string]*session),
		Library:     make(map[string]content),
		Update:      make(map[string]update),
	}

	handlers := []struct {
		p string
		m http.HandlerFunc
	}{
		{internal.SessionPath, s.session},
		{internal.CategoryPath, s.category},
		{internal.CategoryPath + "/", s.categoryID},
		{internal.TagPath, s.tag},
		{internal.TagPath + "/", s.tagID},
		{internal.AssociationPath, s.association},
		{internal.AssociationPath + "/", s.associationID},
		{internal.LibraryPath, s.library},
		{internal.LocalLibraryPath, s.library},
		{internal.LibraryPath + "/", s.libraryID},
		{internal.LocalLibraryPath + "/", s.libraryID},
		{internal.LibraryItemPath, s.libraryItem},
		{internal.LibraryItemPath + "/", s.libraryItemID},
		{internal.LibraryItemUpdateSession, s.libraryItemUpdateSession},
		{internal.LibraryItemUpdateSession + "/", s.libraryItemUpdateSessionID},
		{internal.LibraryItemUpdateSessionFile, s.libraryItemUpdateSessionFile},
		{internal.LibraryItemUpdateSessionFile + "/", s.libraryItemUpdateSessionFileID},
		{internal.LibraryItemAdd + "/", s.libraryItemAdd},
		{internal.LibraryItemFilePath, s.libraryItemFile},
		{internal.LibraryItemFilePath + "/", s.libraryItemFileID},
		{internal.VCenterOVFLibraryItem + "/", s.libraryItemDeployID},
	}

	for i := range handlers {
		h := handlers[i]
		s.HandleFunc(internal.Path+h.p, func(w http.ResponseWriter, r *http.Request) {
			s.Lock()
			defer s.Unlock()

			if !s.isAuthorized(r) {
				w.WriteHeader(http.StatusUnauthorized)
				return
			}

			h.m(w, r)
		})
	}

	return internal.Path + "/", s
}
384622
func (factory *RSSBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := RSSBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
738424
func New(params *stripe.LoginLinkParams) (*stripe.LoginLink, error) {
	return getC().New(params)
}
240976
func New(priority Priority, prefix string) (w *Writer, err error) {
	return Dial("", "", priority, prefix)
}