<commit_before>package amora.backend

import java.nio.ByteBuffer

import scala.concurrent.Future
import scala.concurrent.Promise

import akka.NotUsed
import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.Props
import akka.http.scaladsl.marshalling.ToResponseMarshallable
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.RouteResult
import akka.stream.OverflowStrategy
import akka.stream.scaladsl.Flow
import akka.stream.scaladsl.Sink
import akka.stream.scaladsl.Source
import amora.backend.actors.IndexerActor
import amora.backend.actors.IndexerMessage
import amora.backend.actors.NvimActor
import amora.backend.actors.NvimMsg
import amora.backend.actors.QueueActor
import amora.backend.actors.QueueMessage
import amora.backend.actors.RequestActor
import amora.backend.actors.RequestMessage
import amora.backend.actors.WebSocketRequestActor
import amora.frontend.webui.protocol.IndexData

final class BackendSystem(implicit system: ActorSystem) {

  import system.dispatcher
  import PlatformConstants.timeout
  import akka.pattern.ask
  import boopickle.Default._

  private val nvim = system.actorOf(Props[NvimActor], "nvim")
  private val queue = system.actorOf(Props[QueueActor], "queue")
  private val indexer = system.actorOf(Props[IndexerActor], "indexer")
  private val requestHandler = system.actorOf(Props(classOf[WebSocketRequestActor], queue, indexer), "request-handler")

  def runQuery(query: String, errorMessage: String)(onSuccess: Any ⇒ ToResponseMarshallable): Route =
    mkRequestRoute(indexer, IndexerMessage.RunQuery(query), errorMessage, onSuccess)

  def runUpdate(query: String, errorMessage: String)(onSuccess: Any ⇒ ToResponseMarshallable): Route =
    mkRequestRoute(indexer, IndexerMessage.RunUpdate(query), errorMessage, onSuccess)
<commit_msg>Don't create actors through reflection<commit_after>package amora.backend

import java.nio.ByteBuffer

import scala.concurrent.Future
import scala.concurrent.Promise

import akka.NotUsed
import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.Props
import akka.http.scaladsl.marshalling.ToResponseMarshallable
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.RouteResult
import akka.stream.OverflowStrategy
import akka.stream.scaladsl.Flow
import akka.stream.scaladsl.Sink
import akka.stream.scaladsl.Source
import amora.backend.actors.IndexerActor
import amora.backend.actors.IndexerMessage
import amora.backend.actors.NvimActor
import amora.backend.actors.NvimMsg
import amora.backend.actors.QueueActor
import amora.backend.actors.QueueMessage
import amora.backend.actors.RequestActor
import amora.backend.actors.RequestMessage
import amora.backend.actors.WebSocketRequestActor
import amora.frontend.webui.protocol.IndexData

final class BackendSystem(implicit system: ActorSystem) {

  import system.dispatcher
  import PlatformConstants.timeout
  import akka.pattern.ask
  import boopickle.Default._

  private val nvim = system.actorOf(Props(new NvimActor), "nvim")
  private val queue = system.actorOf(Props(new QueueActor), "queue")
  private val indexer = system.actorOf(Props(new IndexerActor), "indexer")
  private val requestHandler = system.actorOf(Props(new WebSocketRequestActor(queue, indexer)), "request-handler")

  def runQuery(query: String, errorMessage: String)(onSuccess: Any ⇒ ToResponseMarshallable): Route =
    mkRequestRoute(indexer, IndexerMessage.RunQuery(query), errorMessage, onSuccess)

  def runUpdate(query: String, errorMessage: String)(onSuccess: Any ⇒ ToResponseMarshallable): Route =
    mkRequestRoute(indexer, IndexerMessage.RunUpdate(query), errorMessage, onSuccess)

{'fraction_non_alphanumeric': 0.08724100327153762, 'fraction_numerical': 0.0, 'mean_word_length': 6.675732217573222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5758963', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1089, 'n_words': 229}