diff --git a/lib/thousand_island.ex b/lib/thousand_island.ex index c9a599c..413352e 100644 --- a/lib/thousand_island.ex +++ b/lib/thousand_island.ex @@ -99,9 +99,7 @@ defmodule ThousandIsland do * `handler_module`: The name of the module used to handle connections to this server. The module is expected to implement the `ThousandIsland.Handler` behaviour. Required * `handler_options`: A term which is passed as the initial state value to - `c:ThousandIsland.Handler.handle_connection/2` calls. Optional, defaulting to nil. - * `genserver_options`: A term which is passed as the value to the handler module's - underlying `GenServer.start_link/3` call. Optional, defaulting to [] + `c:ThousandIsland.Handler.handle_connection/2` calls. Optional, defaulting to nil * `port`: The TCP port number to listen on. If not specified this defaults to 4000. If a port number of `0` is given, the server will dynamically assign a port number which can then be obtained via `ThousandIsland.listener_info/1` or @@ -116,6 +114,11 @@ defmodule ThousandIsland do `ThousandIsland.Transports.TCP` and `ThousandIsland.Transports.SSL` modules. Any options in terms of interfaces to listen to / certificates and keys to use for SSL connections will be passed in via this option + * `genserver_options`: A term which is passed as the option value to the handler module's + underlying `GenServer.start_link/3` call. Optional, defaulting to `[]` + * `supervisor_options`: A term which is passed as the option value to this server's top-level + supervisor's `Supervisor.start_link/3` call. Useful for setting the `name` for this server. + Optional, defaulting to `[]` * `num_acceptors`: The number of acceptor processes to run. Defaults to 100 * `num_connections`: The maximum number of concurrent connections which each acceptor will accept before throttling connections. Connections will be throttled by having the acceptor @@ -145,6 +148,7 @@ defmodule ThousandIsland do handler_module: module(), handler_options: term(), genserver_options: GenServer.options(), + supervisor_options: [Supervisor.option()], port: :inet.port_number(), transport_module: module(), transport_options: transport_options(), diff --git a/lib/thousand_island/server.ex b/lib/thousand_island/server.ex index 1707287..17e61f8 100644 --- a/lib/thousand_island/server.ex +++ b/lib/thousand_island/server.ex @@ -5,7 +5,7 @@ defmodule ThousandIsland.Server do @spec start_link(ThousandIsland.ServerConfig.t()) :: Supervisor.on_start() def start_link(%ThousandIsland.ServerConfig{} = config) do - Supervisor.start_link(__MODULE__, config) + Supervisor.start_link(__MODULE__, config, config.supervisor_options) end @spec listener_pid(Supervisor.supervisor()) :: pid() | nil diff --git a/lib/thousand_island/server_config.ex b/lib/thousand_island/server_config.ex index 372a233..2c2a03f 100644 --- a/lib/thousand_island/server_config.ex +++ b/lib/thousand_island/server_config.ex @@ -9,6 +9,7 @@ defmodule ThousandIsland.ServerConfig do handler_module: module(), handler_options: term(), genserver_options: GenServer.options(), + supervisor_options: [Supervisor.option()], num_acceptors: pos_integer(), num_connections: non_neg_integer() | :infinity, max_connections_retry_count: non_neg_integer(), @@ -24,6 +25,7 @@ defmodule ThousandIsland.ServerConfig do handler_module: nil, handler_options: [], genserver_options: [], + supervisor_options: [], num_acceptors: 100, num_connections: 16_384, max_connections_retry_count: 5,