From c29276ef67a33c76317fe452161f3a723ff88828 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 27 Aug 2022 13:08:48 +0300 Subject: [PATCH] expose the Null{Connection}Tracer as types, not as variables --- logging/null_tracer.go | 77 ++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/logging/null_tracer.go b/logging/null_tracer.go index ff789f79d..4e0bb60ba 100644 --- a/logging/null_tracer.go +++ b/logging/null_tracer.go @@ -6,52 +6,47 @@ import ( "time" ) -var ( - // The NullTracer is a Tracer that does nothing. - // It is useful for embedding. Don't modify this variable! - NullTracer Tracer = &nullTracer{} - // The NullConnectionTracer is a ConnectionTracer that does nothing. - // It is useful for embedding. Don't modify this variable! - NullConnectionTracer ConnectionTracer = &nullConnectionTracer{} -) +// The NullTracer is a Tracer that does nothing. +// It is useful for embedding. +type NullTracer struct{} -type nullTracer struct{} - -func (n nullTracer) TracerForConnection(context.Context, Perspective, ConnectionID) ConnectionTracer { - return NullConnectionTracer +func (n NullTracer) TracerForConnection(context.Context, Perspective, ConnectionID) ConnectionTracer { + return NullConnectionTracer{} } -func (n nullTracer) SentPacket(net.Addr, *Header, ByteCount, []Frame) {} -func (n nullTracer) DroppedPacket(net.Addr, PacketType, ByteCount, PacketDropReason) {} +func (n NullTracer) SentPacket(net.Addr, *Header, ByteCount, []Frame) {} +func (n NullTracer) DroppedPacket(net.Addr, PacketType, ByteCount, PacketDropReason) {} -type nullConnectionTracer struct{} +// The NullConnectionTracer is a ConnectionTracer that does nothing. +// It is useful for embedding. +type NullConnectionTracer struct{} -func (n nullConnectionTracer) StartedConnection(local, remote net.Addr, srcConnID, destConnID ConnectionID) { +func (n NullConnectionTracer) StartedConnection(local, remote net.Addr, srcConnID, destConnID ConnectionID) { } -func (n nullConnectionTracer) NegotiatedVersion(chosen VersionNumber, clientVersions, serverVersions []VersionNumber) { +func (n NullConnectionTracer) NegotiatedVersion(chosen VersionNumber, clientVersions, serverVersions []VersionNumber) { } -func (n nullConnectionTracer) ClosedConnection(err error) {} -func (n nullConnectionTracer) SentTransportParameters(*TransportParameters) {} -func (n nullConnectionTracer) ReceivedTransportParameters(*TransportParameters) {} -func (n nullConnectionTracer) RestoredTransportParameters(*TransportParameters) {} -func (n nullConnectionTracer) SentPacket(*ExtendedHeader, ByteCount, *AckFrame, []Frame) {} -func (n nullConnectionTracer) ReceivedVersionNegotiationPacket(*Header, []VersionNumber) {} -func (n nullConnectionTracer) ReceivedRetry(*Header) {} -func (n nullConnectionTracer) ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame) {} -func (n nullConnectionTracer) BufferedPacket(PacketType) {} -func (n nullConnectionTracer) DroppedPacket(PacketType, ByteCount, PacketDropReason) {} -func (n nullConnectionTracer) UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int) { +func (n NullConnectionTracer) ClosedConnection(err error) {} +func (n NullConnectionTracer) SentTransportParameters(*TransportParameters) {} +func (n NullConnectionTracer) ReceivedTransportParameters(*TransportParameters) {} +func (n NullConnectionTracer) RestoredTransportParameters(*TransportParameters) {} +func (n NullConnectionTracer) SentPacket(*ExtendedHeader, ByteCount, *AckFrame, []Frame) {} +func (n NullConnectionTracer) ReceivedVersionNegotiationPacket(*Header, []VersionNumber) {} +func (n NullConnectionTracer) ReceivedRetry(*Header) {} +func (n NullConnectionTracer) ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame) {} +func (n NullConnectionTracer) BufferedPacket(PacketType) {} +func (n NullConnectionTracer) DroppedPacket(PacketType, ByteCount, PacketDropReason) {} +func (n NullConnectionTracer) UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int) { } -func (n nullConnectionTracer) AcknowledgedPacket(EncryptionLevel, PacketNumber) {} -func (n nullConnectionTracer) LostPacket(EncryptionLevel, PacketNumber, PacketLossReason) {} -func (n nullConnectionTracer) UpdatedCongestionState(CongestionState) {} -func (n nullConnectionTracer) UpdatedPTOCount(uint32) {} -func (n nullConnectionTracer) UpdatedKeyFromTLS(EncryptionLevel, Perspective) {} -func (n nullConnectionTracer) UpdatedKey(keyPhase KeyPhase, remote bool) {} -func (n nullConnectionTracer) DroppedEncryptionLevel(EncryptionLevel) {} -func (n nullConnectionTracer) DroppedKey(KeyPhase) {} -func (n nullConnectionTracer) SetLossTimer(TimerType, EncryptionLevel, time.Time) {} -func (n nullConnectionTracer) LossTimerExpired(timerType TimerType, level EncryptionLevel) {} -func (n nullConnectionTracer) LossTimerCanceled() {} -func (n nullConnectionTracer) Close() {} -func (n nullConnectionTracer) Debug(name, msg string) {} +func (n NullConnectionTracer) AcknowledgedPacket(EncryptionLevel, PacketNumber) {} +func (n NullConnectionTracer) LostPacket(EncryptionLevel, PacketNumber, PacketLossReason) {} +func (n NullConnectionTracer) UpdatedCongestionState(CongestionState) {} +func (n NullConnectionTracer) UpdatedPTOCount(uint32) {} +func (n NullConnectionTracer) UpdatedKeyFromTLS(EncryptionLevel, Perspective) {} +func (n NullConnectionTracer) UpdatedKey(keyPhase KeyPhase, remote bool) {} +func (n NullConnectionTracer) DroppedEncryptionLevel(EncryptionLevel) {} +func (n NullConnectionTracer) DroppedKey(KeyPhase) {} +func (n NullConnectionTracer) SetLossTimer(TimerType, EncryptionLevel, time.Time) {} +func (n NullConnectionTracer) LossTimerExpired(timerType TimerType, level EncryptionLevel) {} +func (n NullConnectionTracer) LossTimerCanceled() {} +func (n NullConnectionTracer) Close() {} +func (n NullConnectionTracer) Debug(name, msg string) {}