Skip to content

Conversation

@daveallie
Copy link

Allow users to specify global_throttling, meaning all requests from an identifier to an endpoint with global_throttling enabled contribute toward the global_throttling_max.

Useful for app-wide throttling

@gottfrois
Copy link
Owner

Thanks for the pull request. I'm not sure about a global throttling capability since the purpose of this gem was really to allow "per endpoint" throttling capability.

@daveallie
Copy link
Author

It's isn't on by default, it's opt in on both the app and individual endpoint levels, (i.e. if I wan't endpoint A and B to contribute to the same total).

No hard feelings if this doesn't get merged in just thought I would spend a couple of minutes knocking this up as it was something I was looking for when looking to use this gem.

@gottfrois
Copy link
Owner

Maybe we should allow to customize the key used to track stats per endpoints. This way, one could do something like this:

Grape::Attack.configure do |config|
  config.max = 1000
  config.per = 1.day
end

and on each endpoints:

throttle key: "my_app"
get 'foo' do
  ...
end

@daveallie
Copy link
Author

Yeah I like that a lot more than the way I implemented it. It gives you the option to group endpoints in any way you want

nschneble added a commit to nschneble/grape-attack that referenced this pull request Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants