Re-vendor the shared files from sneak/prompts at 0653579 (closes #52)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Takes .golangci.yml, .dockerignore, .gitignore, .editorconfig, the workflow and REPO_POLICIES.md from sneak/prompts 0653579, with this repository's own entries after the shared content. Lint (golangci-lint v2.14.0) and test are Dockerfile phases that script/lint and script/test build alone with a new CACHEBUST value, keeping Go's and golangci-lint's caches; the image build depends on both. make fmt and make fmt-check also format the markdown with prettier, pinned in yarn.lock. The agent guidance moves to AGENTS.md. The Go code is fixed for what the new configuration finds, and the AS and prefix detail reads now return the rows' error after their loops. Model: opus-5-5
This commit was merged in pull request #85.
This commit is contained in:
@@ -72,7 +72,7 @@ func NewPeeringHandler(db database.Store, logger *logger.Logger) *PeeringHandler
|
||||
// the AS path information needed to extract peering relationships.
|
||||
func (h *PeeringHandler) WantsMessage(messageType string) bool {
|
||||
// We only care about UPDATE messages that have AS paths
|
||||
return messageType == "UPDATE"
|
||||
return messageType == ristypes.MessageTypeUpdate
|
||||
}
|
||||
|
||||
// QueueCapacity returns the buffer size for the handler's message queue.
|
||||
@@ -101,6 +101,7 @@ func (h *PeeringHandler) HandleMessage(msg *ristypes.RISMessage) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
key := string(pathJSON)
|
||||
|
||||
h.mu.Lock()
|
||||
@@ -116,6 +117,23 @@ func (h *PeeringHandler) HandleMessage(msg *ristypes.RISMessage) {
|
||||
h.mu.Unlock()
|
||||
}
|
||||
|
||||
// ProcessPeeringsNow triggers immediate processing of all accumulated AS
|
||||
// paths into peering records. This bypasses the normal periodic processing
|
||||
// schedule and is primarily intended for testing purposes.
|
||||
func (h *PeeringHandler) ProcessPeeringsNow() {
|
||||
h.processPeerings()
|
||||
}
|
||||
|
||||
// Stop gracefully shuts down the handler by signaling the background
|
||||
// goroutine to stop and performing a final synchronous processing of
|
||||
// any remaining AS paths. This ensures no peering data is lost during
|
||||
// shutdown.
|
||||
func (h *PeeringHandler) Stop() {
|
||||
close(h.stopCh)
|
||||
// Process any remaining peerings synchronously
|
||||
h.processPeerings()
|
||||
}
|
||||
|
||||
// processLoop runs periodically to process AS paths into peerings
|
||||
func (h *PeeringHandler) processLoop() {
|
||||
ticker := time.NewTicker(peeringProcessInterval)
|
||||
@@ -134,13 +152,6 @@ func (h *PeeringHandler) processLoop() {
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessPeeringsNow triggers immediate processing of all accumulated AS
|
||||
// paths into peering records. This bypasses the normal periodic processing
|
||||
// schedule and is primarily intended for testing purposes.
|
||||
func (h *PeeringHandler) ProcessPeeringsNow() {
|
||||
h.processPeerings()
|
||||
}
|
||||
|
||||
// processPeerings extracts peerings from AS paths and writes to database
|
||||
func (h *PeeringHandler) processPeerings() {
|
||||
// Take the accumulated paths and replace the map with a fresh empty one
|
||||
@@ -160,11 +171,14 @@ func (h *PeeringHandler) processPeerings() {
|
||||
type peeringKey struct {
|
||||
low, high int
|
||||
}
|
||||
|
||||
peerings := make(map[peeringKey]time.Time)
|
||||
|
||||
for pathJSON, timestamp := range paths {
|
||||
var path []int
|
||||
if err := json.Unmarshal([]byte(pathJSON), &path); err != nil {
|
||||
|
||||
err := json.Unmarshal([]byte(pathJSON), &path)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to decode AS path", "error", err)
|
||||
|
||||
continue
|
||||
@@ -197,6 +211,7 @@ func (h *PeeringHandler) processPeerings() {
|
||||
// Record peerings in database
|
||||
start := time.Now()
|
||||
successCount := 0
|
||||
|
||||
for key, ts := range peerings {
|
||||
err := h.db.RecordPeering(key.low, key.high, ts)
|
||||
if err != nil {
|
||||
@@ -218,13 +233,3 @@ func (h *PeeringHandler) processPeerings() {
|
||||
"duration", time.Since(start),
|
||||
)
|
||||
}
|
||||
|
||||
// Stop gracefully shuts down the handler by signaling the background
|
||||
// goroutine to stop and performing a final synchronous processing of
|
||||
// any remaining AS paths. This ensures no peering data is lost during
|
||||
// shutdown.
|
||||
func (h *PeeringHandler) Stop() {
|
||||
close(h.stopCh)
|
||||
// Process any remaining peerings synchronously
|
||||
h.processPeerings()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user