Skip to content

Instantly share code, notes, and snippets.

@manpages
Created September 15, 2014 05:35
Show Gist options
  • Save manpages/9a231f243c4da20223d4 to your computer and use it in GitHub Desktop.
Save manpages/9a231f243c4da20223d4 to your computer and use it in GitHub Desktop.
Better layot for OTP structure
defmodule ArchJS do
use Application
import ArchJS.Macros.Sup
defsup User, [] do
defsofo Sessions, ArchJS.User.Session
children = [
worker(ArchJS.User.Registry, []),
worker(ArchJS.User.Sessions, [])
]
supervise(children, strategy: :one_for_one)
end
defsup Content, [] do
defsofo Threads, ArchJS.Content.Thread
children = [
worker(ArchJS.Content.Registry, []),
worker(ArchJS.Content.Threads, [])
]
supervise(children, strategy: :one_for_one)
end
defsup Root, link: [name: __MODULE__] do
children = [
worker(ArchJS.User, []),
worker(ArchJS.Content, []),
worker(ArchJS.Persist, [])
]
supervise(children, strategy: :one_for_one)
end
def start(_type, _args) do
ArchJS.Root.start_link
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment