pallet.action-plan documentation
An action plan contains actions for execution.
The action plan is built by executing a phase function. Each phase function calls actions which insert themselves into the action plan.
The action plan is transformed to provide aggregated operations, and to resolve precedence relations between actions.
A translated plan is executed by passing an executor, which is a map from action type to function. The executor functions are called with the result of evaluating the action with it's arguments.
action-dependencies
Extract an action's dependencies. Actions are id'd with keywords, and dependencies are declared on an action's id or function.
action-instances
Given a map of dependencies, each with an :f and maybe a :action-id, returns a map where the values are all matching action instances
action-map
Return an action map for the given args. The action plan is a tree of action maps.
precedence specifies naming and dependencies, with :action-id, :always-before and :always-after. If a precedence is supplied, an action-id is generated if none present, to ensure that the standard action precedence is not altered.
- :f the action function
- :args the arguments to pass to the action function
- :location where to execute the action - :orgin or :target
- :action-type the type of action - :script/bash, :fn/clojure, etc
- :execution the execution type - :in-sequence, :aggregated, :collected
- :value the result of calling the action function, :f, with :args
- :session the session map after calling the action function.
add-action
Add an action to the plan
augment-return
Change the return type of an action, to be an action map with :value and :session keys that are the value of the action, and the updated session map for the next action. This creates a consistent return value for all action types (effectively creating a monadic value which is a map).
bind-action-arguments
Bind an action's arguments.
build-for-target
Create the action plan by calling the current phase for the target group.
collect-action-id
Extract an action's id to function mapping
combine-actions
Combine actions by action-type
execute
Execute actions by passing the un-evaluated actions to the executor
function (a function with an arglist of [session f action-type location]).
execute-action
Execute a single action
execute-for-target
Execute the translated action plan for the current target.
get-for-target
Get the action plan for the current phase and target node.
merge-union
Merge-with clojure.set/union
phase-for-target
Return the phase for the target
pop-block
Take the last block and add it to the scope below it in the stack. The block is reversed to put it into the order in which elements were added. Once pop'd, nothing should be added to the block.
push-block
Push a block onto the action-plan
reset-for-target
Reset the action plan for the current phase and target.
script-template
Return the script template for the current group node.
script-template-for-server
Return the script template for the specified server.
target-path
Return the vector path of the action plan for the current session target node, or target group.
transform-nested-scopes
Traverses an action-plan structure. Converting nested scopes into action-map's.
translate
Process the action-plan, applying groupings and precedence, producing an action plan with fully bound functions, ready for execution.
This is equivalent to using an identity monad with a monadic value that is a tree of action maps.
translate-for-target
Build the action plan and translate for the current phase and target node.
translated?
Predicate to test if an action plan has been translated