func (r *Runner) Run(ctx context.Context, wg *sync.WaitGroup, in <-chan message.Message) <-chan message.Message {
	ctx, cancelFunc := context.WithCancel(ctx)
	out := make(chan message.Message)
	wg.Add(1)
	run := func() {
		defer wg.Done()
		defer r.log.Printf("game runner stopped")
		defer close(out)
		defer cancelFunc()
		for { // BLOCKING
			select {
			case <-ctx.Done():
				return
			case m, ok := <-in:
				if !ok {
					return
				}
				r.handleMessage(ctx, wg, m, out)
			}
		}
	}
	go run()
	return out
}
// Run consumes messages from the "in" channel, processing them on a new goroutine until the "in" channel closes.
// The results of messages are sent on the "out" channel to be read by the subscriber.
Run consumes messages from the "in" channel, processing them on a new goroutine until the "in" channel closes.
The results of messages are sent on the "out" channel to be read by the subscriber.
// Run consumes messages from the " in " channel processing them on a new goroutine until the " in " channel closes . // The results of messages are sent on the " out " channel to be read by the subscriber .
func (r *Runner) Run(ctx context.Context, wg *sync.WaitGroup, in <-chan message.Message) <-chan message.Message {
	ctx, cancelFunc := context.WithCancel(ctx)
	out := make(chan message.Message)
	wg.Add(1)
	run := func() {
		defer wg.Done()
		defer r.log.Printf("game runner stopped")
		defer close(out)
		defer cancelFunc()
		for { 
			select {
			case <-ctx.Done():
				return
			case m, ok := <-in:
				if !ok {
					return
				}
				r.handleMessage(ctx, wg, m, out)
			}
		}
	}
	go run()
	return out
}
func ( r * Runner ) Run ( ctx context . Context , wg * sync . WaitGroup , in <- chan message . Message ) <- chan message . Message { ctx , cancelFunc := context . WithCancel ( ctx ) out := make ( chan message . Message ) wg . Add ( 1 ) run := func ( ) { defer wg . Done ( ) defer r . log . Printf ( " " ) defer close ( out ) defer cancelFunc ( ) for { select { case <- ctx . Done ( ) : return case m , ok := <- in : if ! ok { return } r . handleMessage ( ctx , wg , m , out ) } } } go run ( ) return out }
Run consumes messages from the "in" channel, processing them on a new goroutine until the "in" channel closes.
Run consumes messages from the " in " channel processing them on a new goroutine until the " in " channel closes .
// BLOCKING