Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[design] remove QuicConnectionProtocol.create_stream() ? #169

Open
jlaine opened this issue Mar 9, 2021 · 5 comments
Open

[design] remove QuicConnectionProtocol.create_stream() ? #169

jlaine opened this issue Mar 9, 2021 · 5 comments
Labels

Comments

@jlaine
Copy link
Contributor

jlaine commented Mar 9, 2021

The QuicConnectionProtocol.create_stream() method was added to the API early on in the project to provide a way to create a raw pair of reader / writers. However, I have since realised that this is a very niche case, none of the examples use this API. It is more powerful to tap into the quic_event_received() callback.

Similarly the following should probably go:

  • the stream_handler argument to client.connect()
  • the stream_handler argument to server.listen()
@dimitsqx
Copy link

dimitsqx commented Mar 9, 2021

I also believe quic_event_received() is the way to handle data. Anyway, at some point this stream has to be created to send the first message on a particular stream. I believe it could be useful to have a create_stream like:

def create_stream():
    stream_id = self._quic.get_next_available_stream_id()
    stream= self._quic._get_or_create_stream_for_send()
    return stream_id

maybe also an API to send data without accessing QuicConnectionProtocol._quic:

def write(stream_id,data,end_stream):
    self._quic.send_stream_data(stream_id, data, end_stream)
    self.transmit()

The API will be used like:

  1. Client connects.
  2. Client create_stream().
  3. Client uses stream_id to send the first message.
  4. Next the stream_id from the QuicEvent is used

I think everyone will follow the logic from create_stream() when sending the data through a new stream so an API can be useful.

@jmgurney
Copy link
Contributor

Please don't remove this. I just added quic support to ntunnel and am using them. It save the work of having to demux the data, and makes using this integrate nicely with programs that are already designed to use asyncio.open_connection (https://docs.python.org/3/library/asyncio-stream.html#asyncio.open_connection)

@jlaine
Copy link
Contributor Author

jlaine commented Jun 16, 2022

I still plan to remove these APIs from the base protocol, as they are clunky, create confusion and are only needed for very specific cases. Would you might submitting a PR moving them to an example?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants