All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.server.view.StackRegistryView.scala Maven / Gradle / Ivy

There is a newer version: 18.9.1
Show newest version
package com.twitter.server.view

import com.twitter.finagle.util.StackRegistry

private[server] object StackRegistryView {
  /**
   * Render a stack entry, along with its params, in an html template.
   * @param entry The stack registry entry.
   * @param statScope The finagle StatsReceiver scope with which the
   * entries stats are exported. If present, the html page will link
   * to the metrics graphs for this entry.
   */
  def render(
    entry: StackRegistry.Entry,
    statScope: Option[String]
  ): String = {

    def renderParams(params: Seq[(String, String)]): String =
      (for ((field, value) <- params) yield {
        s"""
              ${field}
              ${value}
            """
      }).mkString("\n")

    val modules = entry.modules

    s"""

${entry.name} ${entry.addr}

${ (for (scope <- statScope) yield { s""" Watch metrics for ${entry.name} """ }).getOrElse("") }

${ (for (StackRegistry.Module(role, desc, params) <- modules) yield { s"""
${role}

${desc}

${ if (params.isEmpty) "" else { s"""${renderParams(params)}
Parameter Value
""" } }
""" }).mkString("\n") }
""" } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy