@@ -151,6 +151,25 @@ defmodule PartitionSupervisor do
151
151
@ typedoc since: "1.14.0"
152
152
@ type name :: atom ( ) | { :via , module ( ) , term ( ) }
153
153
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
+
154
173
@ doc false
155
174
def child_spec ( opts ) when is_list ( opts ) do
156
175
id =
@@ -188,16 +207,19 @@ defmodule PartitionSupervisor do
188
207
189
208
## Options
190
209
210
+ See `t:start_link_option/0` for the type of each option.
211
+
191
212
* `:name` - an atom or via tuple representing the name of the partition
192
- supervisor (see `t:name/0`) .
213
+ supervisor. *Required* .
193
214
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*.
195
216
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).
198
219
199
- * `:strategy` - the restart strategy option, defaults to `:one_for_one` .
220
+ * `:strategy` - the restart strategy option.
200
221
You can learn more about strategies in the `Supervisor` module docs.
222
+ Defaults to `:one_for_one`.
201
223
202
224
* `:max_restarts` - the maximum number of restarts allowed in
203
225
a time frame. Defaults to `3`.
@@ -206,7 +228,9 @@ defmodule PartitionSupervisor do
206
228
Defaults to `5`.
207
229
208
230
* `: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
210
234
`:with_arguments` section below.
211
235
212
236
## `:with_arguments`
@@ -227,7 +251,7 @@ defmodule PartitionSupervisor do
227
251
228
252
"""
229
253
@ doc since: "1.14.0"
230
- @ spec start_link ( keyword ) :: Supervisor . on_start ( )
254
+ @ spec start_link ( [ start_link_option ( ) ] ) :: Supervisor . on_start ( )
231
255
def start_link ( opts ) when is_list ( opts ) do
232
256
name = opts [ :name ]
233
257
0 commit comments