Is this a correct child spec ?

依然范特西╮ 提交于 2019-12-24 21:15:03

问题


I notice there is the code as follows in cowboy https://github.com/extend/cowboy

supervisor:start_child(cowboy_sup, child_spec(Ref, NbAcceptors,
    Transport, TransOpts, Protocol, ProtoOpts)).

child_spec(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) ->  
{{cowboy_listener_sup, Ref}, {cowboy_listener_sup, start_link, [ NbAcceptors, Transport,
TransOpts, Protocol, ProtoOpts ]}, permanent, 5000, supervisor,[cowboy_listener_sup]}.

http://www.erlang.org/doc/man/supervisor.html#start_child-2

I don't think it is correct child spec, what do you think about it ?


回答1:


You can verify the correctness of a child spec by using the supervisor:check_childspecs/1 function.

And yes, that looks like a valid child spec:

child_spec() = 
    {Id :: child_id(),
     StartFunc :: mfargs(),
     Restart :: restart(),
     Shutdown :: shutdown(),
     Type :: worker(),
     Modules :: modules()}

Where:

Id -> {cowboy_listener_sup, Ref}
StartFunc -> {cowboy_listener_sup, start_link, [ ... ]}
Restart -> permanent
Shutdown -> 5000
Type -> supervisor
Modules -> [cowboy_listener_sup]

What's the doubt, exactly?



来源:https://stackoverflow.com/questions/10104014/is-this-a-correct-child-spec

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!