<commit_before>package io.flow.proxy

import io.apibuilder.spec.v0.models.Service
import io.flow.build.{Application, BuildType, Downloader}
import io.flow.registry.v0.{Client => RegistryClient}
import Text._

case class Controller() extends io.flow.build.Controller {

  /**
    * Whitelist of applications in the 'api' repo that do not exist in registry
    */
  private[this] val ExcludeWhiteList = Seq("common", "healthcheck", "usage", "optin")

  /**
    * This is the hostname of the services when running in docker on
    * our development machines.
    */
  private[this] val DockerHostname = "172.17.0.1"

  private[this] val DevelopmentHostname = "localhost"

  override val name = "Proxy"
  override val command = "proxy"

  def run(
    buildType: BuildType,
    downloader: Downloader,
    allServices: Seq[Service]
  ) (
    implicit ec: scala.concurrent.ExecutionContext
  ) {
    val services = allServices.
      filter { s => s.resources.nonEmpty }.
      filter { s => !ExcludeWhiteList.contains(s.name) }

    println("Building proxy from: " + services.map(_.name).mkString(", "))

    def serviceHost(name: String): String = {
      buildType match {
        case BuildType.Api => name.toLowerCase
        case BuildType.ApiEvent => name.toLowerCase
        case BuildType.ApiInternal => Text.stripSuffix(name.toLowerCase, "-internal")
        case BuildType.ApiInternalEvent => Text.stripSuffix(name.toLowerCase, "-internal-event")
        case BuildType.ApiPartner => name.toLowerCase
      }
    }

    val version = downloader.service(Application("flow", buildType.toString, "latest")) match {
      case Left(error) => {
        sys.error(s"Failed to download '$buildType' service from apibuilder: $error")
      }
      case Right(svc) => {
        svc.version
      }
    }

    val registryClient = new RegistryClient()
    try {
      build(buildType, services, version, "production") { service =>
        s"https://${serviceHost(service.name)}.api.flow.io"<commit_msg>Handling service excludes for internal services<commit_after>package io.flow.proxy

import io.apibuilder.spec.v0.models.Service
import io.flow.build.{Application, BuildType, Downloader}
import io.flow.registry.v0.{Client => RegistryClient}
import Text._

case class Controller() extends io.flow.build.Controller {

  /**
    * Whitelist of applications in the 'api' repo that do not exist in registry
    */
  private[this] val ExcludeWhiteList = Seq("common", "healthcheck", "usage", "optin")

  /**
    * This is the hostname of the services when running in docker on
    * our development machines.
    */
  private[this] val DockerHostname = "172.17.0.1"

  private[this] val DevelopmentHostname = "localhost"

  override val name = "Proxy"
  override val command = "proxy"

  def run(
    buildType: BuildType,
    downloader: Downloader,
    allServices: Seq[Service]
  ) (
    implicit ec: scala.concurrent.ExecutionContext
  ) {
    val services = allServices.
      filter { s => s.resources.nonEmpty }.
      filterNot { s => ExcludeWhiteList.exists(s.name.startsWith) }

    println("Building proxy from: " + services.map(_.name).mkString(", "))

    def serviceHost(name: String): String = {
      buildType match {
        case BuildType.Api => name.toLowerCase
        case BuildType.ApiEvent => name.toLowerCase
        case BuildType.ApiInternal => Text.stripSuffix(name.toLowerCase, "-internal")
        case BuildType.ApiInternalEvent => Text.stripSuffix(name.toLowerCase, "-internal-event")
        case BuildType.ApiPartner => name.toLowerCase
      }
    }

    val version = downloader.service(Application("flow", buildType.toString, "latest")) match {
      case Left(error) => {
        sys.error(s"Failed to download '$buildType' service from apibuilder: $error")
      }
      case Right(svc) => {
        svc.version
      }
    }

    val registryClient = new RegistryClient()
    try {
      build(buildType, services, version, "production") { service =>
        s"https://${serviceHost(service.name)}.api.flow.io"
{'fraction_non_alphanumeric': 0.11977233358079684, 'fraction_numerical': 0.004454342984409799, 'mean_word_length': 3.2236154649947752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '969125', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1186, 'n_words': 296}