lecture 05
This commit is contained in:
19 files changed
+439
No files matched your search
@@ -0,0 +1,26 @@
|
||||
defmodule Counter.Application do
|
||||
# See https://hexdocs.pm/elixir/Application.html
|
||||
# for more information on OTP Applications
|
||||
@moduledoc false
|
||||
|
||||
@registry Counter.Registry
|
||||
@table Counter.Table
|
||||
|
||||
use Application
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
children = [
|
||||
{Registry, name: @registry, keys: :unique}, # recall same as {Registry, [name: @registry, keys: :unique]}
|
||||
# Starts a worker by calling: Counter.Worker.start_link(arg)
|
||||
# {DynamicSupervisor, name: Counter.DynamicSupervisor, strategy: :one_for_one}
|
||||
{PartitionSupervisor, name: Counter.DynamicSupervisors, child_spec: Counter.DynamicSupervisor}
|
||||
]
|
||||
|
||||
:ets.new(@table, [:named_table, :public])
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: Counter.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user