<commit_before>package uk.ac.wellcome.platform.sierra_reader.modules

import javax.inject.Singleton

import akka.actor.ActorSystem
import com.google.inject.Provides
import com.twitter.inject.annotations.Flag
import com.twitter.inject.{Injector, TwitterModule}
import uk.ac.wellcome.platform.sierra_reader.models.SierraResourceTypes
import uk.ac.wellcome.platform.sierra_reader.models.SierraResourceTypes.{
  bibs,
  items
}
import uk.ac.wellcome.platform.sierra_reader.services.SierraReaderWorkerService

object SierraReaderModule extends TwitterModule {
  flag[String]("reader.resourceType", "Sierra resource type")
  flag[Int]("reader.batchSize", 50, "Number of records in a single json batch")
  flag[String]("sierra.apiUrl", "", "Sierra API url")
  flag[String]("sierra.oauthKey", "", "Sierra API oauth key")
  flag[String]("sierra.oauthSecret", "", "Sierra API oauth secret")
  flag[String](
    "sierra.fields",
    "",
    "List of fields to include in the Sierra API response")

  // eagerly load worker service
  override def singletonStartup(injector: Injector) {
    super.singletonStartup(injector)
    injector.instance[SierraReaderWorkerService]
  }

  override def singletonShutdown(injector: Injector) {
    info("Terminating Sierra Bibs to SNS worker")

    val system = injector.instance[ActorSystem]
    val workerService = injector.instance[SierraReaderWorkerService]

    workerService.stop()
    system.terminate()
  }

  @Singleton
  @Provides
  def providesSierraResourceType(
    @Flag("reader.resourceType") resourceTypeString: String)
    : SierraResourceTypes.Value = {
    resourceTypeString match {
      case s: String if s == bibs.toString => bibs
      case s: String if s == items.toString => items
      case s: String =>
        throw new IllegalArgumentException(
          s"$s is not a valid Sierra resource type")
    }
  }
}<commit_msg>We don't need to call that stop() method<commit_after>package uk.ac.wellcome.platform.sierra_reader.modules

import javax.inject.Singleton

import akka.actor.ActorSystem
import com.google.inject.Provides
import com.twitter.inject.annotations.Flag
import com.twitter.inject.{Injector, TwitterModule}
import uk.ac.wellcome.platform.sierra_reader.models.SierraResourceTypes
import uk.ac.wellcome.platform.sierra_reader.models.SierraResourceTypes.{
  bibs,
  items
}
import uk.ac.wellcome.platform.sierra_reader.services.SierraReaderWorkerService

object SierraReaderModule extends TwitterModule {
  flag[String]("reader.resourceType", "Sierra resource type")
  flag[Int]("reader.batchSize", 50, "Number of records in a single json batch")
  flag[String]("sierra.apiUrl", "", "Sierra API url")
  flag[String]("sierra.oauthKey", "", "Sierra API oauth key")
  flag[String]("sierra.oauthSecret", "", "Sierra API oauth secret")
  flag[String](
    "sierra.fields",
    "",
    "List of fields to include in the Sierra API response")

  // eagerly load worker service
  override def singletonStartup(injector: Injector) {
    super.singletonStartup(injector)
    injector.instance[SierraReaderWorkerService]
  }

  override def singletonShutdown(injector: Injector) {
    info("Terminating Sierra Bibs to SNS worker")

    val system = injector.instance[ActorSystem]
    system.terminate()
  }

  @Singleton
  @Provides
  def providesSierraResourceType(
    @Flag("reader.resourceType") resourceTypeString: String)
    : SierraResourceTypes.Value = {
    resourceTypeString match {
      case s: String if s == bibs.toString => bibs
      case s: String if s == items.toString => items
      case s: String =>
        throw new IllegalArgumentException(
          s"$s is not a valid Sierra resource type")
    }
  }
}
{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.0010851871947911015, 'mean_word_length': 4.406158357771261, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3234734', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1094, 'n_words': 265}