Trait

com.twitter.util.routing

Router

Related Doc: package routing

Permalink

trait Router[Input, +Route] extends (Input) ⇒ Option[Route] 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". It may or may not be desirable for a Router to contain multiple routes that correspond to the same Input.

Note

A Router should be considered immutable unless explicitly noted.

Linear Supertypes
Known Subclasses
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. All

Abstract Value Members

  1. abstract def find(input: Input): Option[Route]

    Permalink

    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

    Some(Route) if a matching route is defined, None 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.

  2. abstract def label: String

    Permalink

    A label used for identifying this Router (i.e.

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

  3. abstract def routes: Iterable[Route]

    Permalink

    All of the Route routes contained within this Router

    All of the Route routes contained within this Router

    Note

    This property is used to linearly determine the routes when closed() 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.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def andThen[A](g: (Option[Route]) ⇒ A): (Input) ⇒ A

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  5. final def apply(input: Input): Option[Route]

    Permalink

    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

    Some(Route) if a route is found to match, None otherwise

    Definition Classes
    Router → Function1
    Note

    A ClosedRouterException will be thrown if close has been initiated on this router and subsequent routing attempts are received.

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def close(deadline: Time): Future[Unit]

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

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

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

    Permalink
    Attributes
    protected
    Definition Classes
    CloseOnce
  12. def closeOnce(deadline: Time): Future[Unit]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    Attributes
    protected
    Definition Classes
    Router → CloseOnce
    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) ⇒ Option[Route]

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  14. def debug(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

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

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

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

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

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  19. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  21. def error(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

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

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

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

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

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  26. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  27. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  28. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  29. def info(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

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

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

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

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

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  34. final def isClosed: Boolean

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

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

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

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

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

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

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  41. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  42. def isTraceEnabled(marker: Marker): Boolean

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

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

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

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  46. final def logger: Logger

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

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  48. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  49. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  50. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  51. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  52. def toString(): String

    Permalink
    Definition Classes
    Function1 → AnyRef → Any
  53. def trace(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  54. def trace(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  55. def trace(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  56. def trace(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  57. def traceResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  58. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  59. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  60. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  61. def warn(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  62. def warn(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  63. def warn(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  64. def warn(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  65. def warnResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging

Inherited from Logging

Inherited from ClosableOnce

Inherited from CloseOnce

Inherited from Closable

Inherited from (Input) ⇒ Option[Route]

Inherited from AnyRef

Inherited from Any

Ungrouped