feat: catalogue generate now rate limits
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Closes coop-cloud/organising#231.
This commit is contained in:
20
pkg/limit/limit.go
Normal file
20
pkg/limit/limit.go
Normal file
@ -0,0 +1,20 @@
|
||||
package limit // https://github.com/tidwall/limiter
|
||||
|
||||
// Limiter is for limiting the number of concurrent operations. This
|
||||
type Limiter struct{ sem chan struct{} }
|
||||
|
||||
// New returns a new Limiter. The limit param is the maximum number of
|
||||
// concurrent operations.
|
||||
func New(limit int) *Limiter {
|
||||
return &Limiter{make(chan struct{}, limit)}
|
||||
}
|
||||
|
||||
// Begin an operation.
|
||||
func (l *Limiter) Begin() {
|
||||
l.sem <- struct{}{}
|
||||
}
|
||||
|
||||
// End the operation.
|
||||
func (l *Limiter) End() {
|
||||
<-l.sem
|
||||
}
|
Reference in New Issue
Block a user