-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort component state fields in the error logs in the order from the m…
…ost to the least important (#614) * defimpl Inspect for components states * Update lib/membrane/core/inspect.ex Co-authored-by: Mateusz Front <[email protected]> * Update lib/membrane/core/inspect.ex Co-authored-by: Mateusz Front <[email protected]> * Update lib/membrane/core/inspect.ex Co-authored-by: Mateusz Front <[email protected]> * Implement suggestion from CR, add new field to the state * Fix compilation error * Specify docker_membrane version to latest * Revert "Fix compilation error" This reverts commit 5b1e1cb. * Pull docker membrane latest before performance tests * Impelement reviewer suggestion * Add function doc * Update changelog --------- Co-authored-by: Mateusz Front <[email protected]>
- Loading branch information
1 parent
4d4283d
commit 56ebe56
Showing
10 changed files
with
150 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
defmodule Membrane.Core.Inspect do | ||
@moduledoc false | ||
|
||
alias Inspect.Algebra | ||
alias Membrane.Core.Component | ||
|
||
@doc """ | ||
A function, that inspects passed state sorting its fields withing the order in which | ||
they occur in the list passed to `defstruct`. | ||
""" | ||
@spec inspect(Component.state(), Inspect.Opts.t()) :: Inspect.Algebra.t() | ||
def inspect(%state_module{} = state, opts) do | ||
ordered_fields = | ||
state_module.__info__(:struct) | ||
|> Enum.map(& &1.field) | ||
|
||
field_to_doc_fun = | ||
fn field, opts -> | ||
value_doc = | ||
Map.fetch!(state, field) | ||
|> Algebra.to_doc(opts) | ||
|
||
Algebra.concat("#{Atom.to_string(field)}: ", value_doc) | ||
end | ||
|
||
Algebra.container_doc( | ||
"%#{Kernel.inspect(state_module)}{", | ||
ordered_fields, | ||
"}", | ||
opts, | ||
field_to_doc_fun, | ||
break: :strict | ||
) | ||
end | ||
end | ||
|
||
[Pipeline, Bin, Element] | ||
|> Enum.map(fn component -> | ||
state_module = Module.concat([Membrane.Core, component, State]) | ||
|
||
defimpl Inspect, for: state_module do | ||
@spec inspect(unquote(state_module).t(), Inspect.Opts.t()) :: Inspect.Algebra.t() | ||
defdelegate inspect(state, opts), to: Membrane.Core.Inspect | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters