fetch_ml/internal/controller/pacing_controller.go
Jeremie Fraeys ea15af1833 Fix multi-user authentication and clean up debug code
- Fix YAML tags in auth config struct (json -> yaml)
- Update CLI configs to use pre-hashed API keys
- Remove double hashing in WebSocket client
- Fix port mapping (9102 -> 9103) in CLI commands
- Update permission keys to use jobs:read, jobs:create, etc.
- Clean up all debug logging from CLI and server
- All user roles now authenticate correctly:
  * Admin: Can queue jobs and see all jobs
  * Researcher: Can queue jobs and see own jobs
  * Analyst: Can see status (read-only access)

Multi-user authentication is now fully functional.
2025-12-06 12:35:32 -05:00

28 lines
679 B
Go

package controller
// AdaptivePacingController derives request pacing based on worker capacity.
type AdaptivePacingController struct {
DesiredRPSPerWorker int
}
// NewAdaptivePacingController constructs a controller with sane defaults.
func NewAdaptivePacingController(desired int) AdaptivePacingController {
if desired < 1 {
desired = 1
}
return AdaptivePacingController{DesiredRPSPerWorker: desired}
}
// RequestsPerSec returns max(1, maxWorkers * desiredRPSPerWorker).
func (a AdaptivePacingController) RequestsPerSec(maxWorkers int) int {
if maxWorkers < 1 {
maxWorkers = 1
}
rps := maxWorkers * a.DesiredRPSPerWorker
if rps < 1 {
rps = 1
}
return rps
}