// New returns a new collector based on the File configuration.
507726
func (f File) New() cue.Collector {
	if f.Path == "" {
		log.Warn("File.New called to created a collector, but Path param is empty.  Returning nil collector.")
		return nil
	}
	if f.Formatter == nil {
		f.Formatter = format.HumanReadable
	}
	if f.Flags == 0 {
		f.Flags = os.O_CREATE | os.O_WRONLY | os.O_APPEND
	}
	if f.Perms == 0 {
		f.Perms = 0600
	}

	fc := &fileCollector{File: f}
	fc.watchSignal()
	fc.watchRemoval()
	return fc
}
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)
}
653471
func New(opts *FileKeyValueStoreOptions) (*FileKeyValueStore, error) {
	if opts == nil {
		return nil, errors.New("FileKeyValueStoreOptions is nil")
	}
	if opts.Path == "" {
		return nil, errors.New("FileKeyValueStore path is empty")
	}
	if opts.KeySerializer == nil {
		// Default key serializer
		opts.KeySerializer = func(key interface{}) (string, error) {
			keyString, ok := key.(string)
			if !ok {
				return "", errors.New("converting key to string failed")
			}
			return filepath.Join(opts.Path, keyString), nil
		}
	}
	if opts.Marshaller == nil {
		opts.Marshaller = defaultMarshaller
	}
	if opts.Unmarshaller == nil {
		opts.Unmarshaller = defaultUnmarshaller
	}
	return &FileKeyValueStore{
		path:          opts.Path,
		keySerializer: opts.KeySerializer,
		marshaller:    opts.Marshaller,
		unmarshaller:  opts.Unmarshaller,
	}, nil
}
502638
func (m *mongoStore) New(r *http.Request, name string) (*gSessions.Session, error) {
	session := gSessions.NewSession(m, name)
	session.Options = &gSessions.Options{
		Path:   m.options.Path,
		MaxAge: m.options.MaxAge,
	}
	session.IsNew = true
	var err error
	if cook, errToken := m.Token.GetToken(r, name); errToken == nil {
		err = securecookie.DecodeMulti(name, cook, &session.ID, m.Codecs...)
		if err == nil {
			ok, err := m.load(session)
			session.IsNew = !(err == nil && ok) // not new if no error and data available
		}
	}
	return session, err
}
714000
func New(config Config) *Producer {
	config.defaults()
	return &Producer{
		Config:  config,
		records: make(chan *k.PutRecordsRequestEntry, config.BacklogSize),
		done:    make(chan struct{}),
	}
}
248984
func New(config *Config) *Keystore {
	if config == nil {
		config = defaultConfig
	}
	return &Keystore{config}
}
743417
func New(value interface{}, config ...Config) *CSV {
	csv := &CSV{}

	if f, ok := value.(string); ok {
		csv.filename = f
	} else {
		if r, ok := value.(io.ReadCloser); ok {
			csv.reader = r
		}

		if w, ok := value.(io.WriteCloser); ok {
			csv.writer = w
		}
	}

	for _, cfg := range config {
		csv.config = cfg
	}
	return csv
}
397338
func New(config Config) *Cache {
	return &Cache{
		m:      make(map[Key]*list.Element, config.MaxItems),
		l:      list.New(),
		config: config,
	}
}
563158
func New(c Config) (Monitor, error) {
	m := &monitor{
		tip:            []string{""},
		path:           c.Path,
		scanner:        c.Scanner,
		sorter:         c.Sorter,
	}

	if err := m.sync(); err != nil {
		return nil, err
	}

	return m, nil
}
597436
func New(lockerConfig config.Locker) error {
	var err error
	switch handlerName(lockerConfig.Handler) {
	case zookeeperHandler:
		handler, err = zookeeper.NewLocker(lockerConfig)
		return err
	case redisHandler:
		handler, err = redis.NewLocker(lockerConfig)
		return err
	default:
		handler = memlock.NewLocker()
	}
	return nil
}
926740
func (t Terminal) New() cue.Collector {
	if t.Formatter == nil {
		t.Formatter = format.HumanReadable
	}
	return &terminalCollector{Terminal: t}
}
1002035
func New(config types.Config) (*Potassium, error) {
	return &Potassium{config.Scheduler.MaxShare, config.Scheduler.ShareBase}, nil
}
383116
func New(collectorsetconfig *config.Config, storage storage.Storage) (*Controller, error) {
	// Instantiate the Kubernetes in cluster config.
	restconfig, err := rest.InClusterConfig()
	if err != nil {
		return nil, err
	}

	// Instantiate the CollectorSet client.
	client, collectorsetscheme, err := collectorsetclient.NewForConfig(restconfig)
	if err != nil {
		return nil, err
	}

	// Instantiate the LogicMontitor API client.
	lmClient := newLMClient(collectorsetconfig.ID, collectorsetconfig.Key, collectorsetconfig.Account)

	// start a controller on instances of our custom resource
	c := &Controller{
		Client:             client,
		CollectorSetScheme: collectorsetscheme,
		LogicmonitorClient: lmClient,
		Storage:            storage,
	}

	return c, nil
}
803630
func New(cfg Collector, nodeInfo collectors.NodeInfo, rels *ContainerTaskRels) (Collector, chan producers.MetricsMessage) {
	c := cfg
	c.log = logrus.WithFields(logrus.Fields{"collector": "mesos-agent"})
	c.nodeInfo = nodeInfo
	c.metricsChan = make(chan producers.MetricsMessage)
	c.ContainerTaskRels = rels
	return c, c.metricsChan
}
1360037
func New(client docker.Client, config *api.Config, fs fs.FileSystem, overrides build.Overrides) (*OnBuild, error) {
	dockerHandler := docker.New(client, config.PullAuthentication)
	builder := &OnBuild{
		docker: dockerHandler,
		git:    git.New(fs, cmd.NewCommandRunner()),
		fs:     fs,
		tar:    tar.New(fs),
	}
	// Use STI Prepare() and download the 'run' script optionally.
	s, err := sti.New(client, config, fs, overrides)
	if err != nil {
		return nil, err
	}
	s.SetScripts([]string{}, []string{constants.Assemble, constants.Run})

	downloader := overrides.Downloader
	if downloader == nil {
		downloader, err = scm.DownloaderForSource(builder.fs, config.Source, config.ForceCopy)
		if err != nil {
			return nil, err
		}
	}

	builder.source = onBuildSourceHandler{
		Downloader: downloader,
		Preparer:   s,
		Ignorer:    &ignore.DockerIgnorer{},
	}

	builder.garbage = build.NewDefaultCleaner(builder.fs, builder.docker)
	return builder, nil
}
997054
func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
	return &Client{transport: transport, formats: formats}
}
109813
func New(path string, mapping mapping.IndexMapping) (Index, error) {
	return newIndexUsing(path, mapping, Config.DefaultIndexType, Config.DefaultKVStore, nil)
}