buildJobDescriptor static method
Computes the Job Object limit descriptor for limits:
memoryBytes→ processMemoryFlag plusprocessMemoryLimitBytes.cpuas a percentage ("50%") → cpuRateFlag pluscpuRate(percent × 100; 50% → 5000). Other cpu spellings (bare fractions) have no mapping yet and are omitted.timeout→timeoutMilliseconds(wall clock, enforced by the job runner's timer rather than a Job Object flag).- killOnJobCloseFlag is always set.
With no limits at all the flags word is 0.
Implementation
static Map<String, Object?> buildJobDescriptor(CubeResourceLimits limits) {
var flags = killOnJobCloseFlag;
final cpu = limits.cpu;
final cpuPercent = cpu == null
? null
: cpu.endsWith('%')
? double.tryParse(cpu.substring(0, cpu.length - 1))
: null;
if (cpuPercent != null) flags |= cpuRateFlag;
final memoryBytes = limits.memoryBytes;
if (memoryBytes != null) flags |= processMemoryFlag;
return {
'flags': flags,
'processMemoryLimitBytes': ?memoryBytes,
if (cpuPercent != null) 'cpuRate': (cpuPercent * 100).round(),
'timeoutMilliseconds': ?limits.timeout?.inMilliseconds,
};
}