fix rate limiting mapping to be the same between api and struct packages (#17599)

This commit is contained in:
Dhia Ayachi 2023-06-07 14:50:22 -04:00 committed by GitHub
parent a35cafa728
commit 39d4aaf224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 16 deletions

View File

@ -119,15 +119,15 @@ const (
OperationCategoryKV OperationCategory = "KV"
OperationCategoryPreparedQuery OperationCategory = "PreparedQuery"
OperationCategorySession OperationCategory = "Session"
OperationCategoryStatus OperationCategory = "Status"
OperationCategoryStatus OperationCategory = "Status" // not limited
OperationCategoryTxn OperationCategory = "Txn"
OperationCategoryAutoConfig OperationCategory = "AutoConfig"
OperationCategoryFederationState OperationCategory = "FederationState"
OperationCategoryInternal OperationCategory = "Internal"
OperationCategoryOperator OperationCategory = "Operator"
OperationCategoryOperator OperationCategory = "Operator" // not limited
OperationCategoryPeerStream OperationCategory = "PeerStream"
OperationCategoryPeering OperationCategory = "Peering"
OperationCategoryPartition OperationCategory = "Partition"
OperationCategoryPartition OperationCategory = "Tenancy"
OperationCategoryDataPlane OperationCategory = "DataPlane"
OperationCategoryDNS OperationCategory = "DNS"
OperationCategorySubscribe OperationCategory = "Subscribe"

View File

@ -144,4 +144,9 @@ var rpcRateLimitSpecs = map[string]rate.OperationSpec{
"Txn.Apply": {Type: rate.OperationTypeWrite, Category: rate.OperationCategoryTxn},
"Txn.Read": {Type: rate.OperationTypeRead, Category: rate.OperationCategoryTxn},
"Namespace.Write": {Type: rate.OperationTypeWrite, Category: rate.OperationCategoryPartition},
"Namespace.Delete": {Type: rate.OperationTypeWrite, Category: rate.OperationCategoryPartition},
"Namespace.List": {Type: rate.OperationTypeRead, Category: rate.OperationCategoryPartition},
"Namespace.Read": {Type: rate.OperationTypeRead, Category: rate.OperationCategoryPartition},
}

View File

@ -20,19 +20,29 @@ type RateLimitIPConfigEntry struct {
WriteRate float64
//limits specific to a type of call
ACL *ReadWriteRatesConfig `json:",omitempty"`
Catalog *ReadWriteRatesConfig `json:",omitempty"`
ConfigEntry *ReadWriteRatesConfig `json:",omitempty"`
ConnectCA *ReadWriteRatesConfig `json:",omitempty"`
Coordinate *ReadWriteRatesConfig `json:",omitempty"`
DiscoveryChain *ReadWriteRatesConfig `json:",omitempty"`
Health *ReadWriteRatesConfig `json:",omitempty"`
Intention *ReadWriteRatesConfig `json:",omitempty"`
KV *ReadWriteRatesConfig `json:",omitempty"`
Tenancy *ReadWriteRatesConfig `json:",omitempty"`
PreparedQuery *ReadWriteRatesConfig `json:",omitempty"`
Session *ReadWriteRatesConfig `json:",omitempty"`
Txn *ReadWriteRatesConfig `json:",omitempty"`
ACL *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryACL OperationCategory = "ACL"
Catalog *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryCatalog OperationCategory = "Catalog"
ConfigEntry *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryConfigEntry OperationCategory = "ConfigEntry"
ConnectCA *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryConnectCA OperationCategory = "ConnectCA"
Coordinate *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryCoordinate OperationCategory = "Coordinate"
DiscoveryChain *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryDiscoveryChain OperationCategory = "DiscoveryChain"
ServerDiscovery *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryServerDiscovery OperationCategory = "ServerDiscovery"
Health *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryHealth OperationCategory = "Health"
Intention *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryIntention OperationCategory = "Intention"
KV *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryKV OperationCategory = "KV"
Tenancy *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryPartition OperationCategory = "Tenancy"
PreparedQuery *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryPreparedQuery OperationCategory = "PreparedQuery"
Session *ReadWriteRatesConfig `json:",omitempty"` // OperationCategorySession OperationCategory = "Session"
Txn *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryTxn OperationCategory = "Txn"
AutoConfig *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryAutoConfig OperationCategory = "AutoConfig"
FederationState *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryFederationState OperationCategory = "FederationState"
Internal *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryInternal OperationCategory = "Internal"
PeerStream *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryPeerStream OperationCategory = "PeerStream"
Peering *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryPeering OperationCategory = "Peering"
DataPlane *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryDataPlane OperationCategory = "DataPlane"
DNS *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryDNS OperationCategory = "DNS"
Subscribe *ReadWriteRatesConfig `json:",omitempty"` // OperationCategorySubscribe OperationCategory = "Subscribe"
Resource *ReadWriteRatesConfig `json:",omitempty"` // OperationCategoryResource OperationCategory = "Resource"
// Partition is the partition the config entry is associated with.
// Partitioning is a Consul Enterprise feature.