View Source Skitter.DSL.Strategy.Helpers (Skitter v0.5.0)

Macros to be used in strategy hooks.

This module defines various macro "primitives" to be used in Skitter.DSL.Strategy.defhook/2. The contents of this module are automatically available inside defhook.

The macros defined in this module do not offer new functionality. Instead, they provide syntactic sugar over calling existing functions with arguments based on the context passed to the strategy hook.

Link to this section Summary

Functions

Call callback of the current component with args.

Call callback of the current component with args.

Call callback of the current component with args and config.

Call callback of the current component with state, config and args.

Call callback of the current component if it exists.

Call callback of the current component if it exists.

Call callback of the current component if it exists.

Call callback of the current component if it exists.

Emit data for the current context.

Emit data for the current context.

Get the index of the given in port.

Get the name of the in port with the given index.

Get the name of the out port with the given index.

Create an empty state for the component.

Get the index of the given out port.

Send a message to a worker using the Elixir's Kernel.send/2.

Send a message to a worker with Skitter.Worker.send/3

Stop the current worker using Skitter.Worker.stop/1

Stop the given worker using Skitter.Worker.stop/1

Programmatically create output for all out ports.

Programmatically create output for the out port with index.

Link to this section Functions

Link to this macro

call(callback)

View Source (macro)

Call callback of the current component with args.

Uses Skitter.Component.call/2.

Link to this macro

call(callback, args)

View Source (macro)

Call callback of the current component with args.

Uses Skitter.Component.call/3.

Link to this macro

call(callback, config, args)

View Source (macro)

Call callback of the current component with args and config.

Uses Skitter.Component.call/4.

Link to this macro

call(callback, state, config, args)

View Source (macro)

Call callback of the current component with state, config and args.

Uses Skitter.Component.call/5.

Link to this macro

call_if_exists(callback)

View Source (macro)

Call callback of the current component if it exists.

Uses Skitter.Component.call_if_exists/2.

Link to this macro

call_if_exists(callback, args)

View Source (macro)

Call callback of the current component if it exists.

Uses Skitter.Component.call_if_exists/3.

Link to this macro

call_if_exists(callback, config, args)

View Source (macro)

Call callback of the current component if it exists.

Uses Skitter.Component.call_if_exists/4.

Link to this macro

call_if_exists(callback, state, config, args)

View Source (macro)

Call callback of the current component if it exists.

Uses Skitter.Component.call_if_exists/5.

Emit data for the current context.

Uses Skitter.Strategy.Component.emit/2

Link to this macro

emit(emit, invocation)

View Source (macro)

Emit data for the current context.

Uses Skitter.Strategy.Component.emit/3

Link to this macro

error(message)

View Source (macro)

Raise a Skitter.StrategyError

The error is automatically annotated with the current context, which is used to retrieve the current component and strategy.

Link to this macro

in_port_to_index(port)

View Source (macro)

Get the index of the given in port.

Calls Skitter.Component.in_port_to_index/2.

Link to this macro

index_to_in_port(index)

View Source (macro)

Get the name of the in port with the given index.

Calls Skitter.Component.index_to_in_port/2.

Link to this macro

index_to_out_port(index)

View Source (macro)

Get the name of the out port with the given index.

Calls Skitter.Component.index_to_out_port/2.

Link to this macro

initial_state()

View Source (macro)

Create an empty state for the component.

This macro creates an initial state for a component, by using Skitter.Component.initial_state/1

Link to this macro

local_worker(state, tag)

View Source (macro)

Create a worker using Skitter.Worker.create_local/3.

This macro creates a local worker, automatically passing the current context.

Link to this macro

out_port_to_index(port)

View Source (macro)

Get the index of the given out port.

Calls Skitter.Component.out_port_to_index/2.

Link to this macro

plain_send(pid, message)

View Source (macro)

Send a message to a worker using the Elixir's Kernel.send/2.

send/2 and send/3 defined in this module call Skitter.Worker.send/3 which will send a message to a worker, eventually causing its Skitter.Strategy.Component.process/4 hook to be called.

In contrast, this function uses the built-in Kernel.send/2 of Elixir, which sends a message to a pid. This is useful when you need to use Kernel.SpecialForms.receive/1 inside a hook.

Link to this macro

remote_worker(state, tag, placement \\ nil)

View Source (macro)

Create a worker using Skitter.Worker.create_remote/4.

This macro creates a remote worker, automatically passing the current context.

Link to this macro

send(worker, message)

View Source (macro)

Send a message to a worker with Skitter.Worker.send/3

The invocation is inferred from the current invocation.

Link to this macro

send(worker, message, invocation)

View Source (macro)

Send a message to a worker with Skitter.Worker.send/3

Stop the current worker using Skitter.Worker.stop/1

Link to this macro

stop_worker(worker)

View Source (macro)

Stop the given worker using Skitter.Worker.stop/1

Link to this macro

to_all_ports(list)

View Source (macro)

Programmatically create output for all out ports.

The data must be wrapped in a list.

Link to this macro

to_port(index, list)

View Source (macro)

Programmatically create output for the out port with index.

The data must be wrapped in a list.