Senior · Design · Channels own completion and terminal failure

Design a channel pipeline with two producers and clear terminal-failure ownership.

Think through your answer before opening the explanation.

Runtime & concurrency

Reveal answer and reasoning

Give a coordinator ownership of writer completion after both producer operations have finished, and state how producer failure or group cancellation is propagated. Consumers must use the channel protocol to drain accepted data and observe the terminal result. Keep a single consumer's wait cancellation separate from the lifetime of shared admission, and select bounded backpressure or drop behavior according to the workload.

Test successful data from both producers, one producer failure, successful empty completion, canceled personal waits, and later admission rejection. Retain and await every producer, consumer, and coordinator task with bounded test control. The wrong design lets the first finishing producer close the writer or silently ignores terminal failure once some items were processed. Production handling after removal still needs its own retry, effect, and durability policy; an in-memory Channel cannot establish a broker acknowledgment or transaction merely by owning asynchronous handoff correctly.

What a strong answer covers

  • One coordinator owns shared completion.
  • Observe accepted data and terminal outcome.
  • Own every task and separate personal wait cancellation.

Common pitfall

Letting an individual producer or reader close a shared channel without lifecycle authority.

Follow-up questions

  1. What should happen to remaining accepted work after one producer fails?
  2. How would shutdown enforce a finite deadline?

Self-review

Choose what to revisit. These marks are your own assessment and are separate from lesson completion.

Primary references

Open lesson and code ↗

← All interview questions