Git Product home page Git Product logo

Comments (5)

marten-seemann avatar marten-seemann commented on June 23, 2024

Here's an API proposal:

We add a new method to the SendStream, ReceiveStream and Stream:

type StreamState int

// TODO: define constants for all stream states defined in RFC 9000

type {Send,Receive}Stream interface {
     StateTransition() <-chan StreamState
}

The channel returned here is a buffered channel, with a capacity sufficient to hold all possible state transitions. I haven't done the math yet, but 8 should be sufficient, maybe even smaller.

The nice property of this channel API is that it doesn't matter when the application calls it: For example, the stream might already be closed when it is called. The channel will then contain all state transitions that happened to reach this state.


On the other hand, it requires a Go routine to block on this channel. Maybe it's better to set a callback:

type {Send,Receive}Stream interface {
     OnStateTransition(func(StreamState))
}

This callback would be called multiple times if multiple state transitions had already happened.

from quic-go.

marten-seemann avatar marten-seemann commented on June 23, 2024

Note that the callback allows us to have multiple layers set a callback. We'd just wrap the existing callback. It's not terribly efficient, but should be fine for a limited number of callbacks. I don't see how this would work with the channel-based API.

from quic-go.

marten-seemann avatar marten-seemann commented on June 23, 2024

Alternatively, we could consider changing how the QUIC layers reports streams as completed: We could only do that once the STOP_SENDING error (for send streams) or RESET_STREAM error (for receive streams) has been read by the application.

This would enforce "correct" usage of the stream API, and allow applications to more easily track the stream state by just wrapping a quic.Stream. The downside is that this change is pretty subtle, and we really need to make sure that we get it right, otherwise we risk deadlocks if streams don't get garbage collected.

from quic-go.

marten-seemann avatar marten-seemann commented on June 23, 2024

Another downside is that the stream actually needs to be used (read from and written to). It's possible to just open the HTTP stream, and send and receive datagrams, but that means you'll never observe the state transition.

from quic-go.

marten-seemann avatar marten-seemann commented on June 23, 2024

Resolved by #4445 and #4460.

from quic-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.