@@ -151,6 +151,25 @@ defmodule PartitionSupervisor do
151151 @ typedoc since: "1.14.0"
152152 @ type name :: atom ( ) | { :via , module ( ) , term ( ) }
153153
154+ @ typedoc """
155+ The "identifier" of a partition.
156+ """
157+ @ typedoc since: "1.19.0"
158+ @ type partition ( ) :: non_neg_integer ( )
159+
160+ @ typedoc """
161+ The possible options to give to `start_link/0`.
162+ """
163+ @ typedoc since: "1.19.0"
164+ @ type start_link_option ::
165+ { :name , name }
166+ | { :child_spec , Supervisor . child_spec ( ) | Supervisor . module_spec ( ) }
167+ | { :partitions , pos_integer ( ) }
168+ | { :strategy , Supervisor . strategy ( ) }
169+ | { :max_restarts , non_neg_integer ( ) }
170+ | { :max_seconds , non_neg_integer ( ) }
171+ | { :with_arguments , ( args :: [ term ( ) ] , partition ( ) -> updated_args :: [ term ( ) ] ) }
172+
154173 @ doc false
155174 def child_spec ( opts ) when is_list ( opts ) do
156175 id =
@@ -188,16 +207,19 @@ defmodule PartitionSupervisor do
188207
189208 ## Options
190209
210+ See `t:start_link_option/0` for the type of each option.
211+
191212 * `:name` - an atom or via tuple representing the name of the partition
192- supervisor (see `t:name/0`) .
213+ supervisor. *Required* .
193214
194- * `:child_spec` - the child spec to be used when starting the partitions.
215+ * `:child_spec` - the child spec to be used when starting the partitions. *Required*.
195216
196- * `:partitions` - a positive integer with the number of partitions.
197- Defaults to `System.schedulers_online() ` (typically the number of cores).
217+ * `:partitions` - the number of partitions.
218+ Defaults to `System.schedulers_online/0 ` (typically the number of cores).
198219
199- * `:strategy` - the restart strategy option, defaults to `:one_for_one` .
220+ * `:strategy` - the restart strategy option.
200221 You can learn more about strategies in the `Supervisor` module docs.
222+ Defaults to `:one_for_one`.
201223
202224 * `:max_restarts` - the maximum number of restarts allowed in
203225 a time frame. Defaults to `3`.
@@ -206,7 +228,9 @@ defmodule PartitionSupervisor do
206228 Defaults to `5`.
207229
208230 * `:with_arguments` - a two-argument anonymous function that allows
209- the partition to be given to the child starting function. See the
231+ the partition to be given to the child starting function. It takes the list of arguments
232+ passed to the child start function and the partition itself, and must return
233+ possibly-updated arguments to give to the child start function. See the
210234 `:with_arguments` section below.
211235
212236 ## `:with_arguments`
@@ -227,7 +251,7 @@ defmodule PartitionSupervisor do
227251
228252 """
229253 @ doc since: "1.14.0"
230- @ spec start_link ( keyword ) :: Supervisor . on_start ( )
254+ @ spec start_link ( [ start_link_option ( ) ] ) :: Supervisor . on_start ( )
231255 def start_link ( opts ) when is_list ( opts ) do
232256 name = opts [ :name ]
233257
0 commit comments