go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/server/quotabeta/examples/ratelimit/README.md (about) 1 # Quota Library Rate Limit Example 2 3 This example shows how to integrate the quota library into a GAE service. 4 Not intended to be run on App Engine. A GAE demo can be found under 5 [examples/appengine/quota](../../../../examples/appengine/quota). 6 7 ## Usage 8 9 Startup: 10 ```shell 11 $ go run .& 12 <observe logs, wait for the server to start> 13 ``` 14 15 Verify that rate limiting works: 16 ```shell 17 $ curl http://localhost:8800/global-rate-limit-endpoint 18 <observe logs, expected 200 OK> 19 $ curl http://localhost:8800/global-rate-limit-endpoint 20 <observe logs, expected 429 Rate Limit Exceeded> 21 <wait 60 seconds> 22 $ curl http://localhost:8800/global-rate-limit-endpoint 23 <observe logs, expected 200 OK> 24 ``` 25 26 Verify that resetting quota works: 27 ```shell 28 $ curl http://localhost:8800/global-rate-limit-reset 29 <observe logs, expected 200 OK> 30 $ curl http://localhost:8800/global-rate-limit-endpoint 31 <observe logs, expected 200 OK> 32 $ curl http://localhost:8800/global-rate-limit-endpoint 33 <observe logs, expected 429 Rate Limit Exceeded> 34 ``` 35 36 Verify that multiple resets don't stack: 37 ```shell 38 $ curl http://localhost:8800/global-rate-limit-reset 39 <observe logs, expected 200 OK> 40 $ curl http://localhost:8800/global-rate-limit-reset 41 <observe logs, expected 200 OK> 42 $ curl http://localhost:8800/global-rate-limit-endpoint 43 <observe logs, expected 200 OK> 44 $ curl http://localhost:8800/global-rate-limit-endpoint 45 <observe logs, expected 429 Rate Limit Exceeded> 46 ```