sless-primer/simple-node/code/time_display/time_display.js
“Naeel” 695f217e13 feat: operator v0.1.16 — job stdout -> status.Message (feature B)
- FunctionJobReconciler: added KubeClient field (kubernetes.Interface)
- getJobPodOutput(): reads pod logs via typed client after job succeeds
- main.go: inject kubernetes.NewForConfigOrDie into FunctionJobReconciler
- rbac.yaml: add pods/pods/log get/list/watch permissions
- examples/simple-python/: job->function chain demo (Python)
- examples/simple-node/: job->function chain demo (Node.js)

sless_job.X.message now contains the return value of the function
2026-03-09 14:50:06 +04:00

21 lines
824 B
JavaScript

// Создано: 2026-03-09
// time_display.js — HTTP-функция (постоянный Deployment + Trigger).
// Читает env JOB_TIME, которую terraform передаёт из sless_job.run_getter.message.
// Демонстрирует цепочку: Job вычисляет данные → Function использует их через env.
exports.showTime = function(event) {
// JOB_TIME устанавливается terraform из статуса джоба (JSON строка)
const jobTimeRaw = process.env.JOB_TIME || '{}';
let jobTime;
try {
const parsed = JSON.parse(jobTimeRaw);
jobTime = parsed.time || jobTimeRaw;
} catch (e) {
jobTime = jobTimeRaw;
}
return {
message: `Сервис запустился в: ${jobTime}`,
path: event._path || '/',
};
};