Re-vendor the shared files from sneak/prompts at dd4027b (closes #52)
check / check (push) Waiting to run

Takes .golangci.yml, .dockerignore, .gitignore, .editorconfig, the
workflow and REPO_POLICIES.md from sneak/prompts dd4027b, keeping this
repository's own entries after the shared content. Lint (golangci-lint
v2.14.0) and test become Dockerfile phases that script/lint and
script/test build alone and uncached; the image build depends on both,
and script/cibuild bootstraps, runs script/check, then builds the image.
The agent guidance file moves to AGENTS.md. The Go code is fixed for
what the new configuration finds; reads that iterate rows now also
report an iteration error.

Model: opus-5-5
This commit is contained in:
2026-10-14 19:11:06 +00:00
parent e0b9c2685f
commit 29d3f30d23
58 changed files with 4113 additions and 2750 deletions
+10 -4
View File
@@ -64,6 +64,7 @@ func New() *Tracker {
// first counts one reconnect.
func (t *Tracker) SetConnected(connected bool) {
t.isConnected.Store(connected)
if !connected {
return
}
@@ -120,9 +121,11 @@ func (t *Tracker) GetStreamMetrics() StreamMetrics {
if msgCount >= 0 {
totalMessages = uint64(msgCount)
}
if byteCount >= 0 {
totalBytes = uint64(byteCount)
}
if wireByteCount >= 0 {
totalWireBytes = uint64(wireByteCount)
}
@@ -166,7 +169,7 @@ func (t *Tracker) RecordWithdrawal() {
func (t *Tracker) SetBGPPeerCount(count int) {
// BGP peer count is always small (< 1000), so int32 is safe
if count > 0 && count < 1<<31 {
t.bgpPeerCount.Store(int32(count)) //nolint:gosec // count is validated
t.bgpPeerCount.Store(int32(count))
}
}
@@ -214,7 +217,8 @@ type StreamMetrics struct {
TotalMessages uint64
// TotalBytes is the total number of decompressed bytes received since startup
TotalBytes uint64
// TotalWireBytes is the total number of bytes received on the wire (before decompression)
// TotalWireBytes is the total number of bytes received on the wire (before
// decompression)
TotalWireBytes uint64
// ConnectedSince is the time when the current connection was established
ConnectedSince time.Time
@@ -222,9 +226,11 @@ type StreamMetrics struct {
Connected bool
// MessagesPerSec is the rate of messages received per second (1-minute average)
MessagesPerSec float64
// BitsPerSec is the rate of decompressed bits received per second (1-minute average)
// BitsPerSec is the rate of decompressed bits received per second (1-minute
// average)
BitsPerSec float64
// WireBitsPerSec is the rate of bits received on the wire per second (1-minute average)
// WireBitsPerSec is the rate of bits received on the wire per second
// (1-minute average)
WireBitsPerSec float64
// ReconnectCount is the number of reconnections since startup
ReconnectCount uint64
+9 -3
View File
@@ -1,12 +1,18 @@
package metrics
package metrics_test
import "testing"
import (
"testing"
"git.eeqj.de/sneak/routewatch/internal/metrics"
)
// TestReconnectCount connects three times with a disconnect between each, the
// way the streamer does, and expects every connection after the first to count
// one reconnect.
func TestReconnectCount(t *testing.T) {
tracker := New()
t.Parallel()
tracker := metrics.New()
tracker.SetConnected(true)
tracker.SetConnected(false)