View Source Skitter.Strategy (Skitter v0.7.1)
Strategy type definition and utilities.
A strategy is a reusable piece of logic which determines how an operation is distributed at runtime. It is defined as a collection of hooks: functions which each define an aspect of the distributed behaviour of an operation.
An operation strategy is defined as an elixir module which implements the
Skitter.Strategy.Operation
behaviour. It is recommended to define a strategy using
Skitter.DSL.Strategy.defstrategy/3
.
This module defines the strategy and context types.
Summary
Types
Context information for strategy hooks.
Immutable data of a data processing pipeline.
A strategy is defined as a module.
Types
@type context() :: %Skitter.Strategy.Context{ _skr: any(), deployment: deployment() | nil, operation: Skitter.Operation.t(), strategy: t() }
Context information for strategy hooks.
A strategy hook often needs information about the context in which it is being called. Relevant information about the context is stored inside the context, which is passed as the first argument to every hook.
The following information is stored:
operation
: The operation for which the hook is called.strategy
: The strategy of the operation.deployment
: The current deployment data.nil
if the deployment is not created yet (e.g. indeploy
)_skr
: Data stored by the runtime system. This data should not be accessed or modified.
@type deployment() :: any()
Immutable data of a data processing pipeline.
A strategy which is deployed over the cluster has access to an immutable set of data which is
termed the deployment. A strategy can specify which data to store in its deployment inside the
Skitter.Strategy.Operation.deploy/2
hook. Afterwards, the other strategy hooks have access
to the data stored within the deployment.
Note that an operation strategy can only access its own deployment data.
@type t() :: module()
A strategy is defined as a module.