-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add max_instances option for dynamic pads #876
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add it to the docs generation too
[:direction, :availability, :flow_control, :demand_unit] |
lib/membrane/bin/pad_data.ex
Outdated
@@ -23,6 +24,7 @@ defmodule Membrane.Bin.PadData do | |||
availability: Membrane.Pad.availability(), | |||
direction: Membrane.Pad.direction(), | |||
name: Membrane.Pad.name(), | |||
max_cardinality: Membrane.Pad.max_cardinality() | nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about max_instances
? :P
lib/membrane/pad.ex
Outdated
@@ -102,6 +102,12 @@ defmodule Membrane.Pad do | |||
""" | |||
@type accepted_format :: module() | (pattern :: term()) | |||
|
|||
@typedoc """ | |||
Describes maximal number of instances of dynamic pad (`availability: :on_request`) that | |||
can occur within single component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can occur within single component. | |
can occur simultaneously within a single component. |
lib/membrane/bin/pad_data.ex
Outdated
@@ -8,6 +8,7 @@ defmodule Membrane.Bin.PadData do | |||
- `:name` - see `t:Membrane.Pad.name/0`. Do not mistake with `:ref` | |||
- `:options` - options passed in `Membrane.ChildrenSpec` when linking pad | |||
- `:ref` - see `t:Membrane.Pad.ref/0` | |||
- `max_cardinality` - specyfies maximal possible number of instances of a dynamic pads that can occur within single element. `nil` for pads with `availability: :always`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `max_cardinality` - specyfies maximal possible number of instances of a dynamic pads that can occur within single element. `nil` for pads with `availability: :always`. | |
- `max_cardinality` - specifies maximal possible number of instances of a dynamic pad that can exist within single element. Equals `nil` for pads with `availability: :always`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would apply similar changes for the option in bin and in the typedoc in Pad
module
@@ -37,6 +37,26 @@ defmodule Membrane.Core.Child.PadController do | |||
:ok | |||
end | |||
|
|||
@spec validate_pad_cardinality!(Pad.name(), state()) :: :ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spec validate_pad_cardinality!(Pad.name(), state()) :: :ok | |
@spec validate_pad_cardinality!(Pad.name(), state()) :: :ok | no_return |
Pad #{inspect(pad_name)} can occur only #{max_cardinality} times within a single component, while it \ | ||
attempted to occur #{current_number + 1} times. Set `:max_cardinality` option to a different value, | ||
to change this boundary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like this:
Pad #{inspect(pad_name)} can occur only #{max_cardinality} times within a single component, while it \ | |
attempted to occur #{current_number + 1} times. Set `:max_cardinality` option to a different value, | |
to change this boundary. | |
Only #{max_cardinality} instances of pad #{inspect(pad_name)} can exist within this component, while an attempt to create #{current_number + 1} instances was made. Set `:max_cardinality` option to a different value, | |
to change this boundary. |
?
lib/membrane/pad.ex
Outdated
@@ -126,7 +135,8 @@ defmodule Membrane.Pad do | |||
accepted_format: accepted_format(), | |||
flow_control: flow_control(), | |||
options: Keyword.t(), | |||
demand_unit: Buffer.Metric.unit()} | |||
demand_unit: Buffer.Metric.unit(), | |||
max_cardinality: max_cardinality()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably not the scope of this PR, but is this element_spec
a proper typespec? I think that it doesn't highlight the fact that some of these fields are mandatory, while the others are optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW. - Perhaps it would be good to write somewhere that max_cardinality
defaults to :infinity
for dynamic pads? I don't think there is a way to tell that without checking the code.
Closes #870