Trait/Object

com.twitter.util.routing

Router

Related Docs: object Router | package routing

Permalink

trait Router[Input, Route] extends (Input) ⇒ Option[Route] with ClosableOnce

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
ClosableOnce, CloseOnce, Closable, (Input) ⇒ Option[Route], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Router
  2. ClosableOnce
  3. CloseOnce
  4. Closable
  5. Function1
  6. AnyRef
  7. 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. 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.

  12. def compose[A](g: (A) ⇒ Input): (A) ⇒ Option[Route]

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  13. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def isClosed: Boolean

    Permalink
    Definition Classes
    CloseOnce
  19. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  20. def logger: Logger

    Permalink

    The Logger to use for this Router.

    The Logger to use for this Router. Can be overridden to customize.

    Attributes
    protected
  21. final def ne(arg0: AnyRef): Boolean

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

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

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

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

    Permalink
    Definition Classes
    Function1 → AnyRef → Any
  26. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ClosableOnce

Inherited from CloseOnce

Inherited from Closable

Inherited from (Input) ⇒ Option[Route]

Inherited from AnyRef

Inherited from Any

Ungrouped