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

mendersoftware / mender-server / 1961830404

01 Aug 2025 06:29PM UTC coverage: 65.815% (+0.3%) from 65.555%
1961830404

Pull #849

gitlab-ci

web-flow
chore: bump the backend-docker-dependencies group across 10 directories with 2 updates

Bumps the backend-docker-dependencies group with 2 updates in the /backend/services/create-artifact-worker directory: golang and alpine.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/deployments directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/deviceauth directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/deviceconfig directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/deviceconnect directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/inventory directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/iot-manager directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/reporting directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/useradm directory: golang.
Bumps the backend-docker-dependencies group with 1 update in the /backend/services/workflows directory: golang.


Updates `golang` from 1.24.4 to 1.24.5

Updates `alpine` from 3.22.0 to 3.22.1

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

Updates `golang` from 1.24.4 to 1.24.5

---
updated-dependencies:
- dependency-name: golang
  dependency-version: 1.24.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: backend-docker-dependencies
- dependency-name: alpine
  dependency-version: 3.22.1
  dependency-type: direct:production... (continued)
Pull Request #849: chore: bump the backend-docker-dependencies group across 10 directories with 2 updates

29335 of 44572 relevant lines covered (65.81%)

1.44 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