Re:Phoenix 1.7.0 Released: Built-In Tailwind, Verified Route...
by conradfr on Monday March 06, 2023 @08:20AM
(#35040611)
(not sure where the "phoenix sockets" fit into it)
1/ So I guess you say one process/GenServer per device, communicating with it.
2/ Use a Registry[0] to store the process names (based on the device id or whatever) to abstract them from their PID.
3/ Have another GenServer (let's call it CoordStore) storing a map of "process_name -> lat/long" (with the related processes sending updates of the coordinates to it)
4/ Use Presence[1] to keep track of the devices and remove them from the CoordStore when needed.
5/ When you have an anomaly on one device ask CoordStore for the nearby devices/processes (using maybe [2]) and ask each one to run the check.
1/ So I guess you say one process/GenServer per device, communicating with it.
2/ Use a Registry[0] to store the process names (based on the device id or whatever) to abstract them from their PID.
3/ Have another GenServer (let's call it CoordStore) storing a map of "process_name -> lat/long" (with the related processes sending updates of the coordinates to it)
4/ Use Presence[1] to keep track of the devices and remove them from the CoordStore when needed.
5/ When you have an anomaly on one device ask CoordStore for the nearby devices/processes (using maybe [2]) and ask each one to run the check.
6/ Done?
[0] https://hexdocs.pm/elixir/1.14.3/Registry.html
[1] https://hexdocs.pm/phoenix/Phoenix.Presence.html
[2] https://github.com/yltsrc/geocalc