scala
-
airframe-control: Parallelscala/airframe 2023. 7. 6. 16:39
airframe-control 의 Parallel 을 테스트 해 본다. 코드 import wvlet.airframe.control.Parallel import java.text.SimpleDateFormat import java.util.Date object AirframeParallel { def now(): String = { val pattern = "HH:mm:ss.SSSZ" val simpleDateFormat = new SimpleDateFormat(pattern) simpleDateFormat.format(new Date()) } def main(args: Array[String]): Unit = { val source: Seq[Int] = Seq(1, 2, 3, 4, 5) println(s..
-
BeforeAndAfterAllscala/scalatest 2023. 3. 21. 20:57
전체 테스트에서 수행 전/후 로 한번씩만 수행 import org.scalatest.BeforeAndAfterAll import org.scalatest.funsuite.AnyFunSuite class MyTest extends AnyFunSuite with BeforeAndAfterAll { override protected def beforeAll(): Unit = println("START") override protected def afterAll(): Unit = println("END") test("test1") { println("test1") } test("test2") { println("test2") } } 출력 결과 START test1 test2 END
-
BeforeAndAfterscala/scalatest 2023. 3. 21. 20:54
test 마다 before / after 가 호출 됨 import org.scalatest.BeforeAndAfter import org.scalatest.funsuite.AnyFunSuite class MyTest extends AnyFunSuite with BeforeAndAfter { before { println("START") } after { println("END") } test("test1") { println("test1") } test("test2") { println("test2") } } 출력 결과 START test1 END START test2 END
-
CustomExecutionContext 설정scala/playframework 2023. 3. 1. 22:13
Custom ExecutionContext 생성 import akka.actor.ActorSystem import play.api.libs.concurrent.CustomExecutionContext class PostExecutionContext @Inject()(actorSystem: ActorSystem) extends CustomExecutionContext(actorSystem, "repository.dispatcher") application.conf 에 ExecutionContext 설정 repository.dispatcher { executor = "thread-pool-executor" throughput = 1 thread-pool-executor { fixed-pool-size = 4..
-
ScalaTestscala/playframework 2023. 2. 19. 23:48
app/conf/routes GET /api controllers.ApiController.api(x: Int, y: Int ?= 10) app/services/Adder.scala package services import javax.inject.Singleton trait Adder { def add(x: Int, y: Int): Int } @Singleton class ServiceAdder extends Adder { override def add(x: Int, y: Int): Int = x + y } app/controllers/ApiController.scala package controllers import play.api.mvc._ import services.Adder import jav..