Storehouse.Notify (Storehouse v0.2.0)

Copy Markdown View Source

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: ...
end

The function is called with the event and a map, then its own arguments, in the process that did the work:

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.

Types

notifier()

@type notifier() :: {module(), atom(), list()} | nil

A function to tell: {module, function, args}, called with the event and its map first.