Class FastPathRouterImpl
java.lang.Object
dev.relism.flash.routing.AbstractRouter
dev.relism.flash.routing.routers.fastpathrouter.FastPathRouterImpl
Router backed by the
fpr-core byte-level state machine. Routes are compiled lazily
on the first request and recompiled when routes are added after startup. Matching runs on a
virtual METHOD + path byte sequence in a single pass; the per-connection
FastPathRouterImpl.RouteScratch (newScratch()) owns the reused MatchResult,
FastPathViews.MethodPathByteView and path-param arrays that would otherwise allocate
request.-
Nested Class Summary
Nested classes/interfaces inherited from class dev.relism.flash.routing.AbstractRouter
AbstractRouter.ExceptionHandler -
Field Summary
Fields inherited from class dev.relism.flash.routing.AbstractRouter
exceptionHandler, notFoundHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractRouteraddRoute(HttpMethod method, String path, RequestHandler handler) voidcompile()Eagerly validates and compiles this route graph before traffic is accepted.Creates a fresh per-connection scratch object forAbstractRouter.route(dev.relism.flash.models.Request, java.lang.Object), ornullif this router implementation keeps no reusable per-connection state.Methods inherited from class dev.relism.flash.routing.AbstractRouter
doRegister, getExceptionHandler, getNotFoundHandler, onException, onNotFound
-
Constructor Details
-
FastPathRouterImpl
public FastPathRouterImpl()
-
-
Method Details
-
newScratch
Description copied from class:AbstractRouterCreates a fresh per-connection scratch object forAbstractRouter.route(dev.relism.flash.models.Request, java.lang.Object), ornullif this router implementation keeps no reusable per-connection state. Called once per connection by the connection driver (e.g.Http1Connection), which holds the opaque result and passes it back into everyAbstractRouter.route(dev.relism.flash.models.Request, java.lang.Object)call for that connection's whole lifetime — the same "create once per connection, reuse across requests" shape already used there forRequestParser. thread", which under this codebase's one-virtual-thread-per-connection model is "one per connection with no upper bound and no pooling" — exactly the failure modeConnectionScratchalready exists to avoid for every other per-connection buffer. An explicit, caller-owned scratch object achieves the same per-connection reuse without that unbounded-growth risk, and without requiringroutingto depend ontransport'sConnectionScratchtype (this package has no such dependency than extendingConnectionScratchitself, which is what an earlier draft of this fix assumed).- Overrides:
newScratchin classAbstractRouter
-
addRoute
- Specified by:
addRoutein classAbstractRouter
-
route
- Specified by:
routein classAbstractRouter
-
compile
public void compile()Description copied from class:AbstractRouterEagerly validates and compiles this route graph before traffic is accepted.- Overrides:
compilein classAbstractRouter
-