View Source Cinema.Engine behaviour (cinema v0.1.0)
The Cinema.Engine
module provides a behaviour for defining engines which can execute projections
defined using the Cinema.Projection
module.
See the Cinema.Engine.Task
module for an example implementation of this behaviour.
Also see the Cinema.Projection
module for more details re: defining projections.
Summary
Functions
Executes the given Projection.t()
using the given engine. Returns {:ok, projection}
if the projection
was successfully executed, otherwise returns {:error, projection}
.
Fetches the output of a Projection.t()
which has been executed using Cinema.Engine.exec/2
.
Returns true
if the given module implements the Elixir.Cinema.Engine
behaviour, otherwise returns false
.
See Cinema.Utils.Task.test_mode/1
.
See Cinema.Utils.Task.test_mode?/0
.
Callbacks
@callback exec(Cinema.Projection.t()) :: {:ok, Cinema.Projection.t()} | {:error, Cinema.Projection.t()}
@callback fetch(Cinema.Projection.t()) :: term()
Functions
@spec exec(Cinema.Projection.t(), Keyword.t()) :: {:ok, Cinema.Projection.t()} | {:error, Cinema.Projection.t()}
Executes the given Projection.t()
using the given engine. Returns {:ok, projection}
if the projection
was successfully executed, otherwise returns {:error, projection}
.
You can fetch the output of the Projection.t()
(assuming it was successfully executed) by passing the
returned Projection.t()
to Cinema.Projection.fetch/1
function.
@spec fetch(Cinema.Projection.t()) :: {:ok, term()} | {:error, String.t()}
Fetches the output of a Projection.t()
which has been executed using Cinema.Engine.exec/2
.
Returns true
if the given module implements the Elixir.Cinema.Engine
behaviour, otherwise returns false
.
See examples:
iex> Cinema.Engine.implemented?(Enum)
false
iex> Cinema.Projection.implemented?(Cinema.Engine.Task)
true
See Cinema.Utils.Task.test_mode/1
.
See Cinema.Utils.Task.test_mode?/0
.