Open ineiti opened 3 years ago
Great idea, it's a bit hard to use currently. I'm adding some comments below.
A first, simplified change could be:
smth like Handler(inputs <-chan, outputs chan->, errors chan->)
?
I think that using smth like Handler(inputs <-chan, outputs chan->) error
would be more idiomatic, so that one can use the classic if err != nil
of golang without having to send something on the channel and then returning. Also, as zero-or-one message is expected on the error channel, no need to use a channel, nil
and != nil
has the same meaning.
- call the endpoint only once for each connection from a client
The client uses Client.Stream
to call a streaming handler, is that what you mean by "each connection"?
- one of the following actions triggers onet to close the input-channel:
What happens if the handler finishes and the output channel isn't closed? (discard if you're thinking of Handler(<-chan) (chan->, chan->, error)
, which I personally don't like)
Some other remarks:
StreamingConn.ReadMessage
is quite cumbersome to use, using a classic channel on the client might be easierHandler(<-input, ->output) error
I'm updating the description
To understand @tharvik's comments, here the original description:
The current RegisterStreamingHandlers
is not ideal when it comes to implement a streaming service:
A first, simplified change could be:
Onet would do the following:
The current
RegisterStreamingHandlers
is not ideal when it comes to implement a streaming service:A first, simplified method signature for a blocking endpoint:
Endpoint(<-input, ->output) error
nil
to indicate the endpoint finished its work and is doneOnet would do the following:
Client.Stream
nil
error to indicate successful terminationnil
error indicates an error by the endpointnil
, the connection is closed without an errornil
, the error is sent as the reason for closing the connectionComments, @tharvik @cgrigis @nkcr ?