Skip to content

Commit 23f24a1

Browse files
committed
Rename ConnStats to StatsConn
1 parent 6097f6d commit 23f24a1

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

agent/agent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (a *agent) runTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) {
205205
if listenerExists {
206206
return conn
207207
}
208-
return &ConnStats{ProtocolStats: &ProtocolStats{}, Conn: conn}
208+
return &StatsConn{ProtocolStats: &ProtocolStats{}, Conn: conn}
209209
})
210210
go a.runCoordinator(ctx)
211211

agent/stats.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ import (
1010
"cdr.dev/slog"
1111
)
1212

13-
// ConnStats wraps a net.Conn with statistics.
14-
type ConnStats struct {
13+
// StatsConn wraps a net.Conn with statistics.
14+
type StatsConn struct {
1515
*ProtocolStats
1616
net.Conn `json:"-"`
1717
}
1818

19-
var _ net.Conn = new(ConnStats)
19+
var _ net.Conn = new(StatsConn)
2020

21-
func (c *ConnStats) Read(b []byte) (n int, err error) {
21+
func (c *StatsConn) Read(b []byte) (n int, err error) {
2222
n, err = c.Conn.Read(b)
2323
atomic.AddInt64(&c.RxBytes, int64(n))
2424
return n, err
2525
}
2626

27-
func (c *ConnStats) Write(b []byte) (n int, err error) {
27+
func (c *StatsConn) Write(b []byte) (n int, err error) {
2828
n, err = c.Conn.Write(b)
2929
atomic.AddInt64(&c.TxBytes, int64(n))
3030
return n, err
@@ -40,7 +40,7 @@ type ProtocolStats struct {
4040
TxBytes int64 `json:"tx_bytes"`
4141
}
4242

43-
var _ net.Conn = new(ConnStats)
43+
var _ net.Conn = new(StatsConn)
4444

4545
// Stats records the Agent's network connection statistics for use in
4646
// user-facing metrics and debugging.
@@ -74,7 +74,7 @@ func (s *Stats) wrapConn(conn net.Conn, protocol string) net.Conn {
7474
s.Unlock()
7575

7676
atomic.AddInt64(&ps.NumConns, 1)
77-
cs := &ConnStats{
77+
cs := &StatsConn{
7878
ProtocolStats: ps,
7979
Conn: conn,
8080
}

agent/stats_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestConnStats(t *testing.T) {
2020
c1, c2 := net.Pipe()
2121

2222
payload := []byte("dogs & cats")
23-
statsConn := &agent.ConnStats{Conn: c1, ProtocolStats: &agent.ProtocolStats{}}
23+
statsConn := &agent.StatsConn{Conn: c1, ProtocolStats: &agent.ProtocolStats{}}
2424

2525
got := make(chan []byte)
2626
go func() {
@@ -44,7 +44,7 @@ func TestConnStats(t *testing.T) {
4444
c1, c2 := net.Pipe()
4545

4646
payload := []byte("cats & dogs")
47-
statsConn := &agent.ConnStats{Conn: c1, ProtocolStats: &agent.ProtocolStats{}}
47+
statsConn := &agent.StatsConn{Conn: c1, ProtocolStats: &agent.ProtocolStats{}}
4848

4949
go func() {
5050
c2.Write(payload)

0 commit comments

Comments
 (0)