What happens to files, told to the app as it happens: a file stored, its analysis done or a step of it failed, a file deleted. For a page that shows the files to everyone who has it open, as their analysis comes in.
# config/config.exs
config :storehouse, notify: {MyApp.Files, :changed, []}
defmodule MyApp.Files do
def changed(event, info), do: ...
endThe function is called with the event and a map, then its own arguments, in the process that did the work:
:stored-%{file: file}, fromStorehouse.store/2andStorehouse.verify_upload/2;:analyzed-%{file: file, steps: names}, the file with the results of the steps that ran (Storehouse.analyze/3);:failed-%{file: file, step: name, reason: reason}, a step that failed;:deleted-%{key: key}(Storehouse.delete/2), or%{prefix: prefix, count: count}(Storehouse.delete_prefix/2).
Each call that does the work takes notify: too, which is used in place
of the config's (notify: nil tells nothing). A function that raises
is logged, and the work is done all the same.
Storehouse.Notify.PubSub broadcasts the events on a topic of the app's
Phoenix.PubSub: a tenant's, so that one subscription follows all its
files.
Summary
Types
A function to tell: {module, function, args}, called with the event and its map first.