package akkastrator
- Alphabetic
- Public
- All
Type Members
-
sealed abstract
class
AbstractOrchestrator[R] extends PersistentActor with AtLeastOnceDelivery with ActorLogging with IdImplicits
An Orchestrator executes a set of, possibly dependent,
Tasks
.An Orchestrator executes a set of, possibly dependent,
Tasks
. A task corresponds to sending a message to an actor, handling its response and possibly mutate the internal state of the Orchestrator.The Orchestrator together with the Task is able to:
- Delivering messages with at-least-once delivery guarantee. The
DistinctIdsOrchestrator
ensures each destination will see an independent strictly monotonically increasing sequence number without gaps. - Handling Status messages, that is, if some actor is interested in querying the Orchestrator for its current status, the Orchestrator will respond with the status of each task.
- When all the dependencies of a task finish that task will be started and the Orchestrator will be prepared to handle the messages that the task destination sends.
- If the Orchestrator crashes, the state of each task will be correctly restored.
NOTE: the responses that are received must be Serializable.
In order for the Orchestrator and the Tasks to be able to achieve all of this they have to access and modify each others state directly. This means they are very tightly coupled with each other. To make this relation more obvious and to enforce it, you will only be able to create tasks if you have a reference to an orchestrator (which is passed implicitly to a task).
If you have the need to refactor the creation of tasks so that you can use them in multiple orchestrators you can leverage self type annotations.
- R
the type of result this orchestrator returns when it finishes.
- Delivering messages with at-least-once delivery guarantee. The
-
case class
AtLeast(n: Int) extends MinimumVotes with Product with Serializable
A MinimumVotes function where at least
n
votes are needed to achieve a quorum. - class Bundle[R] extends Orchestrator[Seq[R]]
- final class CorrelationId extends AnyVal with Ordered[CorrelationId] with Id
- final class DeliveryId extends AnyVal with Id
-
abstract
class
DistinctIdsOrchestrator[R] extends AbstractOrchestrator[R]
In a DistinctIdsOrchestrator an independent sequence is used for each destination of the orchestrator.
In a DistinctIdsOrchestrator an independent sequence is used for each destination of the orchestrator. In this orchestrator the delivery id is not sufficient to disambiguate which task should handle the message, so the ID = CorrelationId and the matchId also needs to check the sender. There is also the added necessity of being able to compute the correlation id for a given (sender, deliveryId) as well as translating a correlation id back to a delivery id.
-
abstract
class
FullTask[R, DL <: HList] extends AnyRef
A full task represents a task plus its dependencies.
A full task represents a task plus its dependencies. It ensures a Task is only created when all of its dependencies have finished.
- R
the result type of this task.
- DL
the type of the dependencies HList.
- sealed trait Id extends Typed[Long]
- trait IdImplicits extends AnyRef
-
trait
MinimumVotes extends (Int) ⇒ Int
A function that calculates how many votes are needed to achieve a quorum, given the number of destinations.
-
abstract
class
Orchestrator[R] extends AbstractOrchestrator[R]
In a simple orchestrator the same sequence number (of akka-persistence) is used for all the destinations of the orchestrator.
In a simple orchestrator the same sequence number (of akka-persistence) is used for all the destinations of the orchestrator. Because of this, ID = DeliveryId, and matchId only checks the deliveryId as that will be enough information to disambiguate which task should handle the response.
- class Quorum[R] extends Orchestrator[R]
-
case class
Report[R](index: Int, description: String, dependencies: Seq[Int], state: State, destination: Option[ActorPath], result: Option[R]) extends Product with Serializable
An immutable representation (a report) of a Task in a given moment of time.
An immutable representation (a report) of a Task in a given moment of time.
- R
the type of the result.
- index
the task index this report pertains to.
- description
a text that describes the task in a human readable way. Or a message key to be used in internationalization.
- dependencies
the indexes of the tasks that must have finished in order for the task to be able to start.
- state
the current state of the task.
- destination
the destination of the task. If the task hasn't started this will be a None.
- result
the result of the task. If the task hasn't finished this will be a None.
-
final
case class
Settings(useTaskColors: Boolean = true, taskColors: Seq[String] = ...) extends Product with Serializable
This class holds all the settings that parameterize akkastrator.
This class holds all the settings that parameterize akkastrator.
If you would like to create an instance of settings from a typesafe config invoke
Settings.fromConfig
. - case class SpawnAndStart(props: Props, startId: Long) extends Product with Serializable
- class Spawner extends Actor with ActorLogging
-
abstract
class
Task[R] extends AnyRef
A task corresponds to sending a message to an actor, handling its response and possibly mutate the internal state of its Orchestrator.
A task corresponds to sending a message to an actor, handling its response and possibly mutate the internal state of its Orchestrator.
The answer(s) to the sent message must be handled in
behavior
.behavior
must invokefinish
when no further processing is necessary. Orabort
if the received message will prevent subsequent tasks from executing properly.The pattern matching inside
behavior
must invokematchId
to ensure the received message is in fact the one that this task its waiting to receive.The internal state of the orchestrator might be mutated inside
behavior
.This class is very tightly coupled with Orchestrator and the reverse is also true. See AbstractOrchestrator for more details on why that is the case.
- R
the return type of this Task.
-
class
TaskBundle[R] extends TaskSpawnOrchestrator[Seq[R], Bundle[R]]
A task that creates a variable number of tasks and succeeds when all the created tasks finish successfully.
A task that creates a variable number of tasks and succeeds when all the created tasks finish successfully. The return type of the tasks must be the same. Their messages and destinations are unrestrained.
This task is specially useful to create
n
tasks wheren
is computed from the result of another task.- R
the return type of the tasks created using
tasksCreator
.
-
class
TaskQuorum[R] extends TaskSpawnOrchestrator[R, Quorum[R]]
A task that creates a variable number of tasks and succeeds when
n
tasks finish producing the same result.A task that creates a variable number of tasks and succeeds when
n
tasks finish producing the same result.n
is calculated with the minimumVotes function. The return type and the message of the tasks must be the same. And their destinations must be different.The last two restrictions are validated in runtime when the quorum is created. If they fail the task will abort. To validate the messages are the same, each task message is compared via
!=
against the other tasks messages. -
class
TaskSpawnOrchestrator[R, O <: AbstractOrchestrator[R]] extends Task[R]
In order for this task to work correctly either: · The created orchestrator must send to its parent a Orchestrator.Success when it finishes and a Orchestrator.Failure when it aborts.
In order for this task to work correctly either: · The created orchestrator must send to its parent a Orchestrator.Success when it finishes and a Orchestrator.Failure when it aborts. And terminate afterwords of sending the messages. · Or the method behavior must be overridden to handle the messages the inner orchestrator sends when it terminates or aborts.
- R
the return type of this Task. Also the return type of the spawned orchestrator.
- O
the type of AbstractOrchestrator the Props must create.
Value Members
-
object
All extends MinimumVotes
A MinimumVotes function where all the votes are needed to achieve a quorum.
- object DSL
- object Event
- object HListConstraints
- object IdImplicits extends IdImplicits
-
object
Majority extends MinimumVotes
A MinimumVotes function where a majority of votes are needed to achieve a quorum.
- object Orchestrator
-
object
QuorumAlreadyAchieved extends Exception with Product with Serializable
Exception used to abort waiting tasks when the quorum was already achieved.
-
object
QuorumImpossibleToAchieve extends Exception with Product with Serializable
Signals that the quorum is impossible to achieve since enough tasks have aborted that prevent the orchestrator from achieving enough votes to satisfy the minimumVotes function.
-
object
QuorumNotAchieved extends Exception with Product with Serializable
Signals that every task in the Quorum has finished but a quorum has not achieved.
- object Settings extends Serializable
- object Task