17
17
18
18
-behaviour (gen_server ).
19
19
20
+ -include (" quicer_types.hrl" ).
21
+
20
22
% % API
21
23
-export ([
22
24
start_link /3 ,
49
51
opts_tab :: ets :tid ()
50
52
}).
51
53
52
- -export_type ([listener_name / 0 ]).
54
+ -export_type ([
55
+ listener_name / 0 ,
56
+ listener_opts / 0
57
+ ]).
53
58
54
59
-type listener_name () :: atom ().
55
60
61
+ -type listener_opts () :: {
62
+ listen_opts () | proplists :proplist (),
63
+ conn_opts () | proplists :proplist (),
64
+ stream_opts () | proplists :proplist ()
65
+ }.
66
+
56
67
% %%===================================================================
57
68
% %% API
58
69
% %%===================================================================
@@ -101,7 +112,7 @@ reload(Pid, NewConf) ->
101
112
% % @NOTE: the acceptor opts and stream opts are not reloaded.
102
113
% %% if you want to reload them, you should restart the listener (terminate and spawn).
103
114
% % @end
104
- -spec reload (pid (), quicer :listen_on (), NewConf :: map () | { map (), map (), map ()} ) ->
115
+ -spec reload (pid (), quicer :listen_on (), NewConf :: listener_opts () ) ->
105
116
ok | {error , _ }.
106
117
reload (Pid , ListenOn , NewConf ) ->
107
118
gen_server :call (Pid , {reload , ListenOn , NewConf }, infinity ).
@@ -116,7 +127,7 @@ count_conns(Pid) ->
116
127
gen_server :call (Pid , count_conns , infinity ).
117
128
118
129
% % @doc get the listener configuration
119
- -spec get_conf (pid (), timeout ()) -> { map (), map (), map ()} .
130
+ -spec get_conf (pid (), timeout ()) -> listener_opts () .
120
131
get_conf (Pid , Timeout ) ->
121
132
gen_server :call (Pid , get_conf , Timeout ).
122
133
@@ -262,14 +273,14 @@ terminate(_Reason, #state{listener = L}) ->
262
273
_ = quicer :close_listener (L ),
263
274
ok .
264
275
265
- -spec do_reload (quicer :listen_on (), map () | { map (), map (), map ()} , # state {}) ->
276
+ -spec do_reload (quicer :listen_on (), listener_opts () , # state {}) ->
266
277
{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 ) ->
268
279
_ = quicer :stop_listener (State # state .listener ),
269
280
Res = quicer :start_listener (
270
281
State # state .listener ,
271
282
ListenOn ,
272
- NewConf
283
+ LOpts
273
284
),
274
285
case Res of
275
286
ok ->
@@ -291,9 +302,7 @@ conf_tab_refresh(Tab, {LOpts, COpts, SOpts}) ->
291
302
{l_opts , to_map (LOpts )},
292
303
{c_opts , to_map (COpts )},
293
304
{s_opts , to_map (SOpts )}
294
- ]);
295
- conf_tab_refresh (Tab , LOpts ) ->
296
- ets :insert (Tab , {l_opts , to_map (LOpts )}).
305
+ ]).
297
306
298
307
to_map (Opts ) when is_list (Opts ) ->
299
308
maps :from_list (Opts );
0 commit comments