han...@google.com
unread,Oct 25, 2013, 2:31:09 PM10/25/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to a...@golang.org, da...@cheney.net, jps...@google.com, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
On 2013/10/25 16:52:12, agl1 wrote:
> This change seems to suck for a user of this package. Now I have to
spin off a
> goroutine to manage requests and, if I forget, the channel fills up
and
> everything grinds to a halt?
A couple of solutions:
1. we buffer incoming requests indefinitely if nobody calls
IncomingRequests()? Then it won't come to a halt, and it will simplify
most use-cases. The disadvantage is that if the remote side sends some
system specific request ("keepalive@randomvendor"), the user still needs
to handle it, and there is nothing that tells him.
2. We let the user register callbacks based on the request type string.
This lets us send failure messages to unknown WantReply requests, so we
will handle "keepalive@randomvendor" correctly. We could either do
type RequestHandler func(incoming *Request) error
func (c *channel) RegisterHandler(reqType string, handler
RequestHandler)
or
func (c *channel) HandleRequest(reqType string) chan *Request
3. We do nothing. This is not very practical, because as it stands you
cannot practically pass off a Channel as io.Reader / io.Writer, since
things like io.ReadFull() can't handle ChannelRequests.
I'm leaning towards #2. What do you think?
I could make it instantiate the channel on demand, ie. if nothing calls
IncomingRequests(), then we have an internal buffer which fills up.
https://codereview.appspot.com/15380048/