43 lines
1.6 KiB
Plaintext
43 lines
1.6 KiB
Plaintext
|
|
# Resource Validators
|
||
|
|
# CPU, memory, and disk allocation validation for deployment modes
|
||
|
|
|
||
|
|
let constraints = import "../constraints/constraints.toml" in
|
||
|
|
let common = import "./common-validator.ncl" in
|
||
|
|
|
||
|
|
{
|
||
|
|
# Validate CPU cores for deployment mode
|
||
|
|
ValidCpuCores = fun mode cpu_cores =>
|
||
|
|
let min_cpu = constraints.deployment.solo.cpu.min in
|
||
|
|
let max_cpu = constraints.deployment.enterprise.cpu.max in
|
||
|
|
common.ValidRange min_cpu max_cpu cpu_cores,
|
||
|
|
|
||
|
|
# Validate memory allocation in MB for deployment mode
|
||
|
|
ValidMemoryMb = fun mode memory_mb =>
|
||
|
|
let min_mem = constraints.deployment.solo.memory_mb.min in
|
||
|
|
let max_mem = constraints.deployment.enterprise.memory_mb.max in
|
||
|
|
common.ValidRange min_mem max_mem memory_mb,
|
||
|
|
|
||
|
|
# Validate disk allocation in GB for deployment mode
|
||
|
|
ValidDiskGb = fun mode disk_gb =>
|
||
|
|
let min_disk = constraints.deployment.solo.disk_gb.min in
|
||
|
|
let max_disk = constraints.deployment.enterprise.disk_gb.max in
|
||
|
|
common.ValidRange min_disk max_disk disk_gb,
|
||
|
|
|
||
|
|
# Validate file size in bytes
|
||
|
|
ValidFileSize = fun min_bytes max_bytes size =>
|
||
|
|
common.ValidRange min_bytes max_bytes size,
|
||
|
|
|
||
|
|
# Validate memory size in MB
|
||
|
|
ValidMemorySizeMb = fun min_mb max_mb size_mb =>
|
||
|
|
common.ValidRange min_mb max_mb size_mb,
|
||
|
|
|
||
|
|
# Validate pool size (number of connections/threads)
|
||
|
|
ValidPoolSize = fun pool_size =>
|
||
|
|
if pool_size < 1 then
|
||
|
|
std.contract.blame_with_message "Pool size must be >= 1" pool_size
|
||
|
|
else if pool_size > 1000 then
|
||
|
|
std.contract.blame_with_message "Pool size must be <= 1000" pool_size
|
||
|
|
else
|
||
|
|
pool_size,
|
||
|
|
}
|