forked from quic-go/quic-go
@@ -32,7 +32,7 @@ func NewFlowControlManager(connectionParametersManager *handshake.ConnectionPara
|
||||
contributesToConnectionFlowControl: make(map[protocol.StreamID]bool),
|
||||
}
|
||||
// initialize connection level flow controller
|
||||
fcm.streamFlowController[0] = NewFlowController(0, connectionParametersManager)
|
||||
fcm.streamFlowController[0] = newFlowController(0, connectionParametersManager)
|
||||
fcm.contributesToConnectionFlowControl[0] = false
|
||||
return &fcm
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (f *flowControlManager) NewStream(streamID protocol.StreamID, contributesTo
|
||||
return
|
||||
}
|
||||
|
||||
f.streamFlowController[streamID] = NewFlowController(streamID, f.connectionParametersManager)
|
||||
f.streamFlowController[streamID] = newFlowController(streamID, f.connectionParametersManager)
|
||||
f.contributesToConnectionFlowControl[streamID] = contributesToConnectionFlow
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func (f *flowControlManager) StreamContributesToConnectionFlowControl(streamID p
|
||||
return contributes, nil
|
||||
}
|
||||
|
||||
func (f *flowControlManager) getFlowController(streamID protocol.StreamID) (FlowController, error) {
|
||||
func (f *flowControlManager) getFlowController(streamID protocol.StreamID) (*flowController, error) {
|
||||
streamFlowController, ok := f.streamFlowController[streamID]
|
||||
if !ok {
|
||||
return nil, errMapAccess
|
||||
|
||||
@@ -24,9 +24,8 @@ type flowController struct {
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
|
||||
// NewFlowController gets a new flow controller
|
||||
// TODO: make private
|
||||
func NewFlowController(streamID protocol.StreamID, connectionParametersManager *handshake.ConnectionParametersManager) *flowController {
|
||||
// newFlowController gets a new flow controller
|
||||
func newFlowController(streamID protocol.StreamID, connectionParametersManager *handshake.ConnectionParametersManager) *flowController {
|
||||
fc := flowController{
|
||||
streamID: streamID,
|
||||
connectionParametersManager: connectionParametersManager,
|
||||
|
||||
@@ -35,24 +35,24 @@ var _ = Describe("Flow controller", func() {
|
||||
})
|
||||
|
||||
It("reads the stream send and receive windows when acting as stream-level flow controller", func() {
|
||||
fc := NewFlowController(5, cpm)
|
||||
fc := newFlowController(5, cpm)
|
||||
Expect(fc.streamID).To(Equal(protocol.StreamID(5)))
|
||||
Expect(fc.receiveFlowControlWindow).To(Equal(protocol.ByteCount(2000)))
|
||||
})
|
||||
|
||||
It("reads the stream send and receive windows when acting as stream-level flow controller", func() {
|
||||
fc := NewFlowController(0, cpm)
|
||||
fc := newFlowController(0, cpm)
|
||||
Expect(fc.streamID).To(Equal(protocol.StreamID(0)))
|
||||
Expect(fc.receiveFlowControlWindow).To(Equal(protocol.ByteCount(4000)))
|
||||
})
|
||||
|
||||
It("does not set the stream flow control windows for sending", func() {
|
||||
fc := NewFlowController(5, cpm)
|
||||
fc := newFlowController(5, cpm)
|
||||
Expect(fc.sendFlowControlWindow).To(BeZero())
|
||||
})
|
||||
|
||||
It("does not set the connection flow control windows for sending", func() {
|
||||
fc := NewFlowController(0, cpm)
|
||||
fc := newFlowController(0, cpm)
|
||||
Expect(fc.sendFlowControlWindow).To(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,20 +2,6 @@ package flowcontrol
|
||||
|
||||
import "github.com/lucas-clemente/quic-go/protocol"
|
||||
|
||||
// A FlowController handles the flow control
|
||||
type FlowController interface {
|
||||
AddBytesSent(n protocol.ByteCount)
|
||||
UpdateSendWindow(newOffset protocol.ByteCount) bool
|
||||
SendWindowSize() protocol.ByteCount
|
||||
SendWindowOffset() protocol.ByteCount
|
||||
UpdateHighestReceived(byteOffset protocol.ByteCount) protocol.ByteCount
|
||||
IncrementHighestReceived(increment protocol.ByteCount)
|
||||
AddBytesRead(n protocol.ByteCount)
|
||||
MaybeTriggerBlocked() bool
|
||||
MaybeTriggerWindowUpdate() (bool, protocol.ByteCount)
|
||||
CheckFlowControlViolation() bool
|
||||
}
|
||||
|
||||
// A FlowControlManager manages the flow control
|
||||
type FlowControlManager interface {
|
||||
NewStream(streamID protocol.StreamID, contributesToConnectionFlow bool)
|
||||
|
||||
Reference in New Issue
Block a user