Caller blocks on reply channel
Review this Go request/response pipeline. A caller sends a job and blocks for the reply on a per-call channel.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 30 min
Mark a line and say what kind of problem it is.0 findings
1type Job struct{ Reply chan int }
2
3func (s *Server) Submit(j Job) int {
4 s.queue <- j // hand off to worker
5 return <-j.Reply // wait for result
6}
7
8func (s *Server) worker() {
9 for j := range s.queue {
10 result := compute(j)
11 select {
12 case j.Reply <- result:
13 default:
14 // caller gone, drop
15 }
16 }
17}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.