introduce an interface for the send queue, use a mock in session tests

This commit is contained in:
Marten Seemann 2020-12-31 13:34:34 +08:00
parent e9848fadf9
commit f1c6421845
6 changed files with 117 additions and 22 deletions

View file

@ -1,5 +1,11 @@
package quic
type sender interface {
Send(p *packetBuffer)
Run() error
Close()
}
type sendQueue struct {
queue chan *packetBuffer
closeCalled chan struct{} // runStopped when Close() is called
@ -7,7 +13,9 @@ type sendQueue struct {
conn sendConn
}
func newSendQueue(conn sendConn) *sendQueue {
var _ sender = &sendQueue{}
func newSendQueue(conn sendConn) sender {
s := &sendQueue{
conn: conn,
runStopped: make(chan struct{}),