Skip to content

Commit 379916d

Browse files
committed
Add Dropped field for monitoring
1 parent 2d3771f commit 379916d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

ringchan.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package ringchan
33
type Ring[T any] struct {
44
// C is the channel to receive values from.
55
C <-chan T
6+
7+
// Number of dropped items due to full buffer.
8+
Dropped int
69
}
710

811
// New creates a ring-buffered channel with fixed capacity from incoming channel.
@@ -29,6 +32,7 @@ func New[T any](in <-chan T, size int) *Ring[T] {
2932
default:
3033
out <- v
3134
}
35+
rc.Dropped++
3236
}
3337
}
3438
}()

0 commit comments

Comments
 (0)