Skip to content

Improve StreamingHandlers contract #675

@ineiti

Description

@ineiti

The current RegisterStreamingHandlers is not ideal when it comes to implement a streaming service:

  • every new client message calls the endpoint again
  • the endpoint cannot return an error once the streaming started
  • the contract between onet and the endpoint is not clear

A first, simplified method signature for a blocking endpoint:
Endpoint(<-input, ->output) error

  • arguments:
    • input-channel of messages from client
    • output-channel of messages from endpoint
  • return:
    • error, which can be nil to indicate the endpoint finished its work and is done

Onet would do the following:

  • setup the input- and output-channel
  • call the endpoint for each new connection from a client using Client.Stream
    • the endpoint is blocking and listening on the input channel for new messages, and sending messages on the output channel
    • if the endpoint is done, it can return with a nil error to indicate successful termination
    • any non-nil error indicates an error by the endpoint
  • send every message from the client through the input channel to the endpoint
  • send every message from the output-channel of the endpoint to the client
  • close the input-channel if the websocket is closed by the client
    • all further messages in the output-channel are ignored
    • any returned error from the endpoint is ignored
    • who should close the output-channel?
  • close the connection if the endpoint returns
    • if the error is nil, the connection is closed without an error
    • if the error is not nil, the error is sent as the reason for closing the connection

Comments, @tharvik @cgrigis @nkcr ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions