我有一个非常简单的混合应用程序(它是凤凰伞项目的一部分)。它甚至不包括业务逻辑流程。例如:
defmodule BGAdapter.Application do
use Application
def start(_type, _args) do
children = [
BGAdapter.LifeCycle # Agent
]
Supervisor.start_link(children, strategy: :one_for_one, name: BGAdapter.Supervisor)
end
end
我Agent
打了两次电话。一次put
,第二次get
。所以我想Agent
BGAdapter.LifeCycle
用 smth 替换单独的模块,例如:
defmodule BGAdapter.Application do
use Application
def start(_type, _args) do
children = [
{ Agent, fn -> %{} end, name: BGAdapter.LifeCycle } # This does not work
]
...
错误是:
** (Mix) Could not start application bg_adapter: exited in: BGAdapter.Application.start(:normal, [])
** (EXIT) an exception was raised:
** (ArgumentError) supervisors expect each child to be one of the following:
* a module
* a {module, arg} tuple
* a child specification as a map with at least the :id and :start fields
* or a tuple with 6 elements generated by Supervisor.Spec (deprecated)
Got: {Agent, #Function<0.33439399/0 in BGAdapter.Application.start/2>, [name: BGAdapter.LifeCycle]}
我怎样才能开始Agent
“内联”?