// New returns a Cache implementation.
// It automatically starts a go routine that manages expiration of assumed pods.
// "ttl" is how long the assumed pod will get expired.
// "stop" is the channel that would close the background goroutine.
436368
func New(ttl time.Duration, stop <-chan struct{}) Cache {
	cache := newSchedulerCache(ttl, cleanAssumedPeriod, stop)
	cache.run()
	return cache
}
397227
func New(storeSize int64, dataStore tusd.DataStore, terminater tusd.TerminaterDataStore) *LimitedStore {
	return &LimitedStore{
		StoreSize:  storeSize,
		DataStore:  dataStore,
		terminater: terminater,
		uploads:    make(map[string]int64),
		mutex:      new(sync.Mutex),
	}
}
341506
func New(w io.Writer, bufferSize int64) io.WriteCloser {
	buf, _ := circbuf.NewBuffer(bufferSize)
	c := &circbufWriter{
		buf:     buf,
		wr:      w,
		flushCh: make(chan struct{}, 1),
	}
	go c.flushLoop()
	return c
}
896483
func New(client client.APIClient, noResolve bool) *IDResolver {
	return &IDResolver{
		client:    client,
		noResolve: noResolve,
		cache:     make(map[string]string),
	}
}
177915
func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ManagerSerfCluster, connPoolPinger Pinger) (m *Manager) {
	m = new(Manager)
	m.logger = logger
	m.clusterInfo = clusterInfo       // can't pass *consul.Client: import cycle
	m.connPoolPinger = connPoolPinger // can't pass *consul.ConnPool: import cycle
	m.rebalanceTimer = time.NewTimer(clientRPCMinReuseDuration)
	m.shutdownCh = shutdownCh
	atomic.StoreInt32(&m.offline, 1)

	l := serverList{}
	l.servers = make([]*metadata.Server, 0)
	m.saveServerList(l)
	return m
}
1175107
func (l *Logger) New(ctx *gear.Context) (interface{}, error) {
	log := Log{}
	l.init(log, ctx)
	return log, nil
}
666186
func New(defaultConfPath, liveConfPath string, portChecker checker) *Resetter {
	return &Resetter{
		defaultConfPath: defaultConfPath,
		liveConfPath:    liveConfPath,
		portChecker:     portChecker,
		timeout:         time.Second * 30,
		Monit:           monit.New(),
		redis:           redis.New(),
	}
}
9449
func New(s store.Store, ctx context.Context) (watcher.Watcher, error) {
	ret := &ContainerWatcher{
		invertsTable: make(map[string]string),
	}
	base, err := watcher.New(s, ctx, KEY, ret.convert, ret.invertKey)
	if err != nil {
		return nil, err
	}
	ret.BaseWatcher = *base
	return ret, nil
}
164987
func New(interval time.Duration) (*Batcher, error) {
	watcher, err := fsnotify.NewWatcher()

	batcher := &Batcher{}
	batcher.Watcher = watcher
	batcher.interval = interval
	batcher.done = make(chan struct{}, 1)
	batcher.Events = make(chan []fsnotify.Event, 1)

	if err == nil {
		go batcher.run()
	}

	return batcher, err
}
94592
func (a Algorithm) New() Digester {
	return &digester{
		alg:  a,
		hash: a.Hash(),
	}
}
728827
func New() *Cache {
	return &Cache{
		Zones:      []string{"."},
		pcap:       defaultCap,
		pcache:     cache.New(defaultCap),
		pttl:       maxTTL,
		minpttl:    minTTL,
		ncap:       defaultCap,
		ncache:     cache.New(defaultCap),
		nttl:       maxNTTL,
		minnttl:    minNTTL,
		prefetch:   0,
		duration:   1 * time.Minute,
		percentage: 10,
		now:        time.Now,
	}
}
240976
func New(priority Priority, prefix string) (w *Writer, err error) {
	return Dial("", "", priority, prefix)
}
1312876
func New(completer Completer, timeout time.Duration) *Future {
	f := &Future{}
	f.wg.Add(1)
	var wg sync.WaitGroup
	wg.Add(1)
	go listenForResult(f, completer, timeout, &wg)
	wg.Wait()
	return f
}
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
}
172227
func New() Definition {
	var q Definition
	q.Where = make(map[string]interface{})
	q.Sort = make(map[string]interface{})
	return q
}
1063332
func New(permits int) *Semaphore {
	if permits < 1 {
		panic("Invalid number of permits. Less than 1")
	}

	// fill channel buffer
	channel := make(chan struct{}, permits)
	for i := 0; i < permits; i++ {
		channel <- struct{}{}
	}

	return &Semaphore{
		permits: permits,
		avail:   permits,
		channel: channel,
	}
}
6130
func New(lsnCfg engine.Listener, router http.Handler, stapler stapler.Stapler,
	connTck conntracker.ConnectionTracker, autoCertCache autocert.Cache, wg *sync.WaitGroup,
) (*T, error) {
	scopedRouter, err := newScopeRouter(lsnCfg.Scope, router)
	if err != nil {
		return nil, err
	}
	return &T{
		lsnCfg: lsnCfg,
		router: router,

		stapler:       stapler,
		connTck:       connTck,
		autoCertCache: autoCertCache,
		serveWg:       wg,
		scopedRouter:  scopedRouter,
		state:         srvStateInit,
	}, nil
}