@@ -30,32 +30,36 @@ defmodule HashRing.Managed do
3030 node_type: :all | :hidden | :visible
3131 ]
3232
33- @ type child_spec_options :: [
34- :id => atom ( ) | term ( ) ,
35- :start => { module , function_name :: atom , args :: [ term ] } ,
36- optional ( :restart ) => restart ,
37- optional ( :shutdown ) => shutdown ,
38- optional ( :type ) => type ,
39- optional ( :modules ) => [ module ] | :dynamic ,
40- optional ( :significant ) => boolean ,
41- :nodes => node_list ,
42- :monitor_nodes => boolean ,
43- :node_blacklist => pattern_list ,
44- :node_whitelist => pattern_list
45- ]
33+ @ type child_spec_option ::
34+ { :id , atom ( ) | term ( ) }
35+ | { :start , { module , function_name :: atom , args :: [ term ] } }
36+ | { :restart , :permanent | :transient | :temporary }
37+ | { :shutdown , timeout ( ) | :brutal_kill }
38+ | { :type , :worker | :supervisor }
39+ | { :modules , [ module ] | :dynamic }
40+ | { :significant , boolean }
41+ | { :nodes , node_list }
42+ | { :monitor_nodes , boolean }
43+ | { :node_blacklist , pattern_list }
44+ | { :node_whitelist , pattern_list }
45+
46+ @ type child_spec_options :: [ child_spec_option ( ) ]
4647
4748 @ valid_ring_opts [ :name , :nodes , :monitor_nodes , :node_blacklist , :node_whitelist , :node_type ]
4849
49- @ spec child_spec ( child_spec_options ) :: Supervisor . child_spec
50+ @ spec child_spec ( child_spec_options ) :: Supervisor . child_spec ( )
5051 def child_spec ( opts ) do
5152 opts = Keyword . put_new ( opts , :name , :hash_ring_manager )
5253
53- Keyword . merge ( % {
54- id: opts [ :id ] || opts [ :name ] ,
55- type: :worker ,
56- restart: :permanent ,
57- start: { __MODULE__ , :run , [ opts [ :name ] , Keyword . take ( opts , @ valid_ring_opts ) ] }
58- } , Keyword . drop ( opts , @ valid_ring_opts ) )
54+ Map . merge (
55+ % {
56+ id: opts [ :id ] || opts [ :name ] ,
57+ type: :worker ,
58+ restart: :permanent ,
59+ start: { __MODULE__ , :run , [ opts [ :name ] , Keyword . take ( opts , @ valid_ring_opts ) ] }
60+ } ,
61+ Map . new ( Keyword . drop ( opts , @ valid_ring_opts ) )
62+ )
5963 end
6064
6165 @ doc """
0 commit comments