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

[action-id-map action]

Extract an action's dependencies. Actions are id'd with keywords, and dependencies are declared on an action's id or function.

action-instances

[actions dependencies]

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

[action-fn precedence args execution action-type location]

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

[action-plan 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

[session]

Create the action plan by calling the current phase for the target group.

collect-action-id

[m action]

Extract an action's id to function mapping

combine-actions

Combine actions by action-type

execute

[action-plan session executor execute-status-fn]

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

[executor session {:keys [f action-type location], :as action}]

Execute a single action

execute-for-target

[session executor execute-status-fn]

Execute the translated action plan for the current target.

get-for-target

[session]

Get the action plan for the current phase and target node.

merge-union

[& m]

Merge-with clojure.set/union

phase-for-target

[session]

Return the phase for the target

pop-block

[action-plan]

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

[action-plan]

Push a block onto the action-plan

reset-for-target

[session]

Reset the action plan for the current phase and target.

script-template

[session]

Return the script template for the current group node.

script-template-for-server

[server]

Return the script template for the specified server.

target-path

[session]

Return the vector path of the action plan for the current session target node, or target group.

transform-nested-scopes

[action-plan]

Traverses an action-plan structure. Converting nested scopes into action-map's.

translate

[action-plan]

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

[session]

Build the action plan and translate for the current phase and target node.

translated?

[action-plan]

Predicate to test if an action plan has been translated