Reactor.File
View SourceAn extension which provides steps for working with the local filesystem within Reactor.
reactor.chgrp
chgrp name
Change the group of a file or directory.
Uses File.chgrp/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the file or directory | |
gid | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The GID to set the file group to | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Change the GID back to the original value on undo? |
reactor.chgrp.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.chgrp.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.chgrp.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Chgrp
reactor.chown
chown name
Change the owner of a file or directory.
Uses File.chown/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the file or directory | |
uid | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The UID to set the file owner to | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Change the UID back to the original value on undo? |
reactor.chown.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.chown.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.chown.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Chown
reactor.chmod
chmod name
Change the permissions of a file or directory.
Uses File.chmod/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the file or directory | |
mode | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The mode to set the file permissions to | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Change the permissions back to the original value on undo? |
reactor.chmod.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.chmod.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.chmod.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Chmod
reactor.close_file
close_file name
Closes a file.
Uses File.close/1
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
device | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The IO device to close | |
description | String.t | An optional description for the step |
reactor.close_file.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.close_file.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.close_file.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.CloseFile
reactor.cp
cp name
Copy the source file to the destination.
Uses File.cp/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
source | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the source file | |
target | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the target file | |
description | String.t | An optional description for the step | |
overwrite? | boolean | true | Whether or not to overwrite the target if it already exists |
revert_on_undo? | boolean | false | Revert back to the initial state on undo (either by removing the target or by setting it back to it's original content) |
reactor.cp.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.cp.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.cp.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Cp
reactor.cp_r
cp_r name
Copy the source file or directories to the destination.
Uses File.cp_r/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
source | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the source file | |
target | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the target file | |
description | String.t | An optional description for the step | |
overwrite? | boolean | true | Whether or not to overwrite the target if it already exists |
revert_on_undo? | boolean | false | Revert back to the initial state on undo (either by removing the target or by setting it back to it's original content) |
reactor.cp_r.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.cp_r.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.cp_r.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.CpR
reactor.glob
glob name
Searches for files matching the provided pattern.
Uses Path.wildcard/2
under the hood.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
pattern | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | A pattern used to select files. See Path.wildcard/2 for more information. | |
description | String.t | An optional description for the step | |
match_dot | boolean | false | Whether or not files starting with a . will be matched by the pattern. See Path.wildcard/2 for more information. |
reactor.glob.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.glob.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.glob.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Glob
reactor.io_binread
io_binread name
Reads from an IO device.
Uses IO.binread/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
device | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The IO device to read from | |
line_or_chars | :eof | :line | non_neg_integer | Controls how the device is iterated. | |
description | String.t | An optional description for the step |
reactor.io_binread.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.io_binread.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.io_binread.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.IoBinRead
reactor.io_binstream
io_binstream name
Streams from an IO device.
Uses IO.binstream/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
device | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The IO device to read from | |
line_or_bytes | :line | non_neg_integer | Controls how the stream is iterated. | |
description | String.t | An optional description for the step |
reactor.io_binstream.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.io_binstream.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.io_binstream.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.IoBinStream
reactor.io_read
io_read name
Reads from an IO device
Uses IO.read/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
device | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The IO device to read from | |
line_or_chars | :eof | :line | non_neg_integer | Controls how the device is iterated. | |
description | String.t | An optional description for the step |
reactor.io_read.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.io_read.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.io_read.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.IoRead
reactor.io_stream
io_stream name
Streams from an IO device.
Uses IO.stream/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
device | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The IO device to read from | |
line_or_codepoints | :line | non_neg_integer | Controls how the stream is iterated. | |
description | String.t | An optional description for the step |
reactor.io_stream.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.io_stream.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.io_stream.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.IoStream
reactor.io_write
io_write name
Writes to an IO device
Uses IO.write/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
device | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The IO device to read from | |
chardata | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The data to write to the IO device | |
description | String.t | An optional description for the step |
reactor.io_write.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.io_write.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.io_write.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.IoWrite
reactor.ln
ln name
Create a hard link from existing
to new
.
Uses File.ln/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
existing | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the existing file | |
new | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the new file | |
description | String.t | An optional description for the step | |
overwrite? | boolean | true | Whether or not to overwrite the new if it already exists |
revert_on_undo? | boolean | false | Revert back to the initial state on undo (either by removing the new or by setting it back to it's original content) |
reactor.ln.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.ln.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.ln.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Ln
reactor.ln_s
ln_s name
Create a symbolic link from existing
to new
.
Uses File.ln_s/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
existing | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the existing file | |
new | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the new file | |
description | String.t | An optional description for the step | |
overwrite? | boolean | true | Whether or not to overwrite the new if it already exists |
revert_on_undo? | boolean | false | Revert back to the initial state on undo (either by removing the new or by setting it back to it's original content) |
reactor.ln_s.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.ln_s.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.ln_s.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.LnS
reactor.lstat
lstat name
Returns information about a path.
If the file is a symlink, sets the type to :symlink
and returns a
File.Stat
struct for the link. For any other file, returns exactly the
same values as stat
.
See File.lstat/2
for more information.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path of the directory to create | |
description | String.t | An optional description for the step | |
time | :universal | :local | :posix | :posix | What format to return the file times in. See File.stat/2 for more. |
reactor.lstat.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.lstat.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.lstat.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Lstat
reactor.mkdir
mkdir name
Creates a directory.
Uses File.mkdir/1
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path of the directory to create | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Remove the created directory if the Reactor is undoing changes |
reactor.mkdir.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.mkdir.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.mkdir.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Mkdir
reactor.mkdir_p
mkdir_p name
Creates a directory and any intermediate directories which also must be created.
Uses File.mkdir_p/1
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path of the directory to create | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Remove the created directory if the Reactor is undoing changes |
reactor.mkdir_p.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.mkdir_p.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.mkdir_p.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.MkdirP
reactor.open_file
open_file name
Opens a file.
Uses File.open/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the file to open | |
modes | list(:append | :binary | :charlist | :compressed | :delayed_write | :exclusive | :raw | :read | :read_ahead | :sync | :write | :utf8 | {:read_ahead, pos_integer} | {:delayed_write, pos_integer, pos_integer} | {:encoding, :latin1 | :unicode | :utf8 | :utf16 | :utf32 | {:utf16, :big | :little} | {:utf32, :big | :little}}) | :ram | The mode to open the file with | |
description | String.t | An optional description for the step |
reactor.open_file.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.open_file.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.open_file.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.OpenFile
reactor.read_file
read_file name
Reads a file.
Uses File.read/1
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the link to read | |
description | String.t | An optional description for the step |
reactor.read_file.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.read_file.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.read_file.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.ReadFile
reactor.read_link
read_link name
Reads a symbolic link.
Uses File.read_link/1
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the link to read | |
description | String.t | An optional description for the step |
reactor.read_link.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.read_link.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.read_link.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.ReadLink
reactor.rm
rm name
Removes a file.
Uses File.rm/1
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the file to remove | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Replace the original file if the Reactor is undoing changes |
reactor.rm.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.rm.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.rm.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Rm
reactor.rmdir
rmdir name
Removes a directory.
Uses File.rmdir/1
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path of the directory to remove | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Recreate the directory if the Reactor is undoing changes |
reactor.rmdir.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.rmdir.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.rmdir.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Rmdir
reactor.stat
stat name
Returns information about a path.
See File.stat/2
for more information.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path of the directory to create | |
description | String.t | An optional description for the step | |
time | :universal | :local | :posix | :posix | What format to return the file times in. See File.stat/2 for more. |
reactor.stat.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.stat.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.stat.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Stat
reactor.touch
touch name
Update the mtime and atime of a file.
Uses File.touch/2
.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path of the directory to remove | |
description | String.t | An optional description for the step | |
time | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The time to change the file to. | |
revert_on_undo? | boolean | false | Recreate the directory if the Reactor is undoing changes |
reactor.touch.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.touch.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.touch.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.Touch
reactor.write_file
write_file name
Writes the given content to the file at the given path.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the file to modify | |
content | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The content to write | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Revert to the original state when undoing changes |
modes | list(:append | :binary | :charlist | :compressed | :delayed_write | :exclusive | :raw | :read | :read_ahead | :sync | :write | :utf8 | {:read_ahead, pos_integer} | {:delayed_write, pos_integer, pos_integer} | {:encoding, :latin1 | :unicode | :utf8 | :utf16 | :utf32 | {:utf16, :big | :little} | {:utf32, :big | :little}}) | [] | See File.mode/0 . |
reactor.write_file.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.write_file.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.write_file.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.WriteFile
reactor.write_stat
write_stat name
Writes the given File.Stat
back to the filesystem at the given path.
Nested DSLs
Arguments
Name | Type | Default | Docs |
---|---|---|---|
name | atom | A unique name for the step. Used when choosing the return value of the Reactor and for arguments into other steps |
Options
Name | Type | Default | Docs |
---|---|---|---|
path | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The path to the file to modify | |
stat | Reactor.Template.Element | Reactor.Template.Input | Reactor.Template.Result | Reactor.Template.Value | The stat to write | |
description | String.t | An optional description for the step | |
revert_on_undo? | boolean | false | Revert to the original state when undoing changes |
time | :universal | :local | :posix | :posix | What format to return the file times in. See File.stat/2 for more. |
reactor.write_stat.wait_for
wait_for names
Wait for the named step to complete before allowing this one to start.
Desugars to argument :_, result(step_to_wait_for)
Examples
wait_for :create_user
Arguments
Name | Type | Default | Docs |
---|---|---|---|
names | atom | list(atom) | The name of the step to wait for. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description. |
Introspection
Target: Reactor.Dsl.WaitFor
reactor.write_stat.guard
guard fun
Provides a flexible method for conditionally executing a step, or replacing it's result.
Expects a two arity function which takes the step's arguments and context and returns one of the following:
:cont
- the guard has passed.{:halt, result}
- the guard has failed - instead of executing the step use the provided result.
Examples
step :read_file_via_cache do
argument :path, input(:path)
run &File.read(&1.path)
guard fn %{path: path}, %{cache: cache} ->
case Cache.get(cache, path) do
{:ok, content} -> {:halt, {:ok, content}}
_ -> :cont
end
end
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
fun | (any, any -> any) | mfa | The guard function. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Guard
reactor.write_stat.where
where predicate
Only execute the surrounding step if the predicate function returns true.
This is a simple version of guard
which provides more flexibility at the cost of complexity.
Examples
step :read_file do
argument :path, input(:path)
run &File.read(&1.path)
where &File.exists?(&1.path)
end
Arguments
Name | Type | Default | Docs |
---|---|---|---|
predicate | (any -> any) | mfa | (any, any -> any) | mfa | Provide a function which takes the step arguments and optionally the context and returns a boolean value. |
Options
Name | Type | Default | Docs |
---|---|---|---|
description | String.t | An optional description of the guard. |
Introspection
Target: Reactor.Dsl.Where
Introspection
Target: Reactor.File.Dsl.WriteStat