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 multipleInput
instances. As there may not be a 1-to-1 mapping ofInput
toRoute
, it is encouraged that aRoute
encapsulates its relationship to anInput
. 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 destinationRoute
). As a result, theRoute
in this example should be aware of the method, path, and and the destination/logic responsible for handling anInput
that matches. Another property to consider for aRoute
is "uniqueness". A Router should be able to determine either: a) a singleRoute
for anInput
b) noRoute
for anInput
A Router should NOT be expected to return multiple routes for anInput
.
- Note
A Router should be considered immutable unless explicitly noted.
- Alphabetic
- By Inheritance
- Router
- Logging
- ClosableOnce
- CloseOnce
- Closable
- Function1
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Router(label: String, routes: Iterable[Route])
Java-friendly constructor
- 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 whenclose()
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
- abstract def find(input: Input): Result
Logic used to determine if this Router contains a
Route
for anInput
.Logic used to determine if this Router contains a
Route
for anInput
.- 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 theInput
.
- 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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def andThen[A](g: (Result) => A): (Input) => A
- Definition Classes
- Function1
- Annotations
- @unspecialized()
- final def apply(input: Input): Result
Attempt to route an
Input
to aRoute
route known by this Router.Attempt to route an
Input
to aRoute
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 ifclose()
has been initiated on this Router and subsequent routing attempts are received.
- Definition Classes
- Router → Function1
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def close(deadline: Time): Future[Unit]
Close the resource with the given deadline.
- 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
- 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
- final def closeFuture: Future[Unit]
- def closeOnce(deadline: Time): Future[Unit]
- def compose[A](g: (A) => Input): (A) => Result
- Definition Classes
- Function1
- Annotations
- @unspecialized()
- 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
- 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
- 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
- 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
- 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
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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
- 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
- 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
- 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
- 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
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- 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
- 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
- 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
- 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
- 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
- final def isClosed: Boolean
Signals whether or not this Closable has been closed.
- 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. Returnstrue
if enabled,false
otherwise.- Attributes
- protected[this]
- Definition Classes
- Logging
- 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
- 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. Returnstrue
if enabled,false
otherwise.- Attributes
- protected[this]
- Definition Classes
- Logging
- 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
- 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. Returnstrue
if enabled,false
otherwise.- Attributes
- protected[this]
- Definition Classes
- Logging
- 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
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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. Returnstrue
if enabled,false
otherwise.- Attributes
- protected[this]
- Definition Classes
- Logging
- 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
- 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. Returnstrue
if enabled,false
otherwise.- Attributes
- protected[this]
- Definition Classes
- Logging
- 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
- val label: String
- final def logger: Logger
Return the underlying com.twitter.util.logging.Logger
Return the underlying com.twitter.util.logging.Logger
- returns
- Attributes
- protected[this]
- Definition Classes
- Logging
- 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
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val routes: Iterable[Route]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- Function1 → AnyRef → Any
- 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
- 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
- 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
- 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
- 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
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- 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
- 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
- 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
- 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
- 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