Exemplo n.º 1
0
// StopAll stops all StartStopper types and returns another channel
// which will close once all things have finished stopping.
// For more information, see stop.All.
func StopAll(stopGrace time.Duration, startStoppers ...StartStopper) <-chan stop.Signal {
	stoppers := make([]stop.Stopper, len(startStoppers))
	for i, ss := range startStoppers {
		stoppers[i] = ss.(stop.Stopper)
	}
	return stop.All(stopGrace, stoppers...)
}
Exemplo n.º 2
0
func TestAll(t *testing.T) {

	s1 := NewTestStopper()
	s2 := NewTestStopper()
	s3 := NewTestStopper()

	select {
	case <-stop.All(1*time.Second, s1, s2, s3):
	case <-time.After(1 * time.Second):
		t.Error("All signal was never sent (timed out)")
	}

}