def this()

in server/src/main/scala/com/twitter/server/handler/TunableHandler.scala [56:108]


  def this() = this(() => StandardTunableMap.registeredIds)

  // Classes used to compose a "view" of a TunableMap, which is returned to the user as a JSON
  // string.

  /**
   * View of a [[TunableMap]] suitable for presentation
   *
   * @param id  id which this [[TunableMap]] representation corresponds to
   * @param tunables  representation of the [[Tunable]]s in the [[TunableMap]]
   */
  private[this] case class TunableMapView(id: String, tunables: Seq[TunableView])

  /**
   * View of a [[Tunable]] suitable for presentation
   *
   * @param id  id of the [[Tunable]]
   * @param value  the current value of the [[Tunable]]
   * @param components  the components that this [[Tunable]] is composed of. These compositions
   *                    are a reflection of the composition of [[TunableMap]]s that make up the
   *                    [[TunableMap]] for a given id. If a [[Tunable]] with the same key occurs
   *                    in multiple of these maps, the different values will be the [[Components]]
   */
  private[this] case class TunableView(id: String, value: String, components: Seq[Component])

  /**
   * View of a [[Tunable]] value that composes a [[Tunbable]] in a composed [[TunableMap]]
   *
   * @param source  the source of the value, i.e. `TunableMap.Entry.source`
   * @param value   value of the component
   */
  private[this] case class Component(source: String, value: String)

  private[this] def respond(
    status: Status,
    content: String,
    headers: Iterable[(String, Object)] = Seq.empty
  ): Future[Response] =
    newResponse(
      status = status,
      contentType = "text/plain;charset=UTF-8",
      headers = headers,
      content = Buf.Utf8(content)
    )

  private[this] def findMutable(
    maps: Map[String, TunableMap],
    id: String
  ): Option[TunableMap.Mutable] = maps.get(id).flatMap {
    TunableMap.components(_).collectFirst {
      case mut: TunableMap.Mutable => mut
    }
  }