diff --git a/dispatcher_test.go b/dispatcher_test.go index 55e8c34..94e9522 100644 --- a/dispatcher_test.go +++ b/dispatcher_test.go @@ -77,7 +77,7 @@ func Test_Dispatcher_WithReasonHandler(t *testing.T) { func Test_Dispatcher_WithEmitter(t *testing.T) { d := stop_dispatcher.NewDispatcher( - stop_dispatcher.WithEmitter(func(stopFn stop_dispatcher.ReasonHandler) { + stop_dispatcher.WithEmitter(func(stopFn func(stop_dispatcher.Reason)) { time.AfterFunc(10*time.Millisecond, func() { stopFn("fake_reason") }) @@ -92,7 +92,7 @@ func Test_Dispatcher_UnregisterCallback(t *testing.T) { safeInnerStopFn := sync.Mutex{} var innerStopFn func(stop_dispatcher.Reason) d := stop_dispatcher.NewDispatcher( - stop_dispatcher.WithEmitter(func(stopFn stop_dispatcher.ReasonHandler) { + stop_dispatcher.WithEmitter(func(stopFn func(stop_dispatcher.Reason)) { safeInnerStopFn.Lock() innerStopFn = stopFn safeInnerStopFn.Unlock() @@ -135,7 +135,7 @@ func Test_Dispatcher(t *testing.T) { callbackCalled = true return nil }) - d.RegisterEmitter(func(stopFn stop_dispatcher.ReasonHandler) { + d.RegisterEmitter(func(stopFn func(stop_dispatcher.Reason)) { time.AfterFunc(10*time.Millisecond, func() { stopFn("fake_reason") }) @@ -173,7 +173,7 @@ func Test_Dispatcher_Prioritize(t *testing.T) { step = append(step, "priority:3_index:0") return nil }) - d.RegisterEmitter(func(stopFn stop_dispatcher.ReasonHandler) { + d.RegisterEmitter(func(stopFn func(stop_dispatcher.Reason)) { time.AfterFunc(10*time.Millisecond, func() { stopFn("fake_reason") }) diff --git a/stop_emitter/signal.go b/stop_emitter/signal.go index edc25be..27f0129 100644 --- a/stop_emitter/signal.go +++ b/stop_emitter/signal.go @@ -19,7 +19,7 @@ func DefaultSignalEmitter() stop_dispatcher.Emitter { // SignalEmitter will emit stop reason when signal was received func SignalEmitter(signals ...os.Signal) stop_dispatcher.Emitter { - return func(stop stop_dispatcher.ReasonHandler) { + return func(stop func(stop_dispatcher.Reason)) { signalChan := make(chan os.Signal, 1) signalNotify(signalChan, signals...) stop(<-signalChan) @@ -35,7 +35,7 @@ func DefaultKillerSignalEmitter() stop_dispatcher.Emitter { // KillerSignalEmitter will emit stop reason when signal was received // it exit if signal was received a second time func KillerSignalEmitter(signals ...os.Signal) stop_dispatcher.Emitter { - return func(stop stop_dispatcher.ReasonHandler) { + return func(stop func(stop_dispatcher.Reason)) { signalReceived := false signalChan := make(chan os.Signal, 2) signalNotify(signalChan, signals...)