v1.0.0
Golang lint / docker-smoke (push) Successful in 17s
Golang lint / lint (push) Failing after 18s

This commit is contained in:
2026-08-06 12:22:44 +03:00
parent a47ac72db0
commit bb2fa57bbe
21 changed files with 1075 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
// Package app provides application lifecycle primitives.
package app
import (
"context"
"os"
"os/signal"
"syscall"
)
// NewContext returns a context for the whole application lifecycle.
//
// The context is cancelled when the parent is cancelled or when the process
// receives an interrupt or a termination signal. Call the returned function
// during shutdown to unregister signal notifications and release resources.
func NewContext(parent context.Context) (context.Context, context.CancelFunc) {
return signal.NotifyContext(parent, os.Interrupt, syscall.SIGTERM)
}
+21
View File
@@ -0,0 +1,21 @@
package app
import (
"context"
"testing"
"time"
)
func TestNewContextCancelsWithParent(t *testing.T) {
parent, cancelParent := context.WithCancel(context.Background())
ctx, stop := NewContext(parent)
t.Cleanup(stop)
cancelParent()
select {
case <-ctx.Done():
case <-time.After(time.Second):
t.Fatal("application context was not cancelled")
}
}