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

lif0 / go-gracefully / 18635932339

19 Oct 2025 08:50PM UTC coverage: 68.783% (-1.9%) from 70.69%
18635932339

push

github

lif0
feat: introduced RegisterFunc;

28 of 36 new or added lines in 2 files covered. (77.78%)

1 existing line in 1 file now uncovered.

130 of 189 relevant lines covered (68.78%)

518.37 hits per line

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

33.33
/global.go
1
package gracefully
2

3
import (
4
        "context"
5

6
        "github.com/lif0/go-gracefully/internal"
7
        "github.com/lif0/pkg/utils/errx"
8
)
9

10
var (
11
        defaultRegistry = NewRegistry()
12

13
        DefaultRegisterer Registerer = defaultRegistry
14
        GlobalErrors                 = internal.NewSyncObject(errx.MultiError{})
15
)
16

17
// SetGlobal sets a custom GracefullyRegister as the global registry.
18
// This allows replacing the default registry with a user-provided one
19
// (e.g. for testing purposes).
20
func SetGlobal(gr *Registry) {
×
21
        DefaultRegisterer = gr
×
22
}
×
23

24
// Register registers the provided GracefulShutdownObject with the DefaultRegisterer.
25
//
26
// Register is a shortcut for DefaultRegisterer.Register(c).
27
func Register(igs GracefulShutdownObject) error {
×
28
        return DefaultRegisterer.Register(igs)
×
29
}
×
30

31
// RegisterFunc registers the provided func with the DefaultRegisterer.
32
//
33
// Register is a shortcut for DefaultRegisterer.RegisterFunc(f).
NEW
34
func RegisterFunc(f func(context.Context) error) error {
×
NEW
35
        return DefaultRegisterer.RegisterFunc(f)
×
NEW
36
}
×
37

38
// Unregister removes the registration of the provided GracefulShutdownObject from the
39
// DefaultRegisterer.
40
//
41
// Unregister is a shortcut for DefaultRegisterer.Unregister(c).
42
func Unregister(igs GracefulShutdownObject) bool {
2✔
43
        return DefaultRegisterer.Unregister(igs)
2✔
44
}
2✔
45

46
// MustRegister registers the provided GracefulShutdownObject with the DefaultRegisterer and
47
// panics if any error occurs.
48
//
49
// MustRegister is a shortcut for DefaultRegisterer.MustRegister(cs...).
50
func MustRegister(igss ...GracefulShutdownObject) {
1✔
51
        DefaultRegisterer.MustRegister(igss...)
1✔
52
}
1✔
53

54
// WaitShutdown blocks the calling goroutine until with the DefaultRegisterer
55
// has finished shutdown all registered instances
56
//
57
// WaitShutdown is a shortcut for DefaultRegisterer.WaitShutdown().
58
func WaitShutdown() {
×
59
        DefaultRegisterer.WaitShutdown()
×
60
}
×
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