Last active
August 3, 2022 00:27
-
-
Save petermueller/8c2dbbfa61e577fafbab9329bd7b6355 to your computer and use it in GitHub Desktop.
elixir OTP reminders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyMod do | |
use GenServer | |
def child_spec(args) do | |
IO.inspect(args, label: "*** MyMod.child_spec/1") | |
%{ | |
id: __MODULE__, | |
start: {__MODULE__, :start_link, [args]} | |
} | |
end | |
def start_link(args) do | |
IO.inspect(args, label: "*** MyMod.start_link/1") | |
GenServer.start_link(__MODULE__, args) | |
end | |
def init(args) do | |
IO.inspect(args, label: "*** MyMod.init/1") | |
{:ok, args} | |
end | |
end | |
# {:ok, sup_pid} = Supervisor.start_link([MyMod], name: MySup, strategy: :one_for_one) | |
{:ok, sup_pid} = Supervisor.start_link([{MyMod, test: :value}], name: MySup, strategy: :one_for_one) | |
Supervisor.stop(sup_pid) | |
# *** MyMod.child_spec/1: [test: :value] | |
# *** MyMod.start_link/1: [test: :value] | |
# *** MyMod.init/1: [test: :value] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment