Skip to content

Commit

Permalink
Add debug messages - remove this commit
Browse files Browse the repository at this point in the history
  • Loading branch information
theseanything committed Dec 6, 2024
1 parent a39a52d commit 9c3b411
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/load_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,13 @@ func (rt *Router) listenForContentStoreUpdates(ctx context.Context) error {
"route_changes",
pgxlisten.HandlerFunc(
func(ctx context.Context, notification *pgconn.Notification, conn *pgx.Conn) error {
logInfo("router: pgxlisten: recieved notification from content store to reload routes")
// This is a non-blocking send, if there is already a notification to reload we don't need to send another one
select {
case rt.CsReloadChan <- true:
logInfo("router: pgxlisten: sent reload notification to CsReloadChan")
default:
logWarn("router: pgxlisten: CsReloadChan is full, discarding reload notification")
}
return nil
},
Expand All @@ -152,17 +155,21 @@ func (rt *Router) PeriodicCSRouteUpdates() {
tick := time.Tick(5 * time.Second)
for range tick {
if time.Since(rt.csLastReloadTime) > time.Minute {
logInfo(fmt.Sprintf("router: last reload from content store was %v triggering reload", rt.csLastReloadTime))
// This is a non-blocking send, if there is already a notification to reload we don't need to send another one
select {
case rt.CsReloadChan <- true:
logInfo("router: periodic: sent reload notification to CsReloadChan")
default:
logWarn("router: periodic: CsReloadChan is full, discarding reload notification")
}
}
}
}

func (rt *Router) waitForReload() {
for range rt.CsReloadChan {
logInfo("router: received reload notification from content store")
rt.reloadCsRoutes(rt.pool)
}
}
Expand Down

0 comments on commit 9c3b411

Please sign in to comment.