Skip to content

Conversation

@ehuelsmann
Copy link
Member

Description

Do not manipulate the context directly; instead, pass parameters to execute_action, which modifies the context after validating the parameters.

This has two benefits:

  1. The context does not get modified when the validators fail
  2. It makes the context much more an internal "scratchpad" for the workflow rather than an API

Credits of the design: @oliwel

For discussion

@jonasbn @oliwel

One problem of this PR is that the context is not fully moved to being a scratchpad; it's still a read-only API: Anything other than the "current state" and "currently available next actions" should still be read from the context.

Another problem that I see, is that the parameters aren't passed to the action's execute method, but copied into the context directly. If we want the context to be a scratchpad for the workflow, I'd make it the responsibility of actions to read/write the context: that way it's a fully private resource.

Type of change

  • Change (fix or feature that would cause existing functionality to not work as expected)
    This change should not break existing behaviour.

Checklist:

  • My code follows the style guidelines of this project, please see the contribution guidelines.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

You might think, that this is one crazy checklist, but it is just as much written for the maintainer of the involved software :-)

@ehuelsmann ehuelsmann added this to the 2.0 milestone Jun 14, 2022
@coveralls
Copy link

coveralls commented Jun 14, 2022

Coverage Status

coverage: 92.35% (+0.02%) from 92.334% when pulling 284bfa5 on ehuelsmann:action-args into 1f00736 on jonasbn:master.

The `autorun` parameter was documented to be internal. It's also
no longer used due to migrating from recursion to a loop for the
`execute_action` function. Therefore, remove all references.

Also, Oliver Welter and I discussed the removal of the autorun
parameter to the observer calls: as "autorunning" isn't a criterion
to the state machine, it shouldn't be to an observer. So we decided
to drop it there too.
By passing the arguments to 'execute_action', there's no need to
directly manipulate the workflow context. This way, the context
is treated as workflow internal state.
…r* merging arguments

This allows passing in values earlier in the workflow and thereby
decouples the workflow invokers from the workflow execution.

Without this change, the workflow invoker would need to know exactly
which step needs which parameters, which would be a case of tight
integration.
@ehuelsmann ehuelsmann marked this pull request as ready for review July 28, 2023 21:00
@ehuelsmann ehuelsmann requested a review from oliwel August 6, 2023 11:12
@oliwel
Copy link
Collaborator

oliwel commented Aug 6, 2023

Looks fine for me :)

@ehuelsmann ehuelsmann merged commit cb8e055 into perl-workflow:master Aug 6, 2023
@ehuelsmann ehuelsmann deleted the action-args branch August 6, 2023 11:16
@ehuelsmann
Copy link
Member Author

Merged based on prior positive reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants