refactor to use app package instead of service

refactor app to be composable
This commit is contained in:
Robin Olsen
2026-02-28 23:30:31 +01:00
parent ba4d3df669
commit aabce0b0b2
56 changed files with 385 additions and 279 deletions

21
internal/app/lifecycle.go Normal file
View File

@@ -0,0 +1,21 @@
package app
type Lifecycle struct {
cleanups []func()
}
func NewLifecycle() *Lifecycle {
return &Lifecycle{
cleanups: make([]func(), 0),
}
}
func (l *Lifecycle) Add(fn func()) {
l.cleanups = append(l.cleanups, fn)
}
func (l *Lifecycle) Close() {
for i := len(l.cleanups) - 1; i >= 0; i-- {
l.cleanups[i]()
}
}