<commit_before>package io.flow.play.actors

import akka.actor.ActorSystem
import io.flow.play.util.Config
import play.api.Logger
import play.api.Play.current
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._

/**
  * Common utilities to help with scheduling of actors with intervals
  * coming from configuration file.
  */
trait Scheduler {

  def config: Config

  /**
   * Helper to schedule a recurring interval based on a configuration
   * parameter.
   * 
   * Example:
   * 
   *   conf/base.conf:
   *     io.flow.delta.api.CheckProjects.seconds = 300
   *     io.flow.delta.api.CheckProjects.seconds_initial = 3
   * 
   *   conf/api/actors/...
   *     scheduleRecurring("io.flow.delta.api.CheckProjects.seconds") {
   *       periodicActor ! PeriodicActor.Messages.CheckProjects
   *     }
b   *
   * @param configName The name of the configuration parameter containing the number
   *        of seconds between runs. You can also optionally add a
   *        configuration parameter of the same name with "_inital"
   *        appended to set the initial interval if you wish it to be
   *        different.
   */
  def scheduleRecurring[T](
    system: ActorSystem,
    configName: String
  ) (
    f: => T
  ) (
    implicit ec: ExecutionContext
  ) {
    val seconds = config.requiredString(configName).toInt
    val initial = config.optionalString(s"${configName}_initial").map(_.toInt).getOrElse(seconds)
    Logger.info(s"[${getClass.getName}] scheduleRecurring[$configName]: Initial[$initial seconds], recurring[$seconds seconds]")
    system.scheduler.schedule(
      FiniteDuration(initial, SECONDS),
      FiniteDuration(seconds, SECONDS),
      new Runnable {
        def run = f
      }
    )
  }

}<commit_msg>Remove 'b'<commit_after>package io.flow.play.actors

import akka.actor.ActorSystem
import io.flow.play.util.Config
import play.api.Logger
import play.api.Play.current
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._

/**
  * Common utilities to help with scheduling of actors with intervals
  * coming from configuration file.
  */
trait Scheduler {

  def config: Config

  /**
   * Helper to schedule a recurring interval based on a configuration
   * parameter.
   * 
   * Example:
   * 
   *   conf/base.conf:
   *     io.flow.delta.api.CheckProjects.seconds = 300
   *     io.flow.delta.api.CheckProjects.seconds_initial = 3
   * 
   *   conf/api/actors/...
   *     scheduleRecurring("io.flow.delta.api.CheckProjects.seconds") {
   *       periodicActor ! PeriodicActor.Messages.CheckProjects
   *     }
   *
   * @param configName The name of the configuration parameter containing the number
   *        of seconds between runs. You can also optionally add a
   *        configuration parameter of the same name with "_inital"
   *        appended to set the initial interval if you wish it to be
   *        different.
   */
  def scheduleRecurring[T](
    system: ActorSystem,
    configName: String
  ) (
    f: => T
  ) (
    implicit ec: ExecutionContext
  ) {
    val seconds = config.requiredString(configName).toInt
    val initial = config.optionalString(s"${configName}_initial").map(_.toInt).getOrElse(seconds)
    Logger.info(s"[${getClass.getName}] scheduleRecurring[$configName]: Initial[$initial seconds], recurring[$seconds seconds]")
    system.scheduler.schedule(
      FiniteDuration(initial, SECONDS),
      FiniteDuration(seconds, SECONDS),
      new Runnable {
        def run = f
      }
    )
  }

}
{'fraction_non_alphanumeric': 0.09943181818181818, 'fraction_numerical': 0.0022727272727272726, 'mean_word_length': 2.9384787472035794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6873768', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1027, 'n_words': 260}