aboutsummaryrefslogtreecommitdiff
path: root/rutina.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2019-04-04 11:54:24 +0300
committerAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2019-04-04 11:54:24 +0300
commit08cbc9b6c05427fd3864bab55a4b40146c54639d (patch)
treec44ab6f2b976a974c20894b29ee0401b5c073676 /rutina.go
parentc86dd5f3d70d310a26da73ee4ef2897121c18909 (diff)
Changed:
- Refactored errors chan Fixed: - Small fixes
Diffstat (limited to 'rutina.go')
-rwxr-xr-xrutina.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/rutina.go b/rutina.go
index f04ff55..a38c384 100755
--- a/rutina.go
+++ b/rutina.go
@@ -30,12 +30,12 @@ func New(mixins ...Mixin) *Rutina {
return r.With(mixins...)
}
+// With applies mixins
func (r *Rutina) With(mixins ...Mixin) *Rutina {
- nr := *r
for _, m := range mixins {
- m.apply(&nr)
+ m.apply(r)
}
- return &nr
+ return r
}
// Go routine
@@ -112,7 +112,13 @@ func (r *Rutina) Go(doer func(ctx context.Context) error, opts ...Options) {
}()
}
-// OS signals handler
+// Errors returns chan for all errors, event if DoNothingIfFail or RestartIfFail set.
+// By default it nil. Use MixinErrChan to turn it on
+func (r *Rutina) Errors() <-chan error {
+ return r.errCh
+}
+
+// ListenOsSignals is simple OS signals handler. By default listen syscall.SIGINT and syscall.SIGTERM
func (r *Rutina) ListenOsSignals(signals ...os.Signal) {
if len(signals) == 0 {
signals = []os.Signal{syscall.SIGINT, syscall.SIGTERM}