// NewThrottler returns a Throttler that polls agent for credits and uses them to throttle
// the service.
551674
func NewThrottler(service string, options ...Option) *Throttler {
	opts := applyOptions(options...)
	creditManager := newHTTPCreditManagerProxy(opts.hostPort)
	t := &Throttler{
		options:       opts,
		creditManager: creditManager,
		service:       service,
		credits:       make(map[string]float64),
		close:         make(chan struct{}),
	}
	t.stopped.Add(1)
	go t.pollManager()
	return t
}
289564
func NewTokenProvider(opts ...TokenProviderOption) (*TokenProvider, error) {
	provider := new(TokenProvider)
	for _, opt := range opts {
		err := opt(provider)
		if err != nil {
			return nil, err
		}
	}
	return provider, nil
}
954081
func NewTarStreamer(r io.Reader, excludes []ExcludeFunc, keywords []Keyword) Streamer {
	pR, pW := io.Pipe()
	ts := &tarStream{
		pipeReader: pR,
		pipeWriter: pW,
		creator:    dhCreator{DH: &DirectoryHierarchy{}},
		teeReader:  io.TeeReader(r, pW),
		tarReader:  tar.NewReader(pR),
		keywords:   keywords,
		hardlinks:  map[string][]string{},
		excludes:   excludes,
	}

	go ts.readHeaders()
	return ts
}
385062
func NewTracker(timeout time.Duration) *Tracker {
	return &Tracker{
		last:    time.Now(),
		timeout: timeout,
	}
}
198480
func NewTCA() *TCA {

	return &TCA{
		Metric:       "BYTES_IN",
		ThrottleTime: 0,
		Disable:      false,
		Count:        0,
		Status:       false,
		Type:         "ROLLING_AVERAGE",
	}
}
774639
func (t *Transferer) NewTransfer(conf *TransferConfig) (*storagetransfer.TransferJob, error) {
	job, err := conf.Job()
	if err != nil {
		return nil, err
	}

	return t.svc.Create(job).Do()
}
154786
func NewTrackerqueryController(service *goa.Service, db application.DB, scheduler *remoteworkitem.Scheduler, configuration trackerQueryConfiguration, authService auth.AuthService) *TrackerqueryController {
	return &TrackerqueryController{
		Controller:    service.NewController("TrackerqueryController"),
		db:            db,
		scheduler:     scheduler,
		configuration: configuration,
		authService:   authService,
	}
}
828870
func NewToolsSetter(st state.EntityFinder, getCanWrite GetAuthFunc) *ToolsSetter {
	return &ToolsSetter{
		st:          st,
		getCanWrite: getCanWrite,
	}
}
1251099
func NewTrackerController(service *goa.Service, db application.DB, scheduler *remoteworkitem.Scheduler, configuration trackerConfiguration) *TrackerController {
	return &TrackerController{
		Controller:    service.NewController("TrackerController"),
		db:            db,
		scheduler:     scheduler,
		configuration: configuration}
}
1283687
func newTimSorter(arr sort.Interface, maxTempSlots int) *TimSorter {
	return &TimSorter{
		Sorter:       newSorter(arr),
		runEnds:      make([]int, 1+STACKSIZE),
		maxTempSlots: maxTempSlots,
	}
}
456579
func NewTransport(t http.RoundTripper) http.RoundTripper {
	return NewTransportWith(stats.DefaultEngine, t)
}
84150
func defaultTxThrottlerConfig() string {
	// Take throttler.DefaultMaxReplicationLagModuleConfig and override some fields.
	config := throttler.DefaultMaxReplicationLagModuleConfig().Configuration
	// TODO(erez): Make DefaultMaxReplicationLagModuleConfig() return a MaxReplicationLagSec of 10
	// and remove this line.
	config.MaxReplicationLagSec = 10
	return proto.MarshalTextString(&config)
}
1003487
func (t *Throttler) Err() error {
	t.errsMutex.Lock()
	defer t.errsMutex.Unlock()
	if atomic.LoadInt32(&t.errorCount) == 0 {
		return nil
	}
	return multiError(t.errs)
}
1270018
func IsThrottleError(err error) bool {
	if _, ok := err.(ServerErrorThrottle); ok {
		return true
	}
	if quotaErr, ok := err.(ServerErrorOverQuota); ok && quotaErr.Throttled {
		return true
	}
	return false
}
1262871
func NewThriftHandlerFunc(processor TProcessor,
	inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {

	return gz(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Add("Content-Type", "application/x-thrift")

		transport := NewStreamTransport(r.Body, w)
		processor.Process(r.Context(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
	})
}
846169
func NewTimer(sec time.Duration, worker *worker.Worker) (*Timer, error) {
	return &Timer{
		ticker: time.NewTicker(sec * time.Second),
		worker: worker,
	}, nil
}
592953
func (m *MockClock) NewTimer(d time.Duration) Timer {
	t := NewMockTimer(m)
	t.Reset(d)
	return t
}