diff --git a/internal/ratelimit/config.go b/internal/ratelimit/config.go new file mode 100644 index 0000000000..97c5207082 --- /dev/null +++ b/internal/ratelimit/config.go @@ -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 diff --git a/internal/ratelimit/doc.go b/internal/ratelimit/doc.go new file mode 100644 index 0000000000..129b14b66b --- /dev/null +++ b/internal/ratelimit/doc.go @@ -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