make the logging.Tracer and logging.ConnectionTracer a struct (#4082)

This commit is contained in:
Marten Seemann 2023-09-16 18:58:51 +07:00 committed by GitHub
parent d8cc4cb3ef
commit 9b82196578
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 1388 additions and 1158 deletions

View file

@ -0,0 +1,51 @@
//go:build gomock || generate
package mocklogging
import (
"net"
"time"
"github.com/quic-go/quic-go/logging"
)
//go:generate sh -c "go run go.uber.org/mock/mockgen -build_flags=\"-tags=gomock\" -package internal -destination internal/tracer.go github.com/quic-go/quic-go/internal/mocks/logging Tracer"
type Tracer interface {
SentPacket(net.Addr, *logging.Header, logging.ByteCount, []logging.Frame)
SentVersionNegotiationPacket(_ net.Addr, dest, src logging.ArbitraryLenConnectionID, _ []logging.VersionNumber)
DroppedPacket(net.Addr, logging.PacketType, logging.ByteCount, logging.PacketDropReason)
}
//go:generate sh -c "go run go.uber.org/mock/mockgen -build_flags=\"-tags=gomock\" -package internal -destination internal/connection_tracer.go github.com/quic-go/quic-go/internal/mocks/logging ConnectionTracer"
type ConnectionTracer interface {
StartedConnection(local, remote net.Addr, srcConnID, destConnID logging.ConnectionID)
NegotiatedVersion(chosen logging.VersionNumber, clientVersions, serverVersions []logging.VersionNumber)
ClosedConnection(error)
SentTransportParameters(*logging.TransportParameters)
ReceivedTransportParameters(*logging.TransportParameters)
RestoredTransportParameters(parameters *logging.TransportParameters) // for 0-RTT
SentLongHeaderPacket(*logging.ExtendedHeader, logging.ByteCount, logging.ECN, *logging.AckFrame, []logging.Frame)
SentShortHeaderPacket(*logging.ShortHeader, logging.ByteCount, logging.ECN, *logging.AckFrame, []logging.Frame)
ReceivedVersionNegotiationPacket(dest, src logging.ArbitraryLenConnectionID, _ []logging.VersionNumber)
ReceivedRetry(*logging.Header)
ReceivedLongHeaderPacket(*logging.ExtendedHeader, logging.ByteCount, logging.ECN, []logging.Frame)
ReceivedShortHeaderPacket(*logging.ShortHeader, logging.ByteCount, logging.ECN, []logging.Frame)
BufferedPacket(logging.PacketType, logging.ByteCount)
DroppedPacket(logging.PacketType, logging.ByteCount, logging.PacketDropReason)
UpdatedMetrics(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int)
AcknowledgedPacket(logging.EncryptionLevel, logging.PacketNumber)
LostPacket(logging.EncryptionLevel, logging.PacketNumber, logging.PacketLossReason)
UpdatedCongestionState(logging.CongestionState)
UpdatedPTOCount(value uint32)
UpdatedKeyFromTLS(logging.EncryptionLevel, logging.Perspective)
UpdatedKey(generation logging.KeyPhase, remote bool)
DroppedEncryptionLevel(logging.EncryptionLevel)
DroppedKey(generation logging.KeyPhase)
SetLossTimer(logging.TimerType, logging.EncryptionLevel, time.Time)
LossTimerExpired(logging.TimerType, logging.EncryptionLevel)
LossTimerCanceled()
ECNStateUpdated(state logging.ECNState, trigger logging.ECNStateTrigger)
// Close is called when the connection is closed.
Close()
Debug(name, msg string)
}