dedis / onet

Overlay Network for distributed protocols
GNU Lesser General Public License v3.0
51 stars 29 forks source link

Improve StreamingHandlers contract #675

Open ineiti opened 3 years ago

ineiti commented 3 years ago

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

Onet would do the following:

Comments, @tharvik @cgrigis @nkcr ?

tharvik commented 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:

ineiti commented 3 years ago

I'm updating the description

ineiti commented 3 years ago

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: