Skip to content
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: add fine-grained policy merge #466

Open
wants to merge 2 commits into
base: transition-to-runkit
Choose a base branch
from

Conversation

eduardacoppo
Copy link

Previously here: tidewise#3
This was on top of another tools/syskit PR

Previously, if a parameter was added to the designer-provided policy, no automated policy determination would be performed. That meant that the init flag would not be computed in this case.
To fix this, a merge_policy function was implemented to merge the explicit policy (the designer-provided one) and the computed policy (init, for instance)
The fix follows these rules:
- if a value is in policy, use it;
- otherwise use the value from computed_policy
Also, if the type policy is set to data, the size policy must be removed, as its only meaningful for the type buffer and it causes the connection to fail.

The Ruby method `merge` merges two hashes. According to the documentation:
"Returns a new hash containing the contents of other_hash and the contents of hsh. If no block is specified, the value for entries with duplicate keys will be that of other_hash."
In this case, to follow the rules of prioritizing the value from explicit_policy in case of key duplication, 'other_hash' is explicit_policy and 'hsh' is computed_policy
Copy link
Member

@doudou doudou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good first step, but there's one issue.

When using needs_reliable_connection, we have to add period information to the syskit models. Until now, setting the policy explicitly would be enough to avoid having to do this (because of time, or because Syskit limitations would make it hard to do). This PR will break these cases.

My suggestion is to split policy_for into:

  • policy_compute_data_element(policy, fallback_policy)
  • policy_default_init_flag

Always call the latter, but call the former only if the explicit policy does not have :type set already. Create corresponding unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants