Switch to Debian testing and imagemagick. (#1021)

This commit is contained in:
Googol Lee
2024-08-29 10:30:06 +02:00
committed by GitHub
parent 6c5c304492
commit ad13172a32
17 changed files with 191 additions and 75 deletions

25
api/utils/throttle.go Normal file
View File

@@ -0,0 +1,25 @@
package utils
import "time"
type Throttle struct {
interval time.Duration
lastAction time.Time
}
func NewThrottle(interval time.Duration) Throttle {
return Throttle{
interval: interval,
lastAction: time.Unix(0, 0),
}
}
func (t *Throttle) Trigger(action func()) {
if action == nil {
return
}
if time.Now().After(t.lastAction.Add(t.interval)) {
t.lastAction = time.Now()
action()
}
}