Package

pt.tecnico.dsi

akkastrator

Permalink

package akkastrator

Visibility
  1. Public
  2. All

Type Members

  1. sealed abstract class AbstractOrchestrator extends PersistentActor with AtLeastOnceDelivery with ActorLogging with IdImplicits

    Permalink

    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:

    • Handling the persistence of the internal state maintained by both the Orchestrator and the Tasks.
    • Delivering messages with at-least-once delivery guarantee. The Orchestrator 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.
    • Tasks that have no dependencies will be started right away and the Orchestrator will, from that point onwards, be prepared to handle the responses to the sent messages.
    • If the Orchestrator crashes, the state it maintains 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 inside an orchestrator.

    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 like so:

    trait DatabaseTasks { self: Orchestrator =>
      def createQueryTask(): Task = new Task("") {
        val destination: ActorPath = ???
        def createMessage(correlationId: CorrelationId): Any = ???
    
        def behavior: Receive = ???
      }
    }
  2. final class CorrelationId extends AnyVal with Ordered[CorrelationId] with Id

    Permalink
  3. case class CreateAndStartTasks[R](collection: Seq[R], id: Long) extends Product with Serializable

    Permalink
  4. final class DeliveryId extends AnyVal with Ordered[DeliveryId] with Id

    Permalink
  5. trait DistinctIds extends AnyRef

    Permalink
  6. abstract class DistinctIdsOrchestrator extends AbstractOrchestrator

    Permalink
  7. sealed trait Event extends AnyRef

    Permalink
  8. case class Finished[R](result: R) extends TaskState with Product with Serializable

    Permalink
  9. sealed trait Id extends Typed[Long]

    Permalink
  10. trait IdImplicits extends AnyRef

    Permalink
  11. case class MessageReceived(taskIndex: Int, response: Serializable) extends Event with Product with Serializable

    Permalink
  12. case class MessageSent(taskIndex: Int) extends Event with Product with Serializable

    Permalink
  13. class MinimalState extends State with DistinctIds

    Permalink

    The simplest implementation of a State with DistinctIds.

    The simplest implementation of a State with DistinctIds. The is the default state used by a DistinctIdsOrchestrator.

    It is not a case class so the user can extend it and implement more complex states.

  14. abstract class Orchestrator extends AbstractOrchestrator

    Permalink
  15. class Settings extends AnyRef

    Permalink

    This class holds all the settings that parameterize akkastrator.

    This class holds all the settings that parameterize akkastrator.

    By default these settings are read from the Config obtained with ConfigFactory.load().

    You can change the settings in multiple ways:

    • Change them in the default configuration file (e.g. application.conf)
    • Pass a different config holding your configurations:
    new Settings(yourConfig)

    However it will be more succinct to pass your config directly to your akkastrator:

    context.actorOf(Props(classOf[YourAkkastrator], yourConfig))
    • Extend this class overriding the settings you want to redefine
    object YourSettings extends Settings() {
      override val saveSnapshotEveryXMessages = 1000
    }
    context.actorOf(Props(classOf[YourAkkastrator], YourSettings))
  16. trait State extends AnyRef

    Permalink
  17. case class StatusResponse(tasks: IndexedSeq[TaskReport]) extends Product with Serializable

    Permalink
  18. abstract class Task[R] extends AnyRef

    Permalink

    A task corresponds to sending a message to an actor, handling its response and possibly mutate the internal state of the Orchestrator.

    A task corresponds to sending a message to an actor, handling its response and possibly mutate the internal state of the Orchestrator.

    The answer(s) to the sent message must be handled in behavior. behavior must invoke finish when no further processing is necessary or terminateEarly if the received message will prevent subsequent tasks from executing properly.

    The pattern matching inside behavior must invoke matchId 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. Because of this you can only create instances of Task inside an orchestrator.

  19. abstract class TaskBundle[I, R] extends Task[Seq[R]]

    Permalink

    TaskBundle: Variable number of tasks Fixed destination Different messages

  20. case class TaskReport(description: String, dependencies: Set[Int], destination: ActorPath, state: TaskState) extends Product with Serializable

    Permalink
  21. sealed trait TaskState extends AnyRef

    Permalink
  22. case class TasksFinished[R](results: Seq[R], id: Long) extends Product with Serializable

    Permalink
  23. case class Waiting(expectedDeliveryId: DeliveryId) extends TaskState with Product with Serializable

    Permalink

Value Members

  1. object Aborted extends TaskState with Product with Serializable

    Permalink
  2. object EmptyState extends State with Product with Serializable

    Permalink
  3. object IdImplicits extends IdImplicits

    Permalink
  4. object SaveSnapshot extends Product with Serializable

    Permalink
  5. object StartReadyTasks extends Product with Serializable

    Permalink
  6. object Status extends Product with Serializable

    Permalink
  7. object Unstarted extends TaskState with Product with Serializable

    Permalink

Ungrouped