call new proxy funcs from within b.serve
Proxy constructors are light functions, so it is ok to call from within
b.serve loop.
Vladimir Bauer
1 year, 10 months ago
| 90 | 90 | if r == nil { |
| 91 | 91 | panic("expected non nil io.Reader") |
| 92 | 92 | } |
| 93 | result := make(chan bool) | |
| 94 | select { | |
| 95 | case b.operateState <- func(s *bState) { result <- len(s.ewmaDecorators) != 0 }: | |
| 96 | return newProxyReader(r, b, <-result) | |
| 93 | result := make(chan io.ReadCloser) | |
| 94 | select { | |
| 95 | case b.operateState <- func(s *bState) { | |
| 96 | result <- newProxyReader(r, b, len(s.ewmaDecorators) != 0) | |
| 97 | }: | |
| 98 | return <-result | |
| 97 | 99 | case <-b.ctx.Done(): |
| 98 | 100 | return nil |
| 99 | 101 | } |
| 106 | 108 | if w == nil { |
| 107 | 109 | panic("expected non nil io.Writer") |
| 108 | 110 | } |
| 109 | result := make(chan bool) | |
| 110 | select { | |
| 111 | case b.operateState <- func(s *bState) { result <- len(s.ewmaDecorators) != 0 }: | |
| 112 | return newProxyWriter(w, b, <-result) | |
| 111 | result := make(chan io.WriteCloser) | |
| 112 | select { | |
| 113 | case b.operateState <- func(s *bState) { | |
| 114 | result <- newProxyWriter(w, b, len(s.ewmaDecorators) != 0) | |
| 115 | }: | |
| 116 | return <-result | |
| 113 | 117 | case <-b.ctx.Done(): |
| 114 | 118 | return nil |
| 115 | 119 | } |