Packages

abstract class Router[Input, +Route] extends (Input) => Result with ClosableOnce with Logging

A generic interface for routing an input to an optional matching route.

Input

The Input type used when determining a route destination

Route

The resulting route type. A Route may have dynamic properties and may be found to satisfy multiple Input instances. As there may not be a 1-to-1 mapping of Input to Route, it is encouraged that a Route encapsulates its relationship to an Input. An example to consider would be an HTTP Router. An HTTP request contains a Method (i.e. GET, POST) and a URI. A Router for a REST API may match "GET /users/{id}" for multiple HTTP requests (i.e. "GET /users/123" AND "GET /users/456" would map to the same destination Route). As a result, the Route in this example should be aware of the method, path, and and the destination/logic responsible for handling an Input that matches. Another property to consider for a Route is "uniqueness". A Router should be able to determine either: a) a single Route for an Input b) no Route for an Input A Router should NOT be expected to return multiple routes for an Input.

Note

A Router should be considered immutable unless explicitly noted.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Router
  2. Logging
  3. ClosableOnce
  4. CloseOnce
  5. Closable
  6. Function1
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Router(label: String, routes: Iterable[Route])

    Java-friendly constructor

  2. new Router(label: String, routes: Iterable[Route])

    label

    A label used for identifying this Router (i.e. for distinguishing between Router instances in error messages or for StatsReceiver scope).

    routes

    All of the Route routes contained within this Router This property is used to linearly determine the routes when close() is called. It may also be used as a way to determine what routes are defined within a Router (i.e. for generating meaningful error messages). This property does not imply any relationship with apply or find or that a Router's runtime behavior needs to be linear.

Abstract Value Members

  1. abstract def find(input: Input): Result

    Logic used to determine if this Router contains a Route for an Input.

    Logic used to determine if this Router contains a Route for an Input.

    input

    The Input to determine a route for.

    returns

    Found(input: Input, route: Route) if a matching route is defined, NotFound if a route destination is not defined for the Input.

    Attributes
    protected
    Note

    This method is only meant to be called within the Router's apply, which handles lifecycle concerns. It should not be accessed directly.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def andThen[A](g: (Result) => A): (Input) => A
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  5. final def apply(input: Input): Result

    Attempt to route an Input to a Route route known by this Router.

    Attempt to route an Input to a Route route known by this Router.

    input

    The Input to use for determining an available route

    returns

    Found(input: Input, route: Route) if a route is found to match, NotFound if there is no match, or RouterClosed if close() has been initiated on this Router and subsequent routing attempts are received.

    Definition Classes
    Router → Function1
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  8. final def close(deadline: Time): Future[Unit]

    Close the resource with the given deadline.

    Close the resource with the given deadline. This deadline is advisory, giving the callee some leeway, for example to drain clients or finish up other tasks.

    Definition Classes
    CloseOnceClosable
  9. def close(after: Duration): Future[Unit]

    Close the resource with the given timeout.

    Close the resource with the given timeout. This timeout is advisory, giving the callee some leeway, for example to drain clients or finish up other tasks.

    Definition Classes
    Closable
  10. final def close(): Future[Unit]

    Close the resource.

    Close the resource. The returned Future is completed when the resource has been fully relinquished.

    Definition Classes
    Closable
  11. final def closeFuture: Future[Unit]

    The Future satisfied upon completion of close.

    The Future satisfied upon completion of close.

    Attributes
    protected
    Definition Classes
    CloseOnce
    Note

    we do not expose direct access to the underlying closePromise, because the Promise state is mutable - we only want mutation to occur within this CloseOnce trait.

  12. def closeOnce(deadline: Time): Future[Unit]

    Attributes
    protected
    Definition Classes
    RouterCloseOnce
    Note

    NonFatal exceptions encountered when calling close() on a Route will be suppressed and Fatal exceptions will take on the same exception behavior of a Future.join.

  13. def compose[A](g: (A) => Input): (A) => Result
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  14. def debug(marker: Marker, message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  15. def debug(message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  16. def debug(marker: Marker, message: => Any): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  17. def debug(message: => Any): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  18. def debugResult[T](message: => String)(fn: => T): T

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger.

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger. The incoming string message should contain a single %s which will be replaced with the result[T] of the given function.

    Example:

    infoResult("The answer is: %s") {"42"}
    Attributes
    protected[this]
    Definition Classes
    Logging
  19. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  21. def error(marker: Marker, message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  22. def error(message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  23. def error(marker: Marker, message: => Any): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  24. def error(message: => Any): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  25. def errorResult[T](message: => String)(fn: => T): T

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger.

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger. The incoming string message should contain a single %s which will be replaced with the result[T] of the given function.

    Example:

    infoResult("The answer is: %s") {"42"}
    Attributes
    protected[this]
    Definition Classes
    Logging
  26. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  27. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. def info(marker: Marker, message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  30. def info(message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  31. def info(marker: Marker, message: => Any): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  32. def info(message: => Any): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  33. def infoResult[T](message: => String)(fn: => T): T

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger.

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger. The incoming string message should contain a single %s which will be replaced with the result[T] of the given function.

    Example:

    infoResult("The answer is: %s") {"42"}
    Attributes
    protected[this]
    Definition Classes
    Logging
  34. final def isClosed: Boolean

    Signals whether or not this Closable has been closed.

    Signals whether or not this Closable has been closed.

    returns

    return true if close has been initiated, false otherwise

    Definition Classes
    CloseOnce
  35. def isDebugEnabled(marker: Marker): Boolean

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data.

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  36. def isDebugEnabled: Boolean

    Determines if the named log level is enabled on the underlying logger.

    Determines if the named log level is enabled on the underlying logger. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  37. def isErrorEnabled(marker: Marker): Boolean

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data.

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  38. def isErrorEnabled: Boolean

    Determines if the named log level is enabled on the underlying logger.

    Determines if the named log level is enabled on the underlying logger. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  39. def isInfoEnabled(marker: Marker): Boolean

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data.

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  40. def isInfoEnabled: Boolean

    Determines if the named log level is enabled on the underlying logger.

    Determines if the named log level is enabled on the underlying logger. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  41. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  42. def isTraceEnabled(marker: Marker): Boolean

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data.

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  43. def isTraceEnabled: Boolean

    Determines if the named log level is enabled on the underlying logger.

    Determines if the named log level is enabled on the underlying logger. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  44. def isWarnEnabled(marker: Marker): Boolean

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data.

    Determines if the named log level is enabled on the underlying logger taking into consideration the given org.slf4j.Marker data. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  45. def isWarnEnabled: Boolean

    Determines if the named log level is enabled on the underlying logger.

    Determines if the named log level is enabled on the underlying logger. Returns true if enabled, false otherwise.

    Attributes
    protected[this]
    Definition Classes
    Logging
  46. val label: String
  47. final def logger: Logger

    Return the underlying com.twitter.util.logging.Logger

    Return the underlying com.twitter.util.logging.Logger

    returns

    a com.twitter.util.logging.Logger

    Attributes
    protected[this]
    Definition Classes
    Logging
  48. final def loggerName: String

    Return the name of the underlying com.twitter.util.logging.Logger

    Return the name of the underlying com.twitter.util.logging.Logger

    returns

    a String name

    Attributes
    protected[this]
    Definition Classes
    Logging
  49. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  50. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  51. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  52. val routes: Iterable[Route]
  53. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  54. def toString(): String
    Definition Classes
    Function1 → AnyRef → Any
  55. def trace(marker: Marker, message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  56. def trace(message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  57. def trace(marker: Marker, message: => Any): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  58. def trace(message: => Any): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  59. def traceResult[T](message: => String)(fn: => T): T

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger.

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger. The incoming string message should contain a single %s which will be replaced with the result[T] of the given function.

    Example:

    infoResult("The answer is: %s") {"42"}
    Attributes
    protected[this]
    Definition Classes
    Logging
  60. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  61. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  62. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  63. def warn(marker: Marker, message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  64. def warn(message: => Any, cause: Throwable): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  65. def warn(marker: Marker, message: => Any): Unit

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Logs the given message at the named log level with the underlying logger taking into consideration the given org.slf4j.Marker data.

    Attributes
    protected[this]
    Definition Classes
    Logging
  66. def warn(message: => Any): Unit

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Logs the given message at the named log level using call-by-name for the message parameter with the underlying logger.

    Attributes
    protected[this]
    Definition Classes
    Logging
  67. def warnResult[T](message: => String)(fn: => T): T

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger.

    Log the given message at the named log level formatted with the result of the passed in function using the underlying logger. The incoming string message should contain a single %s which will be replaced with the result[T] of the given function.

    Example:

    infoResult("The answer is: %s") {"42"}
    Attributes
    protected[this]
    Definition Classes
    Logging

Inherited from Logging

Inherited from ClosableOnce

Inherited from CloseOnce

Inherited from Closable

Inherited from (Input) => Result

Inherited from AnyRef

Inherited from Any

Ungrouped