scala
-
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..
-
Using ScalikeJDBCscala/playframework 2023. 2. 19. 20:30
http://scalikejdbc.org/documentation/playframework-support.html https://github.com/scalikejdbc/scalikejdbc-play-support build.sbt libraryDependencies ++= Seq( jdbc, guice, "mysql" % "mysql-connector-java" % "8.0.32", "org.scalikejdbc" %% "scalikejdbc" % "3.5.0", "org.scalikejdbc" %% "scalikejdbc-config" % "3.5.0", "org.scalikejdbc" %% "scalikejdbc-play-initializer" % "2.8.0-scalikejdbc-3.5", "or..
-
Logging MDCscala/playframework 2023. 2. 19. 01:40
https://github.com/playframework/play-samples/blob/2.8.x/play-scala-rest-api-example/app/v1/post/PostActionBuilder.scala#L29 참고 ------------------------------------------------------------------------------------------------------------ 개인적으로 만들어 본 것 import org.slf4j.MarkerFactory import play.api.MarkerContext import play.api.mvc.RequestHeader import java.util.UUID object Application { // marker..
-
Deployscala/playframework 2023. 2. 19. 01:33
https://www.playframework.com/documentation/2.8.x/Deploying {{ service_home }}/bin/{{ program }} -Dapplication.home={{ service_home }} -Dlogger.file={{ service_home }}/conf/logback.xml -Dplay.http.secret.key=f4175469aec955dc23c054e41c4bbe48 -Dpidfile.path={{ service_home }}/server.pid -Dhttp.port=12132 -Dconfig.file={{ service_home }}/conf/application.conf
-
Filterscala/playframework 2023. 2. 19. 01:22
https://www.playframework.com/documentation/2.8.x/Filters import javax.inject._ import play.api.mvc._ import scala.concurrent.ExecutionContext /** * This is a simple filter that adds a header to all requests. It's * added to the application's list of filters by the * [[Filters]] class. * * @param ec This class is needed to execute code asynchronously. * It is used below by the `map` method. */ @..