Debian Codegraph @

doc/src/guide/migrating_from_1.5.asciidoc

raw
1 [appendix]
2 == Migrating from Ranch 1.5 to 1.6
3
4 Ranch 1.6 added the ability to suspend and resume listeners.
5 It also deprecates a number of features and add interfaces
6 that will be used in Ranch 2.0.
7
8 Ranch 1.6 is compatible with Erlang/OTP 18.0 onward. Support
9 for older releases has been removed.
10
11 === Features added
12
13 * Listeners can now be suspended/resumed without stopping existing
14 connection processes. This effectively closes the listening socket
15 and stops the acceptor processes.
16
17 * Transport options can now be updated for suspended listeners.
18
19 * The `Socket` argument given when the protocol starts has been
20 deprecated. In Ranch 2.0 the socket will be obtainable only
21 by calling `ranch:handshake/1,2`.
22
23 * Ranch-specific transport options and socket options are now
24 better separated. When passing Ranch-specific transport options,
25 Ranch now expects to receive a map, in which case socket
26 options are passed in the `socket_opts` value. When there
27 are only socket options they can be passed to Ranch directly
28 as a convenience.
29
30 * Any future transport option will only be added to the map
31 type. This includes transport options added in this release.
32
33 * The transport option `ack_timeout` was renamed to `handshake_timeout`
34 in the map type.
35
36 * The `cacerts` socket option is now silenced in error logs
37 just like the `certs` and `key` options.
38
39 * The manual has been heavily updated and now features one
40 manual page per function and module, complete with a per-function
41 changelog, examples and more.
42
43 === Experimental features added
44
45 * It is now possible to configure the restart intensity for
46 `ranch_sup` using the OTP application environment. This
47 feature will remain undocumented unless there is popular
48 demand for it.
49
50 * Add the transport option `logger` that allows configuring
51 which logger module will be used. The logger module must
52 follow the interface of the new `logger` module in Erlang/OTP 21,
53 or be set to `error_logger` to keep the old behavior.
54
55 === Changed behaviors
56
57 * Transport modules must now implement `Transport:handshake/2,3`
58 which deprecates and will replace `Transport:accept_ack/1` in
59 Ranch 2.0. It returns a new socket and can therefore be used
60 for implementing TLS upgrade mechanisms.
61
62 === New functions
63
64 * The functions `ranch:suspend_listener/1` and `ranch:resume_listener/1`
65 were added. In addition the function `ranch:get_state/1` can be used
66 to obtain the running state of a listener.
67
68 * A function `ranch:wait_for_connections/3` was added.
69
70 * A function `ranch:handshake/1,2` was added to replace the
71 function `ranch:accept_ack/1`.
72
73 === Bugs fixed
74
75 * The specs for the function `Transport:sendfile/2,4,5` have been
76 corrected. The type used for the filename was too restricting.