Grains v0.3.7 Grains

Grains describes data flow as a graph with interchangeable parts.

To accomplish that grains divides the graph (Recipe) from the implementation of the nodes (Grains). Together these parts can be used to make a Bread which describes how the graph translates to processes. Each process has a symbolic short name, which is resolved to the registered name of the process via a map (%Bread{}.process_map).

Link to this section Summary

Functions

Combine two sets of recipes and grains.

Debug an asynchronous data chain.

This function describes the default implementations for auxiliary grains, for example the periodic timer. Currently these default grains are provided

Retrieve a grain's substate.

Merges two grain maps into one.

Convenient version of routes/2. Takes a list of tuples of the form [{pattern, grains}].

Define a pattern which messages must match in order to be pushed to the successor grains. Every message gets tested against the pattern before it is pushed to the successors.

Link to this section Functions

Link to this function

combine(arg1, arg2)

Combine two sets of recipes and grains.

Link to this function

concat_name(bread, grain)

concat_name(Grains.Bread.t(), atom()) :: atom()
Link to this function

debug_reply_chain(reply_chain, message)

Debug an asynchronous data chain.

The function expects a list of grains. The grain currently handling the message checks if its name matches the first element of the list. If so, it pops that element and attempts to send the message to the next grain in the list. If only one element in the list remains, and that element matches the name of the current grain handling the list, this grain replies to the sender with message.

Link to this function

default_grains()

This function describes the default implementations for auxiliary grains, for example the periodic timer. Currently these default grains are provided:

iex> Grains.default_grains()
%{periodic: Grains.Timer}
Link to this function

get_name(supervisor, short_name)

get_name(Grains.Supervisor.t(), atom()) :: atom()
Link to this function

get_original_recipe!(supervisor)

See Grains.Supervisor.get_original_recipe!/1.

Link to this function

get_substate(bread_id)

get_substate(atom()) :: term()

Retrieve a grain's substate.

This is similar to :sys.get_state/1. Note that this function should usually not be used, but it can be useful for debugging or testing.

Errors

The function exits the caller on error. For example, if no bread with the supplied id can be found, this results in a no_proc exit.

Link to this function

make_bread_name(recipe, bread_id)

make_bread_name(Grains.Recipe.t(), atom()) :: atom()
Link to this function

make_name(recipe, bread_id, short_name)

make_name(Grains.Recipe.t(), atom(), atom()) :: atom()
Link to this function

merge(grains1, grains2)

Merges two grain maps into one.

The function works the same as Map.merge/2: all grains in the second argument are added to the first, overriding any existing one.

Link to this function

merge_recipes(name, a, b)

See Grains.Recipe.merge/3.

Link to this function

new_recipe(name, new)

See Grains.Recipe.new/2.

Link to this function

periodic(grain, period, opts \\ %{with_timestamps: false})

Description of a periodic grain.

Link to this macro

route(routes)

(macro)

Convenient version of routes/2. Takes a list of tuples of the form [{pattern, grains}].

Link to this macro

route(pattern, grains)

(macro)

Define a pattern which messages must match in order to be pushed to the successor grains. Every message gets tested against the pattern before it is pushed to the successors.

Link to this function

start_supervised(recipe, grains, args \\ [])

See Grains.Supervisor.start_link/3.