View Source Skitter.Strategy.Operation behaviour (Skitter v0.6.1)
Operation strategy behaviour.
This module defines and documents the various hooks a Skitter.Strategy
for an operation should
implement, along with the functions it can use to access the runtime system.
Link to this section Summary
Callbacks
Accept data sent to the operation node and send it to a worker.
Deploy an operation over the cluster.
Handle a message received by a worker.
Functions
Emit values.
Link to this section Callbacks
@callback deliver( context :: Skitter.Strategy.context(), data :: any(), port :: Skitter.Operation.port_index() ) :: any()
Accept data sent to the operation node and send it to a worker.
This hook is called by the runtime system when data needs to be sent to a given operation (i.e. when a predecessor of the operation node emits data). It receives the data to be sent along with the index of the port to which the data should be sent.
The result of this hook is ignored. Instead, this hook should use Skitter.Worker.send/2
to
transfer the received data to a worker.
context
Context
All context data (operation, strategy and deployment data) is available when this hook is called.
@callback deploy(context :: Skitter.Strategy.context()) :: Skitter.Strategy.deployment()
Deploy an operation over the cluster.
This hook is called by the runtime system when an operation has to be distributed over the
cluster. Any data returned by this hook is made available to other hooks through the
deployment
field in Skitter.Strategy.context/0
.
context
Context
When this hook is called, only the current strategy, operation and arguments are available in the context.
@callback process( context :: Skitter.Strategy.context(), message :: any(), state :: Skitter.Worker.state(), tag :: Skitter.Worker.tag() ) :: Skitter.Worker.state()
Handle a message received by a worker.
This hook is called by the runtime when a worker process receives a message. It is called with the received message, the data of the worker that received the message and its tag. This hook should return the new state of the worker that received the message.
context
Context
All context data (operation, strategy and the deployment data) is available when this hook is called.
Link to this section Functions
@spec emit(Skitter.Strategy.context(), Skitter.Operation.emit()) :: :ok
Emit values.
This function causes the current operation node to emit data. In other words, the provided data
will be sent to the operation nodes connected to the out ports of the current operation node.
This function accepts a keyword list of {out_port, enum}
pairs. Each element in enum
will be
sent to the in ports of the operation nodes connected to out_port
.
Note that data is emitted from the current worker. This may cause issues when infinite streams of data are emitted.