1818-export ([init /1 , handle_call /3 , handle_cast /2 , handle_info /2 , code_change /3 , terminate /2 ]).
1919
2020% config_listener api
21- -export ([handle_config_change /5 ]).
21+ -export ([handle_config_change /5 , handle_config_terminate / 3 ]).
2222
2323-record (state , {
2424 concurrency ,
@@ -83,12 +83,6 @@ handle_info({'DOWN', Ref, _, _, Reason}, State) ->
8383 false ->
8484 {noreply , State , 0 }
8585 end ;
86- handle_info ({gen_event_EXIT , {config_listener , ? MODULE }, _Reason }, State ) ->
87- erlang :send_after (5000 , self (), restart_config_listener ),
88- {noreply , State };
89- handle_info (restart_config_listener , State ) ->
90- ok = config :listen_for_changes (? MODULE , nil ),
91- {noreply , State };
9286handle_info (timeout , State ) ->
9387 {noreply , maybe_submit_request (State )}.
9488
@@ -97,6 +91,14 @@ handle_config_change("ioq", _, _, _, _) ->
9791handle_config_change (_ , _ , _ , _ , _ ) ->
9892 {ok , nil }.
9993
94+ handle_config_terminate (_ , stop , _ ) -> ok ;
95+ handle_config_terminate (_ , _ , _ ) ->
96+ spawn (fun () ->
97+ timer :sleep (5000 ),
98+ config :listen_for_changes (? MODULE , nil )
99+ end ),
100+ ok .
101+
100102code_change (_Vsn , State , _Extra ) ->
101103 {ok , State }.
102104
0 commit comments