periodic/periodic.go
func OnSignalGo(sig <-chan struct{}, procfunc gp.ProcessFunc) gp.Process {
	return gp.Go(func(proc gp.Process) {
		for {
			select {
			case <-sig:
				proc.Go(procfunc)
			case <-proc.Closing(): // we're told to close
				return
			}
		}
	})
}
func OnSignalGo(sig <-chan struct{}, procfunc gp.ProcessFunc) gp.Process {
	return gp.Go(func(proc gp.Process) {
		for {
			select {
			case <-sig:
				proc.Go(procfunc)
			case <-proc.Closing(): // we're told to close
				return
			}
		}
	})
}
func OnSignalGo ( sig <- chan struct { } , procfunc gp . ProcessFunc ) gp . Process { return gp . Go ( func ( proc gp . Process ) { for { select { case <- sig : proc . Go ( procfunc ) case <- proc . Closing ( ) : // we're told to close return } } } ) }
// OnSignalGo calls the given ProcessFunc every time the signal fires.
// This is not rate limited, multiple calls could be in-flight at the same time.
//
//  sig := make(chan struct{})
//  p := periodicproc.OnSignalGo(sig, func(proc goprocess.Process) {
//  	fmt.Println("fire!")
//  	<-time.After(time.Second) // wont block execution
//  })
//
//  sig<- struct{}
//  sig<- struct{}
//  sig<- struct{}
//
//  // Output:
//  // fire!
//  // fire!
//  // fire!
OnSignalGo calls the given ProcessFunc every time the signal fires . This is not rate limited multiple calls could be in - flight at the same time . sig : = make ( chan struct {} ) p : = periodicproc . OnSignalGo ( sig func ( proc goprocess . Process ) { fmt . Println ( fire! ) < - time . After ( time . Second ) // wont block execution } ) sig< - struct {} sig< - struct {} sig< - struct {} // Output : // fire! // fire! // fire!