Periodic
This example demonstrates defining a custom Lambda Trigger that can periodically trigger Lambdas.
Initial Provisioning
graph LR; cli --> control_plane; console --> control_plane; control_plane <-- tunnel --> agent; subgraph user_edge[User Edge] cli[CLI]; console[Console]; end subgraph cloud[Cloud <small>api.on-prem.net</small>] control_plane[Control Plane]; end subgraph device_edge[Device Edge] agent[Agent]; end
Subsequent Autonomous Edge Operation
graph LR; agent --> trigger[Lambda Trigger]; trigger --> lambda1; trigger --> lambda2; trigger --> lambda3; subgraph device_edge[Device Edge] agent; end subgraph agent[Agent] trigger; lambda1[Lambda 1]; lambda2[Lambda 2]; lambda3[Lambda 3]; end
Define the lambda trigger
$ onprem generate xid
cj7br83erad4ipi8nb4g
# my_periodic_lambda_trigger_type.yaml
id: cj7br83erad4ipi8nb4g
kind: LambdaTriggerType
name: periodic_trigger
description: >
Periodically trigger lambdas.
runsAtControlPlane: true
runsAtDevices: true
scriptContentType: text/x-lua
script: >
local socket = require('socket')
local M = {}
function M.init(context, params)
end
function M.run(context)
while true do
local event = {
timestamp = socket.gettime()
}
coroutine.yield(event)
socket.sleep(0.5) -- seep for 1/2 second
end
end
return M
Upload it to the control plane
$ onprem apply my_periodic_lambda_trigger_type.yaml
It will now show up in the cloud console.
And it will also now show up as one of the trigger choices when editing a Lambda.