<commit_before>package api

import model._
import org.scalajs.dom.ext.Ajax
import org.scalajs.dom.raw._
import upickle._
import util.EventsCustomParser.DockerEventStream
import util.PullEventsCustomParser.{EventStatus, EventStream}
import util.logger._
import util.{EventsCustomParser, PullEventsCustomParser}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.{Future, Promise}
import scala.scalajs.js

case class DockerClient(connection: Connection) {

  val HttpTimeOut = 10 * 1000
  // 10 seconds
  val PingTimeOut = 4 * 1000

  val DockerVersion = "v1.17"
  val url = connection.url + "/" + DockerVersion

  // https://docs.docker.com/reference/api/docker_remote_api_v1.17/#ping-the-docker-server
  def ping(): Future[Unit] =
    Ajax.get(url = s"$url/_ping", timeout = PingTimeOut).map { xhr =>
      log.info("[dockerClient.ping] return: " + xhr.responseText)
    }


  def metadata(): Future[DockerMetadata] = for {
    test <- ping()
    info <- info()<commit_msg>Clean up, Move Docker Client config to an object.<commit_after>package api

import api.DockerClientConfig.APIRequired._
import model._
import org.scalajs.dom.ext.Ajax
import org.scalajs.dom.raw._
import upickle._
import util.EventsCustomParser.DockerEventStream
import util.PullEventsCustomParser.{EventStatus, EventStream}
import util.logger._
import util.{EventsCustomParser, PullEventsCustomParser}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.{Future, Promise}
import scala.scalajs.js

object DockerClientConfig {
  val HttpTimeOut = 10 * 1000
  val PingTimeOut = 4 * 1000
  val DockerVersion = s"v$Mayor.$Minor"

  object APIRequired {
    val Mayor = 1
    val Minor = 17
  }
}

case class DockerClient(connection: Connection) {

  import DockerClientConfig._

  val url = connection.url + "/" + DockerVersion

  // https://docs.docker.com/reference/api/docker_remote_api_v1.17/#ping-the-docker-server
  def ping(): Future[Unit] =
    Ajax.get(url = s"$url/_ping", timeout = PingTimeOut).map { xhr =>
      log.info("[dockerClient.ping] return: " + xhr.responseText)
    }


  def metadata(): Future[DockerMetadata] = for {
    test <- ping()
    info <- info()
{'fraction_non_alphanumeric': 0.11493212669683257, 'fraction_numerical': 0.016289592760180997, 'mean_word_length': 4.251781472684086, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6329196', 'n_tokens_mistral': 760, 'n_tokens_neox': 695, 'n_words': 155}