From 08cbc9b6c05427fd3864bab55a4b40146c54639d Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Thu, 4 Apr 2019 11:54:24 +0300 Subject: Changed: - Refactored errors chan Fixed: - Small fixes --- rutina.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'rutina.go') 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} -- cgit v1.2.3