diff options
author | Jan Uhlig <[email protected]> | 2021-09-01 14:01:47 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2021-09-01 15:30:34 +0200 |
commit | 581b6954d344eaca2bfcdab663019796e852c778 (patch) | |
tree | a20ea9f96c9fbd9251fc8c570b4e0ff485bccb98 /doc/src/guide/listeners.asciidoc | |
parent | c7a7cfb9b93f0db9c99ed21c34f67e0b6adfcb62 (diff) | |
download | ranch-581b6954d344eaca2bfcdab663019796e852c778.tar.gz ranch-581b6954d344eaca2bfcdab663019796e852c778.tar.bz2 ranch-581b6954d344eaca2bfcdab663019796e852c778.zip |
Update docs and modernize examples
* Use the map form for transport options everywhere
* Remove mentions of the list form for transport options
* Use a state enter call instead of gen_statem:enter_loop/4 and
proc_lib:start_link/3 in the tcp_reverse example
* Take care of different EOLs in the tcp_reverse example
* Mention state enter calls, the next_event action, and {continue, ...}
in the docs for how to use gen_statem and gen_server
Diffstat (limited to 'doc/src/guide/listeners.asciidoc')
-rw-r--r-- | doc/src/guide/listeners.asciidoc | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/doc/src/guide/listeners.asciidoc b/doc/src/guide/listeners.asciidoc index 779497c..3e7254d 100644 --- a/doc/src/guide/listeners.asciidoc +++ b/doc/src/guide/listeners.asciidoc @@ -19,7 +19,6 @@ A listener can be started and stopped at will. When starting a listener, a number of different settings are required: * A name to identify it locally and be able to interact with it. -* The number of acceptors in the pool. * A transport handler and its associated options. * A protocol handler and its associated options. @@ -43,8 +42,8 @@ to the `echo_protocol` handler. [source,erlang] {ok, _} = ranch:start_listener(tcp_echo, - ranch_tcp, [{port, 5555}], - echo_protocol, [] + ranch_tcp, #{socket_opts => [{port, 5555}]}, + echo_protocol, [] ). You can try this out by compiling and running the `tcp_echo` example in the @@ -142,8 +141,8 @@ argument is the name of the listener you gave in `ranch:start_listener/5`. [source,erlang] {ok, _} = ranch:start_listener(tcp_echo, - ranch_tcp, [{port, 0}], - echo_protocol, [] + ranch_tcp, #{socket_opts => [{port, 0}]}, + echo_protocol, [] ). Port = ranch:get_port(tcp_echo). @@ -238,8 +237,8 @@ overloaded and ensuring all the connections are handled optimally. [source,erlang] {ok, _} = ranch:start_listener(tcp_echo, - ranch_tcp, #{socket_opts => [{port, 5555}], max_connections => 100}, - echo_protocol, [] + ranch_tcp, #{socket_opts => [{port, 5555}], max_connections => 100}, + echo_protocol, [] ). You can disable this limit by setting its value to the atom `infinity`. @@ -248,8 +247,8 @@ You can disable this limit by setting its value to the atom `infinity`. [source,erlang] {ok, _} = ranch:start_listener(tcp_echo, - ranch_tcp, #{socket_opts => [{port, 5555}], max_connections => infinity}, - echo_protocol, [] + ranch_tcp, #{socket_opts => [{port, 5555}], max_connections => infinity}, + echo_protocol, [] ). The maximum number of connections is a soft limit. In practice, it @@ -305,8 +304,8 @@ measure to find the best value for your application. [source,erlang] {ok, _} = ranch:start_listener(tcp_echo, - ranch_tcp, [{port, 5555}, {num_acceptors, 42}], - echo_protocol, [] + ranch_tcp, #{socket_opts => [{port, 5555}], num_acceptors => 42}, + echo_protocol, [] ). === Customizing the number of connection supervisors @@ -325,8 +324,8 @@ processes. [source,erlang] {ok, _} = ranch:start_listener(tcp_echo, - ranch_tcp, #{socket_opts => [{port, 5555}], num_conns_sups => 42}], - echo_protocol, [] + ranch_tcp, #{socket_opts => [{port, 5555}], num_conns_sups => 42}, + echo_protocol, [] ). === When running out of file descriptors |