Hi All,

this question about design, for example now I have some process that load 
task list and try process each task, it looks like this:

import scala.concurrent.{ExecutionContext, Future}


case class TaskId(processorName: String, id: String)

case class TaskDetails(id: TaskId, status: String, json: String)

trait DAO {
  def loadTaskIds(processorName: String): Future[Seq[TaskId]]

  def loadTaskDetails(id: TaskId): Future[Option[TaskDetails]]

  def deleteTask(id: TaskId): Future[Boolean]

  def markSuccess(id: TaskId): Future[Boolean]
}

class Processor(name: String, dao: DAO, implicit val ec: ExecutionContext) {
  def process(): Unit = {
    dao
      .loadTaskIds(name)
      .map(_.map {
      case taskId =>
        dao.loadTaskDetails(taskId).flatMap {
          case None =>
            delete(taskId)
          case Some(task) if task.status == "success" =>
            delete(taskId)
          case Some(task) =>
            doProcess(task).flatMap {
              case true =>
                dao.markSuccess(taskId).map {
                  case true =>
                    Some(task)
                  case false =>
                    // log.error(...)
                    None
                }
              case false =>
                // log.error(...)
                Future.successful(None)
            }
        }
    }).map {
      case processingFutures =>
        Future.sequence(processingFutures).map(_.flatten).map {
          case completedTasks =>
          // log.info(s"Processing '$name' tasks, complete 
[${completedTasks.map(_.id).mkString(", ")}]")
        }
    }
  }

  private def doProcess(task: TaskDetails): Future[Boolean] = ???

  private def delete(taskId: TaskId): Future[Option[TaskDetails]] =
    dao.deleteTask(taskId).map {
      case true =>
        None
      case false =>
        // log.error(...)
        None
    }
}


My question: how I need to change this code for getting 'True' Actor based 
application without using futures or ask pattern.

PS: I read that I need use only actor tell (!) but I can't understand how I 
can rewrite my logic and DAO as an actor.

With best regards, Vladimir.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to