()
| 19 | ) |
| 20 | |
| 21 | func ExampleFanInWithContext() { |
| 22 | // return channel that generate |
| 23 | filler := func(start, stop int) chan int { |
| 24 | ch := make(chan int) |
| 25 | |
| 26 | go func() { |
| 27 | defer close(ch) |
| 28 | for i := start; i <= stop; i++ { |
| 29 | ch <- i |
| 30 | } |
| 31 | }() |
| 32 | |
| 33 | return ch |
| 34 | } |
| 35 | |
| 36 | ch1 := filler(10, 12) |
| 37 | ch2 := filler(12, 14) |
| 38 | ch3 := filler(15, 16) |
| 39 | |
| 40 | ctx := context.Background() |
| 41 | if ch, err := harmony.FanInWithContext(ctx, ch1, ch2, ch3); err != nil { |
| 42 | for val := range ch { |
| 43 | fmt.Println(val) |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // FututeWithContext is shows creation of two "futures" that are used in our |
| 49 | // "rate our dogs" startup. |
nothing calls this directly
no test coverage detected