edeliver v1.2.5 Edeliver.Relup.RunnableInstruction behaviour
This module can be used to provide custom instructions executed during the upgrade.
They can be used in implementations of the Edeliver.Relup.Modifcation behaviours.
A runnable instruction must implement a run/1 function which will be executed
during the upgrade on the nodes.
Example:
defmodule Acme.Relup.PingNodeInstruction do
use Edeliver.Relup.RunnableInstruction
def modify_relup(instructions = %Instructions{up_instructions: up_instructions}, _config = %Config{}) do
node_name = :"node@host"
%{instructions|
up_instructions: [call_this([node_name]) | instructions.up_instructions],
down_instructions: [call_this([node_name]) | instructions.down_instructions]
}
end
# executed during hot code upgrade from relup file
def run(_options = [node_name]) do
:net_adm.ping(node_name)
end
# actually implemented already in this module
def call_this(arguments) do
# creates a relup instruction to call `run/1` of this module
{:apply, {__MODULE__, :run, arguments}}
end
end
# using the instruction
defmodule Acme.Relup.Modification do
use Edeliver.Relup.Modification
def modify_relup(instructions = %Instructions{}, _config = %Config{}) do
instructions |> Edeliver.Relup.DefaultModification.modify_relup(Config) # use default modifications
|> Acme.Relup.PingNodeInstruction.modify_relup(Config) # apply also custom instructions
end
end
Summary
Callbacks
Returns the arguments which will be passed the run/1 function during the upgrade
Returns a list of module names which implement the behaviour Edeliver.Relup.RunnableInstruction
Returns a function which inserts the relup instruction
The function to run during hot code upgrade on nodes
Callbacks
Specs
arguments(instructions :: %Edeliver.Relup.Instructions{changed_modules: term, down_instructions: term, down_version: term, up_instructions: term, up_version: term}, config :: %ReleaseManager.Config{dev: term, env: term, erl: term, name: term, package: term, relx_config: term, upgrade?: term, verbosity: term, version: term}) :: [term]
Returns the arguments which will be passed the run/1 function during the upgrade.
Default is an empty list.
Specs
dependencies :: [instruction_module :: atom]
Returns a list of module names which implement the behaviour Edeliver.Relup.RunnableInstruction
and are used / referenced by this runnable instruction. These modules must be loaded before this instruction is executed for upgrades and unloaded after this instruction for downgrades. Default is an empty list.
Specs
insert_where :: (%Edeliver.Relup.Instructions{changed_modules: term, down_instructions: term, down_version: term, up_instructions: term, up_version: term}, Edeliver.Relup.Instruction.instruction -> %Edeliver.Relup.Instructions{changed_modules: term, down_instructions: term, down_version: term, up_instructions: term, up_version: term})
Returns a function which inserts the relup instruction
that calls the run/1 fuction of this module.
Default is inserting it at the end of the instructions