View Source Edeliver.Relup.Instruction behaviour (edeliver v1.9.2)

This behaviour can be used to provide custom instructions to modify the relup.

They can be used in the implementations of of the Edeliver.Relup.Modifcation behaviour.

Example:

defmodule Acme.Relup.LogUpgradeInstruction do
  use Edeliver.Relup.Instruction

  def modify_relup(instructions = %Instructions{up_instructions: up_instructions}, _config = %{}) do
    log_instruction = {:apply, {:"Elixir.Logger", :info, [<<"Upgraded successfully">>]}}
    %{instructions| up_instructions: [log_instruction|up_instructions]}
  end

end

# using the instruction
defmodule Acme.Relup.Modification do
  use Edeliver.Relup.Modification

  def modify_relup(instructions = %Instructions{}, config = %{}) do
    instructions |> Edeliver.Relup.DefaultModification.modify_relup(config) # use default modifications
                 |> Acme.Relup.LogUpgradeInstruction.modify_relup(config) # apply also custom instructions
  end
end

edeliver already provides a set of relup instructions:

Link to this section Summary

Types

A function that inserts a new instruction or a set of new instructions at a given place in the list of existing instructions. For most appup instructions from the relup file it matters when they will be executed, e.g before or after some other instructions.

Callbacks

Modifies the relup file.

Link to this section Types

@type insert_fun() ::
  (Edeliver.Relup.Instructions.t()
   | Edeliver.Relup.Instructions.instructions(),
   new_instructions ::
     Edeliver.Relup.Instructions.instruction()
     | Edeliver.Relup.Instructions.instructions() ->
     updated_instructions ::
       Edeliver.Relup.Instructions.t() | Instructinos.instructions())

A function that inserts a new instruction or a set of new instructions at a given place in the list of existing instructions. For most appup instructions from the relup file it matters when they will be executed, e.g before or after some other instructions.

Link to this section Callbacks

Modifies the relup file.

Modifies the relup file which will be used to upgrade (or downgrade) from one version to another by inserting, removing, or shifting appup instructions. See Edeliver.Relup.InsertInstruction and Edeliver.Relup.ShiftInstruction for useful helpers to insert / position the instructions and Edeliver.Relup.RunnableInstruction to execute custom code during the upgrade.