diff options
author | Alexander Kiryukhin <a.kiryukhin@corp.mail.ru> | 2019-04-04 11:54:24 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@corp.mail.ru> | 2019-04-04 11:54:24 +0300 |
commit | 08cbc9b6c05427fd3864bab55a4b40146c54639d (patch) | |
tree | c44ab6f2b976a974c20894b29ee0401b5c073676 /rutina.go | |
parent | c86dd5f3d70d310a26da73ee4ef2897121c18909 (diff) |
Changed:
- Refactored errors chan
Fixed:
- Small fixes
Diffstat (limited to 'rutina.go')
-rwxr-xr-x | rutina.go | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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} |