Repository navigation
signals: Adds ContextWithHUP - #144
Conversation
Adds ContextWithHUP to create a context that is canceled when a SIGHUP signal is received. This allows applications to gracefully handle configuration reloads or other actions triggered by SIGHUP without needing to manage signal handling On Windows, where SIGHUP is not available, ContextWithHUP is a no-op and returns the original context. Signed-off-by: joshvanl <me@joshvanl.dev>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #144 +/- ##
==========================================
+ Coverage 70.99% 71.69% +0.69%
==========================================
Files 85 89 +4
Lines 5931 6017 +86
==========================================
+ Hits 4211 4314 +103
+ Misses 1550 1528 -22
- Partials 170 175 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a ContextWithHUP helper to the signals package to support canceling a context on SIGHUP (for POSIX), with a Windows no-op implementation, enabling apps to react to HUP without bespoke signal wiring.
Changes:
- Add
ContextWithHUP(ctx)on POSIX that cancels whenSIGHUPis received. - Add Windows no-op
ContextWithHUP(ctx)implementation. - Expand POSIX tests to cover SIGTERM cancellation and verify
context.Causecontains signal info; add tests forContextWithHUP.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
signals/signals_posix.go |
Implements ContextWithHUP with signal.Notify + goroutine cancellation on SIGHUP. |
signals/signals_windows.go |
Adds ContextWithHUP as a Windows no-op returning the input context. |
signals/signals_posix_test.go |
Adds coverage for SIGTERM, cancellation cause content, and SIGHUP-driven cancellation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
missed. Signed-off-by: joshvanl <me@joshvanl.dev>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f2c6742 to
99c71cf
Compare
Signed-off-by: joshvanl <me@joshvanl.dev>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Josh van Leeuwen <me@joshvanl.dev>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Josh van Leeuwen <me@joshvanl.dev>
cancel Signed-off-by: joshvanl <me@joshvanl.dev>
Signed-off-by: joshvanl <me@joshvanl.dev>
Adds ContextWithHUP to create a context that is canceled when a SIGHUP signal is received. This allows applications to gracefully handle configuration reloads or other actions triggered by SIGHUP without needing to manage signal handling
On Windows, where SIGHUP is not available, ContextWithHUP is a no-op and returns the original context.