These are chat archives for jdubray/sam

14th
Aug 2016
Valerio Versace
@vforvalerio87
Aug 14 2016 08:25
Hi I'm trying to build an application using SAM architecture; specifically a simple web app to check status for a server.
Where should communication with the server be handled? Something like a "getServerStatus()" function which calls the hypervisor to ask if a specific machine is online or offline.
Is that an Action or should it be handled in the model?
Thanks
Jean-Jacques Dubray
@jdubray
Aug 14 2016 08:57
@vforvalerio87 the queries should generally be made in actions and the result should be part of the proposal to the model.
Create/Update/Delete are in general made directly from the model
You can use the nap() function to run periodic updates (via a setTimeout)
Let me know if you need some pseudo-code
Valerio Versace
@vforvalerio87
Aug 14 2016 17:36
@jdubray thanks! Pseudo code would be much appreciated. I was thinking about a "ready" state for the application with an "index" view and a "getServerStatus" NAP; other states would be "startingServer" and "stoppingServer", which still render the same "index" view (with different data), "startServer" and "stopServer" as NAP respectively until the server is started or stopped; then it's "ready" state all over again