Skip to content

Commit

Permalink
Merge pull request #11 from sonroyaalmerol/log-proxy-source
Browse files Browse the repository at this point in the history
Add detailed load balancer logs
  • Loading branch information
sonroyaalmerol authored Mar 2, 2024
2 parents 61beeda + 57045f8 commit f65d62d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mp4_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func loadBalancer(ctx context.Context, stream database.StreamInfo) (resp *http.R
// Concurrency check mode
for _, url := range stream.URLs {
if checkConcurrency(ctx, url.Content, url.MaxConcurrency) {
log.Printf("Concurrency limit reached (%d): %s", url.MaxConcurrency, url.Content)
continue // Skip this stream if concurrency limit reached
}

Expand All @@ -43,7 +44,7 @@ func loadBalancer(ctx context.Context, stream database.StreamInfo) (resp *http.R
break
} else {
// Log the error
return nil, nil, fmt.Errorf("Error fetching MP4 stream (connection check mode): %s\n", err.Error())
log.Printf("Error fetching MP4 stream (connection check mode): %s\n", err.Error())
}
}

Expand Down Expand Up @@ -103,6 +104,7 @@ func mp4Handler(w http.ResponseWriter, r *http.Request, db *sql.DB) {
http.Error(w, "Error fetching MP4 stream. Exhausted all streams.", http.StatusInternalServerError)
return
}
log.Printf("Proxying %s to %s\n", r.RemoteAddr, selectedUrl.Content)
updateConcurrency(ctx, selectedUrl.Content, true)

// Log the successful response
Expand Down

0 comments on commit f65d62d

Please sign in to comment.