-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: init policy defaults to true #459
base: transition-to-runkit
Are you sure you want to change the base?
feat: init policy defaults to true #459
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.
Good first step.
However, I believe this won't work for ports that are exported on a composition (since they are not using this codepath). I don't think it would work in many cases related to compositions (such as e.g. a composition that has a service as child and gets its real component as an injection in profiles).
The more generic place to resolve this would be where we compute the final connection policy. https://github.com//rock-core/tools-syskit/blob/b674ba903538d229ded38c5980cfd5549535e4eb/lib/syskit/network_generation/dataflow_dynamics.rb#L525
And it will definitely not work for data readers. For data readers, you would need to work here: https://github.com//rock-core/tools-syskit/blob/6b0d92aa0c8bc62a79ce6d58dffb330abdfcceb9/lib/syskit/dynamic_port_binding.rb#L205
lib/syskit/models/port.rb
Outdated
raise WrongPortConnectionTypes.new(self, in_port), "cannot connect #{out_port} to #{in_port}: types mismatch" | ||
end | ||
|
||
validate_connection!(out_port, in_port) |
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.
Why the !
here ?
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.
This is subjective, but while reading about !
methods in ruby, I learned that this is a convention in rails for methods that might raise exceptions (example: https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-save-21). Seemed like a practical way to indicate that the method might interrupt the normal flow of code.
But now that you mention it, maybe it doesn't make sense here, since it's not being called by the user. It does draw attention to the method, though, and that was the main idea.
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 a ... long discussion in the Ruby circles. The !
is generally meant to represent "unexpectedly dangerous methods".... Not a very easy criteria to apply. For instance, in containers, it's used to mark self-modifying versions of modification methods (e.g. Hash#merge! vs. Hash#merge)
Regardless of the overall discussion, it's best to always follow the conventions of the codebase you're modifying. Within Syskit, the validate_*
methods all raise and none has a !
.
78b2475
to
4132b18
Compare
fix Metrics/CyclomaticComplexity offense by moving the connection validation code to a separate function
and rewrite code in port model
Use init_policy from the port as a default for the policy Do not override the existing init flag in the policy `policy.fetch(:init, port.model.init_policy)` to set the init value if not already provided in the policy
4132b18
to
7ab7ee8
Compare
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.
Right ... so turns out that the syskit dataflow comptuation code itself is binary. Either the policy is empty and it gets computed automatically, or it's not and policy_for gets called.
Let's merge this PR following that behaviour and fix it later.
a54ec92
to
945bf58
Compare
The
:init
policy flag requests that the connection sends the last value written to it.This PR applies the
:init
policy using therecommend_init
flagDepends on: