github.com/MerlinKodo/quic-go@v0.39.2/internal/flowcontrol/interface.go (about)

     1  package flowcontrol
     2  
     3  import "github.com/MerlinKodo/quic-go/internal/protocol"
     4  
     5  type flowController interface {
     6  	// for sending
     7  	SendWindowSize() protocol.ByteCount
     8  	UpdateSendWindow(protocol.ByteCount)
     9  	AddBytesSent(protocol.ByteCount)
    10  	// for receiving
    11  	AddBytesRead(protocol.ByteCount)
    12  	GetWindowUpdate() protocol.ByteCount // returns 0 if no update is necessary
    13  	IsNewlyBlocked() (bool, protocol.ByteCount)
    14  }
    15  
    16  // A StreamFlowController is a flow controller for a QUIC stream.
    17  type StreamFlowController interface {
    18  	flowController
    19  	// for receiving
    20  	// UpdateHighestReceived should be called when a new highest offset is received
    21  	// final has to be to true if this is the final offset of the stream,
    22  	// as contained in a STREAM frame with FIN bit, and the RESET_STREAM frame
    23  	UpdateHighestReceived(offset protocol.ByteCount, final bool) error
    24  	// Abandon should be called when reading from the stream is aborted early,
    25  	// and there won't be any further calls to AddBytesRead.
    26  	Abandon()
    27  }
    28  
    29  // The ConnectionFlowController is the flow controller for the connection.
    30  type ConnectionFlowController interface {
    31  	flowController
    32  	Reset() error
    33  }
    34  
    35  type connectionFlowControllerI interface {
    36  	ConnectionFlowController
    37  	// The following two methods are not supposed to be called from outside this packet, but are needed internally
    38  	// for sending
    39  	EnsureMinimumWindowSize(protocol.ByteCount)
    40  	// for receiving
    41  	IncrementHighestReceived(protocol.ByteCount) error
    42  }