1 /* 2 * Make.org Core API 3 * Copyright (C) 2020 Make.org 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation, either version 3 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Affero General Public License for more details. 14 * 15 * You should have received a copy of the GNU Affero General Public License 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package org.make.api.technical 21 22 import akka.actor.typed.scaladsl.AskPattern._ 23 import akka.actor.typed.{ActorRef, Behavior, Props, SpawnProtocol} 24 import akka.util.Timeout 25 import grizzled.slf4j.Logging 26 27 import scala.concurrent.Future 28 29 trait SpawnActorService { 30 def spawn[T](behavior: Behavior[T], name: String, props: Props = Props.empty): Future[ActorRef[T]] 31 } 32 33 trait SpawnActorServiceComponent { 34 def spawnActorService: SpawnActorService 35 } 36 37 trait SpawnActorRefComponent { 38 def spawnActorRef: ActorRef[SpawnProtocol.Command] 39 } 40 41 trait DefaultSpawnActorServiceComponent extends SpawnActorServiceComponent with Logging { 42 this: ActorSystemComponent with SpawnActorRefComponent => 43 44 override val spawnActorService: SpawnActorService = new DefaultSpawnActorService 45 46 class DefaultSpawnActorService extends SpawnActorService { 47 48 implicit val timeout: Timeout = TimeSettings.defaultTimeout 49 50 override def spawn[T](behavior: Behavior[T], name: String, props: Props = Props.empty): Future[ActorRef[T]] = 51 spawnActorRef ? { replyTo: ActorRef[ActorRef[T]] => 52 SpawnProtocol.Spawn(behavior = behavior, name = name, props = props, replyTo = replyTo) 53 } 54 55 } 56 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 44 | 361 | 1481 - 1509 | Apply | org.make.api.technical.DefaultSpawnActorServiceComponent.DefaultSpawnActorService.<init> | org.make.api.technical.job.jobcoordinatorservicetest,org.make.api.technical.crm.crmservicecomponenttest | new DefaultSpawnActorServiceComponent.this.DefaultSpawnActorService() |
| 48 | 338 | 1609 - 1636 | Select | org.make.api.technical.TimeSettings.defaultTimeout | org.make.api.technical.job.jobcoordinatorservicetest,org.make.api.technical.crm.crmservicecomponenttest | TimeSettings.defaultTimeout |
| 51 | 331 | 1758 - 1913 | ApplyToImplicitArgs | akka.actor.typed.scaladsl.AskPattern.Askable.? | akka.actor.typed.scaladsl.AskPattern.Askable[akka.actor.typed.SpawnProtocol.Command](DefaultSpawnActorServiceComponent.this.spawnActorRef).?[akka.actor.typed.ActorRef[T]](((replyTo: akka.actor.typed.ActorRef[akka.actor.typed.ActorRef[T]]) => akka.actor.typed.SpawnProtocol.Spawn.apply[T](behavior, name, props, replyTo)))(DefaultSpawnActorService.this.timeout, akka.actor.typed.scaladsl.AskPattern.schedulerFromActorSystem(DefaultSpawnActorServiceComponent.this.actorSystem)) | |
| 51 | 370 | 1758 - 1771 | Select | org.make.api.technical.SpawnActorRefComponent.spawnActorRef | DefaultSpawnActorServiceComponent.this.spawnActorRef | |
| 51 | 377 | 1772 - 1772 | Select | org.make.api.technical.ActorSystemComponent.actorSystem | DefaultSpawnActorServiceComponent.this.actorSystem | |
| 51 | 344 | 1772 - 1772 | Select | org.make.api.technical.DefaultSpawnActorServiceComponent.DefaultSpawnActorService.timeout | DefaultSpawnActorService.this.timeout | |
| 51 | 353 | 1772 - 1772 | ApplyToImplicitArgs | akka.actor.typed.scaladsl.AskPattern.schedulerFromActorSystem | akka.actor.typed.scaladsl.AskPattern.schedulerFromActorSystem(DefaultSpawnActorServiceComponent.this.actorSystem) | |
| 52 | 349 | 1818 - 1905 | Apply | akka.actor.typed.SpawnProtocol.Spawn.apply | akka.actor.typed.SpawnProtocol.Spawn.apply[T](behavior, name, props, replyTo) |