Codebase list golang-github-vbauerster-mpb / ddf5b75
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
1 changed file(s) with 12 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
9090 if r == nil {
9191 panic("expected non nil io.Reader")
9292 }
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
9799 case <-b.ctx.Done():
98100 return nil
99101 }
106108 if w == nil {
107109 panic("expected non nil io.Writer")
108110 }
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
113117 case <-b.ctx.Done():
114118 return nil
115119 }