<commit_before>package controllers

import models.{AssetLifecycle, MetaWrapper, Model, Status => AStatus}
import util.{Provisioner, SoftLayer}
import com.tumblr.play.{CommandResult, ProvisionerRequest}
import com.twitter.util.Future

import akka.actor.Actor._
import akka.actor.Actor
import akka.dispatch.FutureTimeoutException
import akka.routing._
import akka.util.Duration
import akka.util.duration._

import play.api.libs.akka._
import play.api.libs.concurrent.{Redeemed, Thrown}
import play.api.mvc.{AnyContent, Request}

case class AssetUpdateProcessor(tag: String, userTimeout: Option[Duration] = None)(implicit req: Request[AnyContent])
  extends BackgroundProcess[Either[ResponseData,Boolean]]
{
  val timeout = userTimeout.getOrElse(defaultTimeout)

  def run(): Either[ResponseData,Boolean] = {
    val assetUpdater = actions.UpdateAsset.get()
    assetUpdater.execute(tag)
  }
}

case class ProvisionerProcessor(request: ProvisionerRequest, userTimeout: Option[Duration] = None)(implicit req: Request[AnyContent]) extends BackgroundProcess[CommandResult]
{
  override def defaultTimeout: Duration = Duration.parse("60 seconds")
  val timeout = userTimeout.getOrElse(defaultTimeout)

  def run(): CommandResult = {
    Provisioner.pluginEnabled { plugin =>
      val future = plugin.test(request).flatMap { res =>
        if (res.exitCode == 0) {
          plugin.provision(request)
        } else {
          Future(res)
        }
      }
      future()
    }.getOrElse(CommandResult(-2, "Provisioner plugin not enabled"))
  }
}

sealed trait BackgroundProcess[T] {
  val timeout: Duration
  def run(): T

  protected def defaultTimeout: Duration = {
    val config = util.Helpers.subAsMap("")
    Duration.parse(config.getOrElse("timeout", "2 seconds"))<commit_msg>Upgraded to latest collins ruby lib<commit_after>package controllers

import models.{AssetLifecycle, MetaWrapper, Model, Status => AStatus}
import util.{Provisioner, SoftLayer}
import com.tumblr.play.{CommandResult, ProvisionerRequest}
import com.twitter.util.Future

import akka.actor.Actor._
import akka.actor.Actor
import akka.dispatch.FutureTimeoutException
import akka.routing._
import akka.util.Duration
import akka.util.duration._

import play.api.libs.akka._
import play.api.libs.concurrent.{Redeemed, Thrown}
import play.api.mvc.{AnyContent, Request}

case class AssetUpdateProcessor(tag: String, userTimeout: Option[Duration] = None)(implicit req: Request[AnyContent])
  extends BackgroundProcess[Either[ResponseData,Boolean]]
{
  val timeout = userTimeout.getOrElse(defaultTimeout)

  def run(): Either[ResponseData,Boolean] = {
    val assetUpdater = actions.UpdateAsset.get()
    assetUpdater.execute(tag)
  }
}

case class ProvisionerProcessor(request: ProvisionerRequest, userTimeout: Option[Duration] = None)(implicit req: Request[AnyContent]) extends BackgroundProcess[CommandResult]
{
  override def defaultTimeout: Duration = Duration.parse("90 seconds")
  val timeout = userTimeout.getOrElse(defaultTimeout)

  def run(): CommandResult = {
    Provisioner.pluginEnabled { plugin =>
      val future = plugin.test(request).flatMap { res =>
        if (res.exitCode == 0) {
          plugin.provision(request)
        } else {
          Future(res)
        }
      }
      future()
    }.getOrElse(CommandResult(-2, "Provisioner plugin not enabled"))
  }
}

sealed trait BackgroundProcess[T] {
  val timeout: Duration
  def run(): T

  protected def defaultTimeout: Duration = {
    val config = util.Helpers.subAsMap("")
    Duration.parse(config.getOrElse("timeout", "2 seconds"))
{'fraction_non_alphanumeric': 0.11011738401341531, 'fraction_numerical': 0.002794857462269424, 'mean_word_length': 4.627358490566038, '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': '7653007', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1043, 'n_words': 238}