• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-server / 2030701598

09 Sep 2025 09:31PM UTC coverage: 65.606% (+0.3%) from 65.283%
2030701598

Pull #946

gitlab-ci

web-flow
chore: bump vite from 7.0.6 to 7.1.5 in /frontend

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 7.0.6 to 7.1.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v7.1.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 7.1.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #946: chore: bump vite from 7.0.6 to 7.1.5 in /frontend

28607 of 43604 relevant lines covered (65.61%)

1.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/backend/pkg/rate/limit.go
1
package rate
2

3
import (
4
        "context"
5
        "time"
6

7
        "golang.org/x/time/rate"
8
)
9

10
// Limiter implements a rate limiting interface based on golang.org/x/time/rate
11
// but extending the interface with the ability to expose internal errors.
12
type Limiter interface {
13
        Reserve(ctx context.Context) (Reservation, error)
14
}
15

16
type LimiterFunc func(context.Context) (Reservation, error)
17

18
func (f LimiterFunc) Reserve(ctx context.Context) (Reservation, error) {
×
19
        return f(ctx)
×
20
}
×
21

22
// EventLimiter allows grouping limiters by eventID.
23
type EventLimiter interface {
24
        ReserveEvent(ctx context.Context, eventID string) (Reservation, error)
25
}
26

27
// Reservation is a point-in-time reservation of a ratelimit token. If the token
28
// is approved OK return true, otherways Delay will return the duration for next
29
// token(s) to become available. While Tokens return the number of available
30
// tokens after the reservation.
31
type Reservation interface {
32
        OK() bool
33
        Delay() time.Duration
34
        Tokens() int64
35
}
36

37
type limiter rate.Limiter
38

39
func NewLimiter(limit int, interval time.Duration) Limiter {
×
40
        return (*limiter)(rate.NewLimiter(rate.Every(interval/time.Duration(limit)), limit))
×
41
}
×
42

43
func (lim *limiter) Reserve(context.Context) (Reservation, error) {
×
44
        now := time.Now()
×
45
        goLimiter := (*rate.Limiter)(lim)
×
46
        res := &reservation{
×
47
                reservation: goLimiter.ReserveN(now, 1),
×
48
                time:        now,
×
49
        }
×
50
        if res.OK() {
×
51
                res.tokens = int64(goLimiter.TokensAt(now))
×
52
        }
×
53
        return res, nil
×
54
}
55

56
type reservation struct {
57
        time        time.Time
58
        tokens      int64
59
        reservation *rate.Reservation
60
}
61

62
func (r *reservation) OK() bool {
×
63
        return r.Delay() == 0
×
64
}
×
65

66
func (r *reservation) Delay() time.Duration {
×
67
        return r.reservation.DelayFrom(r.time)
×
68
}
×
69

70
func (r *reservation) Tokens() int64 {
×
71
        return r.tokens
×
72
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc