feat(ratelimit): Define initial ratelimit package and Config

pull/4093/head
Timothy Messier 3 years ago
parent b159080593
commit 0fb77358e5
No known key found for this signature in database
GPG Key ID: EFD2F184F7600572

@ -0,0 +1,30 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package ratelimit
import (
"time"
)
const (
// DefaultLimiterMaxEntries is the default maximum number of quotas that
// can be tracked by the rate limiter.
DefaultLimiterMaxEntries = 16384 // TODO: pick a meaningful default value
)
// Config is used to configure rate limits. Each config is used to specify
// the maximum number of requests that can be made in a time period for the
// corresponding resources and actions.
type Config struct {
Resources []string `hcl:"resources"`
Actions []string `hcl:"actions"`
Per string `hcl:"per"`
Limit int `hcl:"limit"`
PeriodHCL string `hcl:"period"`
Period time.Duration `hcl:"-"`
Unlimited bool `hcl:"unlimited"`
}
// Configs is an ordered set of Config.
type Configs []*Config

@ -0,0 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
// Package ratelimit provides the rate limit configuration and http middleware
// for use by the controller's http API.
package ratelimit
Loading…
Cancel
Save