Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context wraps a context and captures the signal that cancelled it.
func NewContext ¶
NewContext creates a context that is cancelled on SIGTERM (standard termination). It captures SIGINT (Interrupt) separately to allow the state machine to handle it.
Usage:
ctx := signal.NewContext(context.Background())
defer ctx.Cancel()
select {
case <-ctx.Done():
// Check if it was a signal or just a cancel
if sig := ctx.Signal(); sig != nil {
fmt.Println("Received signal:", sig)
}
}
Click to show internal directories.
Click to hide internal directories.