- 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.
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package config
|
|
|
|
// ResourceConfig centralizes pacing and resource optimization knobs.
|
|
type ResourceConfig struct {
|
|
MaxWorkers int `yaml:"max_workers" toml:"max_workers"`
|
|
DesiredRPSPerWorker int `yaml:"desired_rps_per_worker" toml:"desired_rps_per_worker"`
|
|
RequestsPerSec int `yaml:"requests_per_sec" toml:"requests_per_sec"`
|
|
PodmanCPUs string `yaml:"podman_cpus" toml:"podman_cpus"`
|
|
PodmanMemory string `yaml:"podman_memory" toml:"podman_memory"`
|
|
RequestBurstOverride int `yaml:"request_burst" toml:"request_burst"`
|
|
}
|
|
|
|
// ApplyDefaults ensures sane values without requiring every field to be set.
|
|
func (r *ResourceConfig) ApplyDefaults() {
|
|
if r.MaxWorkers < 1 {
|
|
r.MaxWorkers = 1
|
|
}
|
|
if r.DesiredRPSPerWorker < 1 {
|
|
r.DesiredRPSPerWorker = DefaultDesiredRPSPerWorker
|
|
}
|
|
if r.PodmanCPUs == "" {
|
|
r.PodmanCPUs = DefaultPodmanCPUs
|
|
}
|
|
if r.PodmanMemory == "" {
|
|
r.PodmanMemory = DefaultPodmanMemory
|
|
}
|
|
}
|
|
|
|
// EffectiveRequestsPerSec returns an auto-derived value when not explicitly set.
|
|
func (r ResourceConfig) EffectiveRequestsPerSec() int {
|
|
if r.RequestsPerSec > 0 {
|
|
return r.RequestsPerSec
|
|
}
|
|
|
|
rps := r.MaxWorkers * r.DesiredRPSPerWorker
|
|
if rps < 1 {
|
|
return 1
|
|
}
|
|
return rps
|
|
}
|