Packages
reactor
0.15.5
1.0.2
1.0.1
1.0.0
0.17.0
0.16.0
0.15.6
0.15.5
0.15.4
0.15.3
0.15.2
0.15.1
0.15.0
0.14.0
0.13.3
0.13.2
0.13.1
0.13.0
0.12.1
0.12.0
0.11.0
0.10.3
0.10.2
0.10.1
0.10.0
0.9.1
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0
An asynchronous, graph-based execution engine
Current section
Files
Jump to
Current section
Files
lib/reactor/dsl/collect.ex
defmodule Reactor.Dsl.Collect do
@moduledoc """
The struct used to store collect DSL entities.
See `d:Reactor.collect`.
"""
defstruct __identifier__: nil,
arguments: [],
description: nil,
guards: [],
name: nil,
transform: nil
alias Reactor.{Builder, Dsl, Step}
@type t :: %__MODULE__{
arguments: [Dsl.Argument.t()],
description: nil | String.t(),
guards: [Dsl.Where.t() | Dsl.Guard.t()],
name: atom,
transform: nil | (any -> any),
__identifier__: any
}
@doc false
def __entity__,
do: %Spark.Dsl.Entity{
name: :collect,
describe: """
A Reactor step which simply collects and returns it's arguments.
Arguments can optionally be transformed before returning.
""",
examples: [
"""
collect :latest_release_uri do
argument :repository, input(:repository)
argument :organisation, input(:organisation)
transform fn inputs ->
%{uri: "https://api.github.com/repos/\#{inputs.organisation}/\#{inputs.repository}/releases/latest"}
end
end
"""
],
args: [:name],
target: __MODULE__,
identifier: :name,
entities: [
arguments: [Dsl.Argument.__entity__(), Dsl.WaitFor.__entity__()],
guards: [Dsl.Where.__entity__(), Dsl.Guard.__entity__()]
],
recursive_as: :steps,
schema: [
name: [
type: :atom,
required: true,
doc: """
A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps.
"""
],
description: [
type: :string,
required: false,
doc: """
An optional description for the step.
"""
],
transform: [
type: {:or, [{:spark_function_behaviour, Step, {Step.TransformAll, 1}}, nil]},
required: false,
default: nil,
doc: """
An optional transformation function which can be used to modify the entire argument map before it is returned.
"""
]
]
}
defimpl Dsl.Build do
def build(step, reactor) do
Builder.add_step(
reactor,
step.name,
Step.ReturnAllArguments,
step.arguments,
async?: true,
description: step.description,
guards: step.guards,
max_retries: 1,
transform: step.transform,
ref: :step_name
)
end
def verify(_step, _dsl_state), do: :ok
end
end