diff --git a/lib/broadway.ex b/lib/broadway.ex index 907697f..1dd951f 100644 --- a/lib/broadway.ex +++ b/lib/broadway.ex @@ -843,6 +843,18 @@ defmodule Broadway do @type on_start() :: {:ok, pid()} | :ignore | {:error, {:already_started, pid()} | term()} @type name :: atom() | {:via, module(), term()} + @typedoc """ + A function used to dynamically determine the batch size. + """ + @typedoc since: "1.3.0" + @type batch_size_fun() :: (Message.t(), acc :: term() -> {:emit | :cont, acc :: term()}) + + @typedoc """ + Value for the `:batch_size` option. + """ + @typedoc since: "1.3.0" + @type batch_size() :: pos_integer() | {initial_acc :: term(), batch_size_fun()} + @doc """ Invoked for preparing messages before handling (if defined). diff --git a/lib/broadway/options.ex b/lib/broadway/options.ex index 0cd72c4..770a660 100644 --- a/lib/broadway/options.ex +++ b/lib/broadway/options.ex @@ -231,6 +231,7 @@ defmodule Broadway.Options do ], batch_size: [ type: {:custom, __MODULE__, :validate_batch_size, []}, + type_doc: "`t:batch_size/0`", default: 100, doc: """ The size of the generated batches. Default value is `100`. It is typically an