A Router
is a lot like a com.twitter.finagle.Client
, except
that it is not configured with destination
com.twitter.finagle.Name
.
A Router
is a lot like a com.twitter.finagle.Client
, except
that it is not configured with destination
com.twitter.finagle.Name
. Instead, a
destination is determined for
each request by an Identifier and a client is
then dynamically resolved.
Routers are implemented by the various protocol packages. For example:
object Http extends Router[Request, Response] ... val router: ServiceFactory[Request, Response] = Http.newRouter("http")
A RoutingFactory is a ServiceFactory that, for each request, determines a routable name for the request, resolves it to a client, and dispatches the request to a downstream service.
A RoutingFactory is a ServiceFactory that, for each request, determines a routable name for the request, resolves it to a client, and dispatches the request to a downstream service.
getDst
is responsible for determining the name (Path) of each
request.
A DstBindingFactory is used to obtain a client that serves each destination.
A Router that composes three com.twitter.finagle.Stack
s:
A Router that composes three com.twitter.finagle.Stack
s:
* pathStack
is a per-Dst.Path Stack segment. When this Stack is applied, the
Dst.Path Stack.Param
is
configured. This type of destination has a destination
com.twitter.finagle.Path
, a base com.twitter.finagle.Dtab
,
and a local (usually per-request) Dtab
.
* boundStack
is a per-com.twitter.finagle.buoyant.Dst.Bound
Stack segment. When this Stack is applied, the
Dst.Bound Stack.Param
is configured. This type of destination has an
com.twitter.finagle.Addr
, a bound id, and a residual
path.
* clientStack
is a per-
com.twitter.finagle.BindingFactory.Dest
Stack segment. When
this Stack is applied, the BindingFactory.Dest
Stack.Param
is configured with a com.twitter.finagle.Name.Bound
that does
not have a residual com.twitter.finagle.Path
.
The stack is divided into these layers so that caching may be
applied bottom-up. This enables a clientStack
to be shared by
multiple boundStack
and a boundStack
to be shared by multiple
pathStack
s. It is the StackRouter
's job to connect these
Stack
segments and to set the proper
com.twitter.finagle.Stack.Param
s as described above.
The standard template implementation of StackRouter.
The standard template implementation of StackRouter.
Provides Stack caching so that e.g. multiple per-path stacks may
share common underlying boundStack
and clientStack
service
factories.
Implementers must provide a newIdentifier()
implementation that
l
Originator.Param is a boolean stack param that is used to configure a Router.
Originator.Param is a boolean stack param that is used to configure a Router. If the param is set to true, it indicates that the router is the first hop in a linker-to-linker request, and the router's stats are updated to reflect that.
com.twitter.finagle.Stack.Param
The io.buoyant.router and com.twitter.finagle.buoyant packages provide a library for building RPC routers with Finagle.