Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEmacs
    private fun onProcessNumber(command: ProcessNumber): Behavior<GraphCommand> {
        context.log.info("Received ProcessNumber command with number: ${command.number} - ${context.self.path().name()}")
        Source.single(command.number)
            .via(operation)
            .buffer(1000, OverflowStrategy.dropHead())
            .throttle(10, Duration.ofSeconds(1))
            .runWith(Sink.foreach { result -> command.replyTo.tell(ProcessedNumber(result)) }, materializer)
        return this
    }
  • 초기 셋업과정은 복잡할수 있지만~ 복잡한 성능고려 처리를 직관적이고 심플하게 이용할수 있습니다.


TestCode

Code Block
themeEmacs
    @Test
    fun testProcessNumberAdd() {
        val probe: TestProbe<GraphCommand> = testKit.createTestProbe()
        val graphActor: ActorRef<GraphCommand> = testKit.spawn(GraphActor.create())

        graphActor.tell(ProcessNumber(5, probe.ref))
        val response = probe.receiveMessage() as ProcessedNumber
        assertEquals(6, response.result)
    }

...