- Internals of the API might be affected by unknown behavior of callbacks
- lets the consumer decides how many goroutines is needed to handle it
1 - I should emphasize that the API in question is concurrent by nature (inbounds at any time which might need replies).
2 - All points made are good valid points in general. Thanks!
3 - With 1 in mind, still IMHO, channels should be preferred. Draining on either side, needs goroutines. But consumer must have better control - not just one goroutine per inbound. But yes, it's a concern.
(I'm on mobile now, but I'll give it more thought).
----------------------------------------------------------------------Synchronous Functions----------------------------------------------------------------------Prefer synchronous functions - functions which return their results directly or finish any callbacks or channel ops before returning - over asynchronous ones.Synchronous functions keep goroutines localized within a call, making it easier to reason about their lifetimes and avoid leaks and data races. They're also easier to test: the caller can pass an input and check the output without the need for polling or synchronization.If callers need more concurrency, they can add it easily by calling the function from a separate goroutine. But it is quite difficult - sometimes impossible - to remove unnecessary concurrency at the caller side.----------------------------------------------------------------------