mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
logging: add a Close function to the Tracer (#4298)
* logging: add a Close function to the Tracer * close the Tracer when the Transport is closed
This commit is contained in:
parent
b675e34254
commit
07ec3245bd
8 changed files with 65 additions and 1 deletions
|
@ -41,6 +41,42 @@ func (m *MockTracer) EXPECT() *MockTracerMockRecorder {
|
|||
return m.recorder
|
||||
}
|
||||
|
||||
// Close mocks base method.
|
||||
func (m *MockTracer) Close() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Close")
|
||||
}
|
||||
|
||||
// Close indicates an expected call of Close.
|
||||
func (mr *MockTracerMockRecorder) Close() *TracerCloseCall {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockTracer)(nil).Close))
|
||||
return &TracerCloseCall{Call: call}
|
||||
}
|
||||
|
||||
// TracerCloseCall wrap *gomock.Call
|
||||
type TracerCloseCall struct {
|
||||
*gomock.Call
|
||||
}
|
||||
|
||||
// Return rewrite *gomock.Call.Return
|
||||
func (c *TracerCloseCall) Return() *TracerCloseCall {
|
||||
c.Call = c.Call.Return()
|
||||
return c
|
||||
}
|
||||
|
||||
// Do rewrite *gomock.Call.Do
|
||||
func (c *TracerCloseCall) Do(f func()) *TracerCloseCall {
|
||||
c.Call = c.Call.Do(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// DoAndReturn rewrite *gomock.Call.DoAndReturn
|
||||
func (c *TracerCloseCall) DoAndReturn(f func()) *TracerCloseCall {
|
||||
c.Call = c.Call.DoAndReturn(f)
|
||||
return c
|
||||
}
|
||||
|
||||
// Debug mocks base method.
|
||||
func (m *MockTracer) Debug(arg0, arg1 string) {
|
||||
m.ctrl.T.Helper()
|
||||
|
|
|
@ -15,6 +15,7 @@ type Tracer interface {
|
|||
SentVersionNegotiationPacket(_ net.Addr, dest, src logging.ArbitraryLenConnectionID, _ []logging.VersionNumber)
|
||||
DroppedPacket(net.Addr, logging.PacketType, logging.ByteCount, logging.PacketDropReason)
|
||||
Debug(name, msg string)
|
||||
Close()
|
||||
}
|
||||
|
||||
//go:generate sh -c "go run go.uber.org/mock/mockgen -typed -build_flags=\"-tags=gomock\" -package internal -destination internal/connection_tracer.go github.com/quic-go/quic-go/internal/mocks/logging ConnectionTracer"
|
||||
|
|
|
@ -28,5 +28,8 @@ func NewMockTracer(ctrl *gomock.Controller) (*logging.Tracer, *MockTracer) {
|
|||
Debug: func(name, msg string) {
|
||||
t.Debug(name, msg)
|
||||
},
|
||||
Close: func() {
|
||||
t.Close()
|
||||
},
|
||||
}, t
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue