[design] remove QuicConnectionProtocol.create_stream() ?
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_handlerargument toclient.connect() - the
stream_handlerargument toserver.listen()
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:
- Client connects.
- Client
create_stream(). - Client uses stream_id to send the first message.
- 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.
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)
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?
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.