Agent class extends Edge Compute’s StatefulActor, and the platform calls it through the actor’s entries.
One instance runs one of these at a time, so a handler never interleaves with another on the same conversation. Execution Model has the rest of the rules. A webhook is a request to
fetch like any other, and what the function does with it is the function’s own code.
Activation
The platform constructs the class on every activation. The constructor opens the instance’s stores and re-arms the task scheduler before the instance takes a call.StatefulActorreceivesctxandenvthroughsuper(ctx, env). It keeps them asthis.ctxandthis.env.ctx.storagebacks the task scheduler and the state store. The message log and the event log are built on it too.ctx.blockConcurrencyWhileruns the store setup and the re-arm. Every other call waits until both finish. The callback has a 30-second budget.
The Fetch Entry
The class does not override the actor’sfetch. It inherits the default.
fetch(req)receives every request to the instance that is not an upgrade. A class that serves the streams and RPC over HTTP overrides it and passes the request to anAgentHttpServer.
The WebSocket Entry
The class overrides the actor’swebSocket and hands each socket to its socket server.
webSocket(ws, req)receives the accepted socket and the handshake request. A class that overrides none of the three seams throws before it touches the socket, so the socket is refused.
The Alarm Entry
The instance has one alarm. The task scheduler sets it throughctx.storage, to the earliest due task.
ctx.storage.setAlarmreceives the earliest due time, in milliseconds since the epoch. Setting it again replaces the previous time, so every task shares the one alarm.ctx.storage.deleteAlarmclears the alarm when no task is pending.
alarm drains every due task and re-arms.
alarm(info)is the entry the platform calls when the alarm fires. Every task the drain dispatches runs inside it, under the alarm’s time budget.