-
Notifications
You must be signed in to change notification settings - Fork 173
/
stats.go
32 lines (26 loc) · 975 Bytes
/
stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Package transport provides long-lived http/tcp connections for
// intra-cluster communications (see README for details and usage example).
/*
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
*/
package transport
import (
"github.com/NVIDIA/aistore/cmn/atomic"
)
// stream (session) stats
type Stats struct {
Num atomic.Int64 // number of transferred objects including zero size (header-only) objects
Size atomic.Int64 // transferred object size (does not include transport headers)
Offset atomic.Int64 // stream offset, in bytes
CompressedSize atomic.Int64 // compressed size (converges to the actual compressed size over time)
}
type nopRxStats struct{}
// interface guard
var (
_ rxStats = (*Stats)(nil)
_ rxStats = (*nopRxStats)(nil)
)
func (s *Stats) addOff(o int64) { s.Offset.Add(o) }
func (s *Stats) incNum() { s.Num.Inc() }
func (nopRxStats) addOff(int64) {}
func (nopRxStats) incNum() {}