rename the cryptoStreamI interface to cryptoStream

This commit is contained in:
Marten Seemann 2018-08-11 12:24:51 +07:00
parent 40050f558d
commit 04147d86da
9 changed files with 20 additions and 20 deletions

View file

@ -8,7 +8,7 @@ import (
"github.com/lucas-clemente/quic-go/internal/wire" "github.com/lucas-clemente/quic-go/internal/wire"
) )
type cryptoStreamI interface { type cryptoStream interface {
StreamID() protocol.StreamID StreamID() protocol.StreamID
io.Reader io.Reader
io.Writer io.Writer
@ -21,21 +21,21 @@ type cryptoStreamI interface {
handleMaxStreamDataFrame(*wire.MaxStreamDataFrame) handleMaxStreamDataFrame(*wire.MaxStreamDataFrame)
} }
type cryptoStream struct { type cryptoStreamImpl struct {
*stream *stream
} }
var _ cryptoStreamI = &cryptoStream{} var _ cryptoStream = &cryptoStreamImpl{}
func newCryptoStream(sender streamSender, flowController flowcontrol.StreamFlowController, version protocol.VersionNumber) cryptoStreamI { func newCryptoStream(sender streamSender, flowController flowcontrol.StreamFlowController, version protocol.VersionNumber) cryptoStream {
str := newStream(version.CryptoStreamID(), sender, flowController, version) str := newStream(version.CryptoStreamID(), sender, flowController, version)
return &cryptoStream{str} return &cryptoStreamImpl{str}
} }
// SetReadOffset sets the read offset. // SetReadOffset sets the read offset.
// It is only needed for the crypto stream. // It is only needed for the crypto stream.
// It must not be called concurrently with any other stream methods, especially Read and Write. // It must not be called concurrently with any other stream methods, especially Read and Write.
func (s *cryptoStream) setReadOffset(offset protocol.ByteCount) { func (s *cryptoStreamImpl) setReadOffset(offset protocol.ByteCount) {
s.receiveStream.readOffset = offset s.receiveStream.readOffset = offset
s.receiveStream.frameQueue.readPosition = offset s.receiveStream.frameQueue.readPosition = offset
} }

View file

@ -9,13 +9,13 @@ import (
var _ = Describe("Crypto Stream", func() { var _ = Describe("Crypto Stream", func() {
var ( var (
str *cryptoStream str *cryptoStreamImpl
mockSender *MockStreamSender mockSender *MockStreamSender
) )
BeforeEach(func() { BeforeEach(func() {
mockSender = NewMockStreamSender(mockCtrl) mockSender = NewMockStreamSender(mockCtrl)
str = newCryptoStream(mockSender, nil, protocol.VersionWhatever).(*cryptoStream) str = newCryptoStream(mockSender, nil, protocol.VersionWhatever).(*cryptoStreamImpl)
}) })
It("sets the read offset", func() { It("sets the read offset", func() {

View file

@ -220,9 +220,9 @@ func (mr *MockQuicSessionMockRecorder) destroy(arg0 interface{}) *gomock.Call {
} }
// getCryptoStream mocks base method // getCryptoStream mocks base method
func (m *MockQuicSession) getCryptoStream() cryptoStreamI { func (m *MockQuicSession) getCryptoStream() cryptoStream {
ret := m.ctrl.Call(m, "getCryptoStream") ret := m.ctrl.Call(m, "getCryptoStream")
ret0, _ := ret[0].(cryptoStreamI) ret0, _ := ret[0].(cryptoStream)
return ret0 return ret0
} }

View file

@ -6,7 +6,7 @@ package quic
//go:generate sh -c "./mockgen_private.sh quic mock_stream_sender_test.go github.com/lucas-clemente/quic-go streamSender StreamSender" //go:generate sh -c "./mockgen_private.sh quic mock_stream_sender_test.go github.com/lucas-clemente/quic-go streamSender StreamSender"
//go:generate sh -c "./mockgen_private.sh quic mock_stream_getter_test.go github.com/lucas-clemente/quic-go streamGetter StreamGetter" //go:generate sh -c "./mockgen_private.sh quic mock_stream_getter_test.go github.com/lucas-clemente/quic-go streamGetter StreamGetter"
//go:generate sh -c "./mockgen_private.sh quic mock_stream_frame_source_test.go github.com/lucas-clemente/quic-go streamFrameSource StreamFrameSource" //go:generate sh -c "./mockgen_private.sh quic mock_stream_frame_source_test.go github.com/lucas-clemente/quic-go streamFrameSource StreamFrameSource"
//go:generate sh -c "./mockgen_private.sh quic mock_crypto_stream_test.go github.com/lucas-clemente/quic-go cryptoStreamI CryptoStream" //go:generate sh -c "./mockgen_private.sh quic mock_crypto_stream_test.go github.com/lucas-clemente/quic-go cryptoStream CryptoStream"
//go:generate sh -c "./mockgen_private.sh quic mock_stream_manager_test.go github.com/lucas-clemente/quic-go streamManager StreamManager" //go:generate sh -c "./mockgen_private.sh quic mock_stream_manager_test.go github.com/lucas-clemente/quic-go streamManager StreamManager"
//go:generate sh -c "./mockgen_private.sh quic mock_unpacker_test.go github.com/lucas-clemente/quic-go unpacker Unpacker" //go:generate sh -c "./mockgen_private.sh quic mock_unpacker_test.go github.com/lucas-clemente/quic-go unpacker Unpacker"
//go:generate sh -c "./mockgen_private.sh quic mock_quic_aead_test.go github.com/lucas-clemente/quic-go quicAEAD QuicAEAD" //go:generate sh -c "./mockgen_private.sh quic mock_quic_aead_test.go github.com/lucas-clemente/quic-go quicAEAD QuicAEAD"

View file

@ -39,7 +39,7 @@ type packetHandlerManager interface {
type quicSession interface { type quicSession interface {
Session Session
handlePacket(*receivedPacket) handlePacket(*receivedPacket)
getCryptoStream() cryptoStreamI getCryptoStream() cryptoStream
GetVersion() protocol.VersionNumber GetVersion() protocol.VersionNumber
run() error run() error
destroy(error) destroy(error)

View file

@ -86,7 +86,7 @@ type session struct {
conn connection conn connection
streamsMap streamManager streamsMap streamManager
cryptoStream cryptoStreamI cryptoStream cryptoStream
rttStats *congestion.RTTStats rttStats *congestion.RTTStats
@ -1188,7 +1188,7 @@ func (s *session) newFlowController(id protocol.StreamID) flowcontrol.StreamFlow
) )
} }
func (s *session) newCryptoStream() cryptoStreamI { func (s *session) newCryptoStream() cryptoStream {
id := s.version.CryptoStreamID() id := s.version.CryptoStreamID()
flowController := flowcontrol.NewStreamFlowController( flowController := flowcontrol.NewStreamFlowController(
id, id,
@ -1276,7 +1276,7 @@ func (s *session) RemoteAddr() net.Addr {
return s.conn.RemoteAddr() return s.conn.RemoteAddr()
} }
func (s *session) getCryptoStream() cryptoStreamI { func (s *session) getCryptoStream() cryptoStream {
return s.cryptoStream return s.cryptoStream
} }

View file

@ -345,7 +345,7 @@ var _ = Describe("Session", func() {
fc := mocks.NewMockStreamFlowController(mockCtrl) fc := mocks.NewMockStreamFlowController(mockCtrl)
offset := protocol.ByteCount(0x4321) offset := protocol.ByteCount(0x4321)
fc.EXPECT().UpdateSendWindow(offset) fc.EXPECT().UpdateSendWindow(offset)
sess.cryptoStream.(*cryptoStream).sendStream.flowController = fc sess.cryptoStream.(*cryptoStreamImpl).sendStream.flowController = fc
err := sess.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{ err := sess.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{
StreamID: sess.version.CryptoStreamID(), StreamID: sess.version.CryptoStreamID(),
ByteOffset: offset, ByteOffset: offset,

View file

@ -9,7 +9,7 @@ import (
type streamFramer struct { type streamFramer struct {
streamGetter streamGetter streamGetter streamGetter
cryptoStream cryptoStreamI cryptoStream cryptoStream
version protocol.VersionNumber version protocol.VersionNumber
streamQueueMutex sync.Mutex streamQueueMutex sync.Mutex
@ -19,7 +19,7 @@ type streamFramer struct {
} }
func newStreamFramer( func newStreamFramer(
cryptoStream cryptoStreamI, cryptoStream cryptoStream,
streamGetter streamGetter, streamGetter streamGetter,
v protocol.VersionNumber, v protocol.VersionNumber,
) *streamFramer { ) *streamFramer {

View file

@ -14,7 +14,7 @@ type windowUpdateQueue struct {
queue map[protocol.StreamID]bool // used as a set queue map[protocol.StreamID]bool // used as a set
queuedConn bool // connection-level window update queuedConn bool // connection-level window update
cryptoStream cryptoStreamI cryptoStream cryptoStream
streamGetter streamGetter streamGetter streamGetter
connFlowController flowcontrol.ConnectionFlowController connFlowController flowcontrol.ConnectionFlowController
callback func(wire.Frame) callback func(wire.Frame)
@ -22,7 +22,7 @@ type windowUpdateQueue struct {
func newWindowUpdateQueue( func newWindowUpdateQueue(
streamGetter streamGetter, streamGetter streamGetter,
cryptoStream cryptoStreamI, cryptoStream cryptoStream,
connFC flowcontrol.ConnectionFlowController, connFC flowcontrol.ConnectionFlowController,
cb func(wire.Frame), cb func(wire.Frame),
) *windowUpdateQueue { ) *windowUpdateQueue {