1414 unfinished /1 ,
1515 set_retry_timeout /2 ,
1616 set_max_workers /2 ,
17- get_max_workers /1
17+ get_max_workers /1
1818 ]).
1919
2020% % For workers
@@ -123,8 +123,6 @@ set_max_workers(Name, Workers) ->
123123-spec get_max_workers (atom ()) -> non_neg_integer ().
124124get_max_workers (Name ) ->
125125 gen_server :call (Name , get_max_workers ).
126-
127-
128126
129127% %% For workers
130128
@@ -139,14 +137,19 @@ init([Nodes, Client, MaxWorkers, MaxRetries]) ->
139137 process_flag (trap_exit , true ),
140138 ok = net_kernel :monitor_nodes (true ),
141139
142- {ok , # state {nodes = ping_nodes (Nodes ),
143- client = Client ,
144- max_workers = MaxWorkers ,
145- max_retries = MaxRetries ,
146- retry_timeout = 1000 ,
147- pending = queue :new (),
148- running = [],
149- ticks = 0 }}.
140+ case ping_nodes (Nodes ) of
141+ [] ->
142+ erlang :error (no_nodes_in_cluster );
143+ Nodes ->
144+ {ok , # state {nodes = Nodes ,
145+ client = Client ,
146+ max_workers = MaxWorkers ,
147+ max_retries = MaxRetries ,
148+ retry_timeout = 1000 ,
149+ pending = queue :new (),
150+ running = [],
151+ ticks = 0 }}
152+ end .
150153
151154handle_call ({execute , MFA }, _From , State ) ->
152155 {reply , ok , execute_try (MFA , State )};
@@ -197,7 +200,7 @@ handle_call({set_max_workers, Workers}, _From, State) ->
197200 {reply , ok , State # state {max_workers = Workers }};
198201
199202handle_call (get_max_workers , _From , State ) ->
200- {reply , ok , State # state .max_workers };
203+ {reply , { ok , State # state .max_workers }, State };
201204
202205handle_call (_Request , _From , State ) ->
203206 {reply , ok , State }.
0 commit comments