Skip to content

Commit

Permalink
add rate limiter for api commands
Browse files Browse the repository at this point in the history
  • Loading branch information
eds000n committed Mar 16, 2023
1 parent 126ef04 commit eb9d928
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cli/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ func (o Operation) command() *cobra.Command {

req, _ := http.NewRequest(o.Method, uri, body)
req.Header = headers
MakeRequestAndFormat(req)
rateLimiter := Throttle{
rate: viper.GetInt("rsh-load-rate"),
requests: viper.GetInt("rsh-requests"),
}
rateLimiter.RateLimit(func() {
MakeRequestAndFormat(req)
})
},
}

Expand Down

0 comments on commit eb9d928

Please sign in to comment.