1717
1818-behaviour (gen_server ).
1919
20+ -include (" quicer_types.hrl" ).
21+
2022% % API
2123-export ([
2224 start_link /3 ,
4951 opts_tab :: ets :tid ()
5052}).
5153
52- -export_type ([listener_name / 0 ]).
54+ -export_type ([
55+ listener_name / 0 ,
56+ listener_opts / 0
57+ ]).
5358
5459-type listener_name () :: atom ().
5560
61+ -type listener_opts () :: {
62+ listen_opts () | proplists :proplist (),
63+ conn_opts () | proplists :proplist (),
64+ stream_opts () | proplists :proplist ()
65+ }.
66+
5667% %%===================================================================
5768% %% API
5869% %%===================================================================
@@ -101,7 +112,7 @@ reload(Pid, NewConf) ->
101112% % @NOTE: the acceptor opts and stream opts are not reloaded.
102113% %% if you want to reload them, you should restart the listener (terminate and spawn).
103114% % @end
104- -spec reload (pid (), quicer :listen_on (), NewConf :: map () | { map (), map (), map ()} ) ->
115+ -spec reload (pid (), quicer :listen_on (), NewConf :: listener_opts () ) ->
105116 ok | {error , _ }.
106117reload (Pid , ListenOn , NewConf ) ->
107118 gen_server :call (Pid , {reload , ListenOn , NewConf }, infinity ).
@@ -116,7 +127,7 @@ count_conns(Pid) ->
116127 gen_server :call (Pid , count_conns , infinity ).
117128
118129% % @doc get the listener configuration
119- -spec get_conf (pid (), timeout ()) -> { map (), map (), map ()} .
130+ -spec get_conf (pid (), timeout ()) -> listener_opts () .
120131get_conf (Pid , Timeout ) ->
121132 gen_server :call (Pid , get_conf , Timeout ).
122133
@@ -262,14 +273,14 @@ terminate(_Reason, #state{listener = L}) ->
262273 _ = quicer :close_listener (L ),
263274 ok .
264275
265- -spec do_reload (quicer :listen_on (), map () | { map (), map (), map ()} , # state {}) ->
276+ -spec do_reload (quicer :listen_on (), listener_opts () , # state {}) ->
266277 {ok | {error , any ()}, # state {}}.
267- do_reload (ListenOn , NewConf , # state {opts_tab = OptsTab } = State ) ->
278+ do_reload (ListenOn , { LOpts , _ , _ } = NewConf , # state {opts_tab = OptsTab } = State ) ->
268279 _ = quicer :stop_listener (State # state .listener ),
269280 Res = quicer :start_listener (
270281 State # state .listener ,
271282 ListenOn ,
272- NewConf
283+ LOpts
273284 ),
274285 case Res of
275286 ok ->
@@ -291,9 +302,7 @@ conf_tab_refresh(Tab, {LOpts, COpts, SOpts}) ->
291302 {l_opts , to_map (LOpts )},
292303 {c_opts , to_map (COpts )},
293304 {s_opts , to_map (SOpts )}
294- ]);
295- conf_tab_refresh (Tab , LOpts ) ->
296- ets :insert (Tab , {l_opts , to_map (LOpts )}).
305+ ]).
297306
298307to_map (Opts ) when is_list (Opts ) ->
299308 maps :from_list (Opts );
0 commit comments