Add Batch Limits to API limits config

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10556
GitOrigin-RevId: a4ff69dfc0b1651e0376aa60545a0b0b7d6ee41d
This commit is contained in:
Sandeep Raj Kumar 2023-12-15 07:34:29 +05:30 committed by hasura-bot
parent 7fd9f0fd7c
commit 0ff034cb87
5 changed files with 53 additions and 11 deletions

View File

@ -50,6 +50,7 @@ type apiLimitsObject struct {
DepthLimit yaml.Node `yaml:"depth_limit,omitempty"`
NodeLimit yaml.Node `yaml:"node_limit,omitempty"`
TimeLimit yaml.Node `yaml:"time_limit,omitempty"`
BatchLimit yaml.Node `yaml:"batch_limit,omitempty"`
}
func (o *MetadataObject) Build() (map[string]interface{}, error) {

View File

@ -101,10 +101,29 @@ func TestMetadataObject_Export(t *testing.T) {
map[string][]byte{
"testdata/export_test/api_limits.yaml": []byte(`disabled: false
rate_limit:
per_role: {}
global:
max_reqs_per_min: 30
unique_params: IP
max_reqs_per_min: 1
per_role:
user:
max_reqs_per_min: 10
unique_params: null
depth_limit:
global: 5
per_role:
user: 2
node_limit:
global: 5
per_role:
user: 2
time_limit:
global: 30
per_role:
user: 10
batch_limit:
global: 5
per_role:
user: 2
`)},
false,
require.NoError,

View File

@ -1,6 +1,25 @@
batch_limit:
global: 5
per_role:
user: 2
depth_limit:
global: 5
per_role:
user: 2
disabled: false
node_limit:
global: 5
per_role:
user: 2
rate_limit:
per_role: {}
global:
max_reqs_per_min: 30
unique_params: IP
max_reqs_per_min: 1
per_role:
user:
max_reqs_per_min: 10
unique_params: null
time_limit:
global: 30
per_role:
user: 10

View File

@ -1 +1 @@
{"api_limits": {"disabled": false, "rate_limit": {"per_role": {}, "global": {"unique_params": "IP", "max_reqs_per_min": 1}}}}
{"api_limits": {"disabled": false, "rate_limit": {"global": {"max_reqs_per_min": 30, "unique_params": "IP"}, "per_role": {"user": {"max_reqs_per_min": 10, "unique_params": null}}}, "depth_limit": {"global": 5, "per_role": {"user": 2}}, "node_limit": {"global": 5, "per_role": {"user": 2}}, "time_limit": {"global": 30, "per_role": {"user": 10}}, "batch_limit": {"global": 5, "per_role": {"user": 2}}}}

View File

@ -4,11 +4,14 @@
"api_limits": {
"disabled": false,
"rate_limit": {
"per_role": {},
"global": {
"unique_params": "IP",
"max_reqs_per_min": 1
"global": { "max_reqs_per_min": 30, "unique_params": "IP" },
"per_role": {
"user": { "max_reqs_per_min": 10, "unique_params": null }
}
}
},
"depth_limit": { "global": 5, "per_role": { "user": 2 } },
"node_limit": { "global": 5, "per_role": { "user": 2 } },
"time_limit": { "global": 30, "per_role": { "user": 10 } },
"batch_limit": { "global": 5, "per_role": { "user": 2 } }
}
}
}