rename StreamDataBlockedFrame.DataLimit to MaximumStreamData

This commit is contained in:
Marten Seemann 2020-07-02 16:28:23 +07:00
parent fa07078d81
commit cc340b2887
10 changed files with 31 additions and 31 deletions

View file

@ -171,12 +171,12 @@ func getFrames() []wire.Frame {
MaximumData: protocol.MaxByteCount, MaximumData: protocol.MaxByteCount,
}, },
&wire.StreamDataBlockedFrame{ &wire.StreamDataBlockedFrame{
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),
DataLimit: protocol.ByteCount(getRandomNumber()), MaximumStreamData: protocol.ByteCount(getRandomNumber()),
}, },
&wire.StreamDataBlockedFrame{ &wire.StreamDataBlockedFrame{
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),
DataLimit: protocol.MaxByteCount, MaximumStreamData: protocol.MaxByteCount,
}, },
&wire.StreamsBlockedFrame{ &wire.StreamsBlockedFrame{
Type: protocol.StreamTypeUni, Type: protocol.StreamTypeUni,

View file

@ -191,8 +191,8 @@ var _ = Describe("Frame parsing", func() {
It("unpacks STREAM_DATA_BLOCKED frames", func() { It("unpacks STREAM_DATA_BLOCKED frames", func() {
f := &StreamDataBlockedFrame{ f := &StreamDataBlockedFrame{
StreamID: 0xdeadbeef, StreamID: 0xdeadbeef,
DataLimit: 0xdead, MaximumStreamData: 0xdead,
} }
err := f.Write(buf, versionIETFFrames) err := f.Write(buf, versionIETFFrames)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())

View file

@ -42,7 +42,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) {
case *DataBlockedFrame: case *DataBlockedFrame:
logger.Debugf("\t%s &wire.DataBlockedFrame{MaximumData: %d}", dir, f.MaximumData) logger.Debugf("\t%s &wire.DataBlockedFrame{MaximumData: %d}", dir, f.MaximumData)
case *StreamDataBlockedFrame: case *StreamDataBlockedFrame:
logger.Debugf("\t%s &wire.StreamDataBlockedFrame{StreamID: %d, DataLimit: %d}", dir, f.StreamID, f.DataLimit) logger.Debugf("\t%s &wire.StreamDataBlockedFrame{StreamID: %d, MaximumStreamData: %d}", dir, f.StreamID, f.MaximumStreamData)
case *MaxStreamsFrame: case *MaxStreamsFrame:
switch f.Type { switch f.Type {
case protocol.StreamTypeUni: case protocol.StreamTypeUni:

View file

@ -123,11 +123,11 @@ var _ = Describe("Frame logging", func() {
It("logs STREAM_DATA_BLOCKED frames", func() { It("logs STREAM_DATA_BLOCKED frames", func() {
frame := &StreamDataBlockedFrame{ frame := &StreamDataBlockedFrame{
StreamID: 42, StreamID: 42,
DataLimit: 1000, MaximumStreamData: 1000,
} }
LogFrame(logger, frame, false) LogFrame(logger, frame, false)
Expect(buf.String()).To(ContainSubstring("\t<- &wire.StreamDataBlockedFrame{StreamID: 42, DataLimit: 1000}\n")) Expect(buf.String()).To(ContainSubstring("\t<- &wire.StreamDataBlockedFrame{StreamID: 42, MaximumStreamData: 1000}\n"))
}) })
It("logs STREAMS_BLOCKED frames", func() { It("logs STREAMS_BLOCKED frames", func() {

View file

@ -9,8 +9,8 @@ import (
// A StreamDataBlockedFrame is a STREAM_DATA_BLOCKED frame // A StreamDataBlockedFrame is a STREAM_DATA_BLOCKED frame
type StreamDataBlockedFrame struct { type StreamDataBlockedFrame struct {
StreamID protocol.StreamID StreamID protocol.StreamID
DataLimit protocol.ByteCount MaximumStreamData protocol.ByteCount
} }
func parseStreamDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*StreamDataBlockedFrame, error) { func parseStreamDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*StreamDataBlockedFrame, error) {
@ -28,19 +28,19 @@ func parseStreamDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*St
} }
return &StreamDataBlockedFrame{ return &StreamDataBlockedFrame{
StreamID: protocol.StreamID(sid), StreamID: protocol.StreamID(sid),
DataLimit: protocol.ByteCount(offset), MaximumStreamData: protocol.ByteCount(offset),
}, nil }, nil
} }
func (f *StreamDataBlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { func (f *StreamDataBlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
b.WriteByte(0x15) b.WriteByte(0x15)
utils.WriteVarInt(b, uint64(f.StreamID)) utils.WriteVarInt(b, uint64(f.StreamID))
utils.WriteVarInt(b, uint64(f.DataLimit)) utils.WriteVarInt(b, uint64(f.MaximumStreamData))
return nil return nil
} }
// Length of a written frame // Length of a written frame
func (f *StreamDataBlockedFrame) Length(version protocol.VersionNumber) protocol.ByteCount { func (f *StreamDataBlockedFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.DataLimit)) return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.MaximumStreamData))
} }

View file

@ -20,7 +20,7 @@ var _ = Describe("STREAM_DATA_BLOCKED frame", func() {
frame, err := parseStreamDataBlockedFrame(b, versionIETFFrames) frame, err := parseStreamDataBlockedFrame(b, versionIETFFrames)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef))) Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef)))
Expect(frame.DataLimit).To(Equal(protocol.ByteCount(0xdecafbad))) Expect(frame.MaximumStreamData).To(Equal(protocol.ByteCount(0xdecafbad)))
Expect(b.Len()).To(BeZero()) Expect(b.Len()).To(BeZero())
}) })
@ -40,8 +40,8 @@ var _ = Describe("STREAM_DATA_BLOCKED frame", func() {
Context("writing", func() { Context("writing", func() {
It("has proper min length", func() { It("has proper min length", func() {
f := &StreamDataBlockedFrame{ f := &StreamDataBlockedFrame{
StreamID: 0x1337, StreamID: 0x1337,
DataLimit: 0xdeadbeef, MaximumStreamData: 0xdeadbeef,
} }
Expect(f.Length(0)).To(Equal(1 + utils.VarIntLen(0x1337) + utils.VarIntLen(0xdeadbeef))) Expect(f.Length(0)).To(Equal(1 + utils.VarIntLen(0x1337) + utils.VarIntLen(0xdeadbeef)))
}) })
@ -49,14 +49,14 @@ var _ = Describe("STREAM_DATA_BLOCKED frame", func() {
It("writes a sample frame", func() { It("writes a sample frame", func() {
b := &bytes.Buffer{} b := &bytes.Buffer{}
f := &StreamDataBlockedFrame{ f := &StreamDataBlockedFrame{
StreamID: 0xdecafbad, StreamID: 0xdecafbad,
DataLimit: 0x1337, MaximumStreamData: 0x1337,
} }
err := f.Write(b, versionIETFFrames) err := f.Write(b, versionIETFFrames)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
expected := []byte{0x15} expected := []byte{0x15}
expected = append(expected, encodeVarInt(uint64(f.StreamID))...) expected = append(expected, encodeVarInt(uint64(f.StreamID))...)
expected = append(expected, encodeVarInt(uint64(f.DataLimit))...) expected = append(expected, encodeVarInt(uint64(f.MaximumStreamData))...)
Expect(b.Bytes()).To(Equal(expected)) Expect(b.Bytes()).To(Equal(expected))
}) })
}) })

View file

@ -196,7 +196,7 @@ func marshalDataBlockedFrame(enc *gojay.Encoder, f *wire.DataBlockedFrame) {
func marshalStreamDataBlockedFrame(enc *gojay.Encoder, f *wire.StreamDataBlockedFrame) { func marshalStreamDataBlockedFrame(enc *gojay.Encoder, f *wire.StreamDataBlockedFrame) {
enc.StringKey("frame_type", "stream_data_blocked") enc.StringKey("frame_type", "stream_data_blocked")
enc.Int64Key("stream_id", int64(f.StreamID)) enc.Int64Key("stream_id", int64(f.StreamID))
enc.Int64Key("limit", int64(f.DataLimit)) enc.Int64Key("limit", int64(f.MaximumStreamData))
} }
func marshalStreamsBlockedFrame(enc *gojay.Encoder, f *wire.StreamsBlockedFrame) { func marshalStreamsBlockedFrame(enc *gojay.Encoder, f *wire.StreamsBlockedFrame) {

View file

@ -227,8 +227,8 @@ var _ = Describe("Frames", func() {
It("marshals STREAM_DATA_BLOCKED frames", func() { It("marshals STREAM_DATA_BLOCKED frames", func() {
check( check(
&wire.StreamDataBlockedFrame{ &wire.StreamDataBlockedFrame{
StreamID: 42, StreamID: 42,
DataLimit: 1337, MaximumStreamData: 1337,
}, },
map[string]interface{}{ map[string]interface{}{
"frame_type": "stream_data_blocked", "frame_type": "stream_data_blocked",

View file

@ -242,8 +242,8 @@ func (s *sendStream) popNewOrRetransmittedStreamFrame(maxBytes protocol.ByteCoun
if sendWindow == 0 { if sendWindow == 0 {
if isBlocked, offset := s.flowController.IsNewlyBlocked(); isBlocked { if isBlocked, offset := s.flowController.IsNewlyBlocked(); isBlocked {
s.sender.queueControlFrame(&wire.StreamDataBlockedFrame{ s.sender.queueControlFrame(&wire.StreamDataBlockedFrame{
StreamID: s.streamID, StreamID: s.streamID,
DataLimit: offset, MaximumStreamData: offset,
}) })
return nil, false return nil, false
} }

View file

@ -311,8 +311,8 @@ var _ = Describe("Send Stream", func() {
mockFC.EXPECT().SendWindowSize().Return(protocol.ByteCount(0)) mockFC.EXPECT().SendWindowSize().Return(protocol.ByteCount(0))
mockFC.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(12)) mockFC.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(12))
mockSender.EXPECT().queueControlFrame(&wire.StreamDataBlockedFrame{ mockSender.EXPECT().queueControlFrame(&wire.StreamDataBlockedFrame{
StreamID: streamID, StreamID: streamID,
DataLimit: 12, MaximumStreamData: 12,
}) })
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
@ -354,8 +354,8 @@ var _ = Describe("Send Stream", func() {
// don't use offset 3 here, to make sure the BLOCKED frame contains the number returned by the flow controller // don't use offset 3 here, to make sure the BLOCKED frame contains the number returned by the flow controller
mockFC.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(10)) mockFC.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(10))
mockSender.EXPECT().queueControlFrame(&wire.StreamDataBlockedFrame{ mockSender.EXPECT().queueControlFrame(&wire.StreamDataBlockedFrame{
StreamID: streamID, StreamID: streamID,
DataLimit: 10, MaximumStreamData: 10,
}) })
f, hasMoreData = str.popStreamFrame(1000) f, hasMoreData = str.popStreamFrame(1000)
Expect(f).To(BeNil()) Expect(f).To(BeNil())