Adopt scripts-to-rule-them-all: script/ entrypoints, Makefile shims
This commit is contained in:
@@ -36,7 +36,6 @@ const (
|
||||
statsWindow = time.Hour
|
||||
)
|
||||
|
||||
|
||||
// ASNFetcher handles background WHOIS lookups for ASNs.
|
||||
type ASNFetcher struct {
|
||||
db database.Store
|
||||
@@ -55,9 +54,9 @@ type ASNFetcher struct {
|
||||
consecutiveFails int
|
||||
|
||||
// hourly stats tracking
|
||||
statsMu sync.Mutex
|
||||
successTimes []time.Time
|
||||
errorTimes []time.Time
|
||||
statsMu sync.Mutex
|
||||
successTimes []time.Time
|
||||
errorTimes []time.Time
|
||||
}
|
||||
|
||||
// NewASNFetcher creates a new ASN fetcher.
|
||||
|
||||
@@ -330,19 +330,19 @@ func (s *Server) handleStats() http.HandlerFunc {
|
||||
|
||||
// GCStats represents garbage collection statistics
|
||||
type GCStats struct {
|
||||
NumGC uint32 `json:"num_gc"`
|
||||
TotalPauseMs uint64 `json:"total_pause_ms"`
|
||||
LastPauseMs float64 `json:"last_pause_ms"`
|
||||
HeapAllocBytes uint64 `json:"heap_alloc_bytes"`
|
||||
HeapSysBytes uint64 `json:"heap_sys_bytes"`
|
||||
NumGC uint32 `json:"num_gc"`
|
||||
TotalPauseMs uint64 `json:"total_pause_ms"`
|
||||
LastPauseMs float64 `json:"last_pause_ms"`
|
||||
HeapAllocBytes uint64 `json:"heap_alloc_bytes"`
|
||||
HeapSysBytes uint64 `json:"heap_sys_bytes"`
|
||||
}
|
||||
|
||||
// StreamStats represents stream statistics including announcements/withdrawals
|
||||
type StreamStats struct {
|
||||
Announcements uint64 `json:"announcements"`
|
||||
Withdrawals uint64 `json:"withdrawals"`
|
||||
RouteChurnPerSec float64 `json:"route_churn_per_sec"`
|
||||
BGPPeerCount int `json:"bgp_peer_count"`
|
||||
Announcements uint64 `json:"announcements"`
|
||||
Withdrawals uint64 `json:"withdrawals"`
|
||||
RouteChurnPerSec float64 `json:"route_churn_per_sec"`
|
||||
BGPPeerCount int `json:"bgp_peer_count"`
|
||||
}
|
||||
|
||||
// StatsResponse represents the API statistics response
|
||||
@@ -499,19 +499,19 @@ func (s *Server) handleStats() http.HandlerFunc {
|
||||
}
|
||||
|
||||
stats := StatsResponse{
|
||||
Uptime: uptime,
|
||||
TotalMessages: metrics.TotalMessages,
|
||||
TotalBytes: metrics.TotalBytes,
|
||||
TotalWireBytes: metrics.TotalWireBytes,
|
||||
MessagesPerSec: metrics.MessagesPerSec,
|
||||
MbitsPerSec: metrics.BitsPerSec / bitsPerMegabit,
|
||||
WireMbitsPerSec: metrics.WireBitsPerSec / bitsPerMegabit,
|
||||
Connected: metrics.Connected,
|
||||
ConnectionDuration: connectionDuration,
|
||||
ReconnectCount: metrics.ReconnectCount,
|
||||
GoVersion: runtime.Version(),
|
||||
Goroutines: runtime.NumGoroutine(),
|
||||
MemoryUsage: humanize.Bytes(memStats.Alloc),
|
||||
Uptime: uptime,
|
||||
TotalMessages: metrics.TotalMessages,
|
||||
TotalBytes: metrics.TotalBytes,
|
||||
TotalWireBytes: metrics.TotalWireBytes,
|
||||
MessagesPerSec: metrics.MessagesPerSec,
|
||||
MbitsPerSec: metrics.BitsPerSec / bitsPerMegabit,
|
||||
WireMbitsPerSec: metrics.WireBitsPerSec / bitsPerMegabit,
|
||||
Connected: metrics.Connected,
|
||||
ConnectionDuration: connectionDuration,
|
||||
ReconnectCount: metrics.ReconnectCount,
|
||||
GoVersion: runtime.Version(),
|
||||
Goroutines: runtime.NumGoroutine(),
|
||||
MemoryUsage: humanize.Bytes(memStats.Alloc),
|
||||
GC: GCStats{
|
||||
NumGC: memStats.NumGC,
|
||||
TotalPauseMs: memStats.PauseTotalNs / uint64(nanosecondsPerMillisecond),
|
||||
|
||||
@@ -112,8 +112,8 @@ type Streamer struct {
|
||||
cancel context.CancelFunc
|
||||
running bool
|
||||
metrics *metrics.Tracker
|
||||
totalDropped uint64 // Total dropped messages across all handlers
|
||||
random *rand.Rand // Random number generator for backpressure drops
|
||||
totalDropped uint64 // Total dropped messages across all handlers
|
||||
random *rand.Rand // Random number generator for backpressure drops
|
||||
bgpPeers map[string]bool // Track active BGP peers by peer IP
|
||||
bgpPeersMu sync.RWMutex // Protects bgpPeers map
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
hoursPerDay = 24
|
||||
daysPerMonth = 30
|
||||
cidrPartCount = 2 // A CIDR has two parts: prefix and length
|
||||
hoursPerDay = 24
|
||||
daysPerMonth = 30
|
||||
cidrPartCount = 2 // A CIDR has two parts: prefix and length
|
||||
)
|
||||
|
||||
// timeSince returns a human-readable duration since the given time
|
||||
@@ -109,16 +109,16 @@ func initTemplates() {
|
||||
|
||||
// Create common template functions
|
||||
funcs := template.FuncMap{
|
||||
"timeSince": timeSince,
|
||||
"urlEncode": url.QueryEscape,
|
||||
"prefixURL": prefixURL,
|
||||
"appName": func() string { return version.Name },
|
||||
"appAuthor": func() string { return version.Author },
|
||||
"appAuthorURL": func() string { return version.AuthorURL },
|
||||
"appLicense": func() string { return version.License },
|
||||
"appRepoURL": func() string { return version.RepoURL },
|
||||
"appGitRevision": func() string { return version.GitRevisionShort },
|
||||
"appGitCommitURL": func() string { return version.CommitURL() },
|
||||
"timeSince": timeSince,
|
||||
"urlEncode": url.QueryEscape,
|
||||
"prefixURL": prefixURL,
|
||||
"appName": func() string { return version.Name },
|
||||
"appAuthor": func() string { return version.Author },
|
||||
"appAuthorURL": func() string { return version.AuthorURL },
|
||||
"appLicense": func() string { return version.License },
|
||||
"appRepoURL": func() string { return version.RepoURL },
|
||||
"appGitRevision": func() string { return version.GitRevisionShort },
|
||||
"appGitCommitURL": func() string { return version.CommitURL() },
|
||||
}
|
||||
|
||||
// Parse index template
|
||||
|
||||
Reference in New Issue
Block a user