// New constructs a `TokenLimiter` middleware instance.
547653
func New(next http.Handler, extract utils.SourceExtractor, defaultRates *RateSet, opts ...TokenLimiterOption) (*TokenLimiter, error) {
	if defaultRates == nil || len(defaultRates.m) == 0 {
		return nil, fmt.Errorf("provide default rates")
	}
	if extract == nil {
		return nil, fmt.Errorf("provide extract function")
	}
	tl := &TokenLimiter{
		next:         next,
		defaultRates: defaultRates,
		extract:      extract,

		log: log.StandardLogger(),
	}

	for _, o := range opts {
		if err := o(tl); err != nil {
			return nil, err
		}
	}
	setDefaults(tl)
	bucketSets, err := ttlmap.NewMapWithProvider(tl.capacity, tl.clock)
	if err != nil {
		return nil, err
	}
	tl.bucketSets = bucketSets
	return tl, nil
}
163885
func New(config *Config, authorizer Authorizer) (*NodeAuthorizer, error) {
	utils.Logger.Info("starting the node authorization service",
		zap.String("listen", config.Listen),
		zap.String("version", Version))

	if authorizer == nil {
		return nil, errors.New("no authorizer")
	}

	if err := config.IsValid(); err != nil {
		return nil, fmt.Errorf("configuration error: %s", err)
	}

	return &NodeAuthorizer{
		authorizer: authorizer,
		config:     config,
	}, nil
}
866190
func New(authToken string, expr string,
	callback func(searchResults string),
	cleanup func()) *js.Object {
	if err := checkZoomExpr(expr); err != nil {
		dom.GetWindow().Alert(fmt.Sprintf("%v", err))
		return nil
	}
	expr = ShiftZoomPredicate(expr)
	return js.MakeWrapper(&Query{
		AuthToken: authToken,
		Expr:      expr,
		Callback:  callback,
		Cleanup:   cleanup,
		Limit:     50,
	})
}
1019917
func New(claims map[string]interface{}) (string, error) {
	enc, err := newEncoded(claims)
	if err != nil {
		return "", err
	}

	return enc.token, nil
}
694639
func New(ctx context.Context, next http.Handler, config config.ErrorPage, serviceBuilder serviceBuilder, name string) (http.Handler, error) {
	middlewares.GetLogger(ctx, name, typeName).Debug("Creating middleware")

	httpCodeRanges, err := types.NewHTTPCodeRanges(config.Status)
	if err != nil {
		return nil, err
	}

	backend, err := serviceBuilder.BuildHTTP(ctx, config.Service, nil)
	if err != nil {
		return nil, err
	}

	return &customErrors{
		name:           name,
		next:           next,
		backendHandler: backend,
		httpCodeRanges: httpCodeRanges,
		backendQuery:   config.Query,
	}, nil
}
782686
func New(ctx context.Context, next http.Handler, name string) (http.Handler, error) {
	middlewares.GetLogger(ctx, name, typeName).Debug("Creating middleware")

	return &compress{
		next: next,
		name: name,
	}, nil
}
12451
func New(params *stripe.TokenParams) (*stripe.Token, error) {
	return getC().New(params)
}
137908
func New(maxSize int) blockledger.Factory {
	rlf := &ramLedgerFactory{
		maxSize: maxSize,
		ledgers: make(map[string]blockledger.ReadWriter),
	}

	return rlf
}
1059450
func New(cfg Collector, nodeInfo collectors.NodeInfo, ctr *mesosAgent.ContainerTaskRels) (Collector, chan producers.MetricsMessage) {
	c := cfg
	c.nodeInfo = nodeInfo
	c.metricsChan = make(chan producers.MetricsMessage)
	c.containerTaskRels = ctr
	return c, c.metricsChan
}
1304539
func New(ctx context.Context, next http.Handler, confCircuitBreaker config.CircuitBreaker, name string) (http.Handler, error) {
	expression := confCircuitBreaker.Expression

	logger := middlewares.GetLogger(ctx, name, typeName)
	logger.Debug("Creating middleware")
	logger.Debug("Setting up with expression: %s", expression)

	oxyCircuitBreaker, err := cbreaker.New(next, expression, createCircuitBreakerOptions(expression))
	if err != nil {
		return nil, err
	}
	return &circuitBreaker{
		circuitBreaker: oxyCircuitBreaker,
		name:           name,
	}, nil
}
486190
func New(limit int, interval time.Duration) *RateLimiter {
	lim := &RateLimiter{
		limit:    limit,
		interval: interval,
	}
	lim.times.Init()
	return lim
}
1367192
func New(token string, options ...Option) *Client {
	slackURL := DefaultAPIEndpoint
	httpcl := http.DefaultClient
	debug, _ := strconv.ParseBool(os.Getenv("SLACK_DEBUG"))
	var logger Logger = nilLogger{}
	for _, o := range options {
		switch o.Name() {
		case httpclkey:
			httpcl = o.Value().(*http.Client)
		case debugkey:
			debug = o.Value().(bool)
		case loggerkey:
			logger = o.Value().(Logger)
		case slackurlkey:
			slackURL = o.Value().(string)
		}
	}

	if !strings.HasSuffix(slackURL, "/") {
		slackURL = slackURL + "/"
	}

	if _, ok := logger.(nilLogger); debug && ok {
		logger = traceLogger{dst: os.Stderr}
	}

	wrappedcl := &httpClient{
		client:   httpcl,
		debug:    debug,
		slackURL: slackURL,
		logger:   logger,
	}
	return &Client{
		auth:            &AuthService{client: wrappedcl, token: token},
		bots:            &BotsService{client: wrappedcl, token: token},
		channels:        &ChannelsService{client: wrappedcl, token: token},
		chat:            &ChatService{client: wrappedcl, token: token},
		dialog:          &DialogService{client: wrappedcl, token: token},
		emoji:           &EmojiService{client: wrappedcl, token: token},
		groups:          &GroupsService{client: wrappedcl, token: token},
		oauth:           &OAuthService{client: wrappedcl},
		reminders:       &RemindersService{client: wrappedcl, token: token},
		reactions:       &ReactionsService{client: wrappedcl, token: token},
		rtm:             &RTMService{client: wrappedcl, token: token},
		users:           &UsersService{client: wrappedcl, token: token},
		usersProfile:    &UsersProfileService{client: wrappedcl, token: token},
		usergroups:      &UsergroupsService{client: wrappedcl, token: token},
		usergroupsUsers: &UsergroupsUsersService{client: wrappedcl, token: token},
		debug:           debug,
	}
}
970408
func New(authToken, parentDir string, limit int,
	updadeSearchSession func(string), triggerRender func()) *js.Object {
	parentDirbr, ok := blob.Parse(parentDir)
	if !ok {
		dom.GetWindow().Alert(fmt.Sprintf("invalid parentDir blobRef: %q", parentDir))
		return nil
	}
	return js.MakeWrapper(&Query{
		ParentDir:           parentDirbr,
		AuthToken:           authToken,
		UpdateSearchSession: updadeSearchSession,
		TriggerRender:       triggerRender,
		Limit:               limit,
	})
}
873019
func New(token string, url string) *API {
	api := new(API)
	api.Endpoint = url
	api.Client = newRestClient(token)
	return api
}
362100
func (r Rollbar) New() cue.Collector {
	if r.Token == "" || r.Environment == "" {
		log.Warn("Rollbar.New called to created a collector, but Token or Environment param is empty.  Returning nil collector.")
		return nil
	}
	return &rollbarCollector{
		Rollbar: r,
		http:    collector.HTTP{RequestFormatter: r.formatRequest}.New(),
	}
}
55482
func New(token string) *Client {
	c := &Client{}
	c.Token = token

	c.Keys = &KeyResource{c}
	c.Repos = &RepoResource{c}
	c.Users = &UserResource{c}
	c.Orgs = &OrgResource{c}
	c.Emails = &EmailResource{c}
	c.Hooks = &HookResource{c}
	c.Contents = &ContentResource{c}
	c.RepoKeys = &RepoKeyResource{c}
	c.ApiUrl = "https://api.github.com"
	return c
}
174713
func New(mws ...Middleware) *Router {
	r := &Router{
		parent:           nil,
		hostrm:           newHostMatcher(),
		middlewares:      Middlewares{},
		namedMiddlewares: make(map[string]Middlewares),
		pool:             newCtxPool(),
	}
	r.Use(mws...)
	r.Configure(
		WithLogger(lionLogger),
		WithServer(&http.Server{
			ReadTimeout:  5 * time.Second,
			WriteTimeout: 10 * time.Second,
		}),
	)
	return r
}