func()

in testutils/relay.go [102:134]


func (r *frameRelay) relayBetween(outgoing bool, c net.Conn, outC net.Conn) {
	defer r.wg.Done()

	frame := tchannel.NewFrame(tchannel.MaxFramePayloadSize)
	for {
		err := frame.ReadIn(c)
		if err == io.EOF {
			// Connection gracefully closed.
			return
		}
		if err != nil && r.closed.Load() > 0 {
			// Once the relay is shutdown, we expect connection errors.
			return
		}
		if !assert.NoError(r.t, err, "read frame failed") {
			return
		}

		outFrame := r.relayFunc(outgoing, frame)
		if outFrame == nil {
			continue
		}

		err = outFrame.WriteOut(outC)
		if err != nil && r.closed.Load() > 0 {
			// Once the relay is shutdown, we expect connection errors.
			return
		}
		if !assert.NoError(r.t, err, "write frame failed") {
			return
		}
	}
}