aboutsummaryrefslogtreecommitdiff
path: root/mixins.go
diff options
context:
space:
mode:
Diffstat (limited to 'mixins.go')
-rwxr-xr-xmixins.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/mixins.go b/mixins.go
index 1344d07..aea08ef 100755
--- a/mixins.go
+++ b/mixins.go
@@ -4,6 +4,7 @@ import (
"context"
"log"
"os"
+ "syscall"
)
// Mixin interface
@@ -72,3 +73,18 @@ func (l LifecycleMixin) apply(r *Rutina) {
func WithLifecycleListener(listener LifecycleListener) *LifecycleMixin {
return &LifecycleMixin{Listener: listener}
}
+
+type ListenOsSignalsMixin struct {
+ Signals []os.Signal
+}
+
+func (l ListenOsSignalsMixin) apply(r *Rutina) {
+ r.autoListenSignals = l.Signals
+}
+
+func WithListenOsSignals(signals ...os.Signal) *ListenOsSignalsMixin {
+ if len(signals) == 0 {
+ signals = []os.Signal{syscall.SIGINT, syscall.SIGTERM}
+ }
+ return &ListenOsSignalsMixin{Signals: signals}
+}