Skip to content

Commit 7b95364

Browse files
committed
add rate limiter for api commands
1 parent e58457c commit 7b95364

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cli/operation.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ func (o Operation) command() *cobra.Command {
139139

140140
req, _ := http.NewRequest(o.Method, uri, body)
141141
req.Header = headers
142-
MakeRequestAndFormat(req)
142+
rateLimiter := Throttle{
143+
rate: viper.GetInt("rsh-load-rate"),
144+
requests: viper.GetInt("rsh-requests"),
145+
}
146+
rateLimiter.RateLimit(func() {
147+
MakeRequestAndFormat(req)
148+
})
143149
},
144150
}
145151

0 commit comments

Comments
 (0)