The 'RouteSubscriptionSupport' exposes a directive exists to integrate existing routes with an Exchange.
The 'RouteSubscriptionSupport' exposes a directive exists to integrate existing routes with an Exchange.
Consider some basic route:
post(path("foo")) { ... }
We want to be able to integrate it with an exchange to make it a reactive, work-pulling route. We also want that to be non-intrusive. A client of our basic route shouldn't be forced to go via the Exchange to use our endpoint; it should work the same with or without the exchange.
To accomplish this, we'll need to know: 1) The exchange from which to pull more work 2) the subscription key used to request the next work item 3) a means to identify whether the given request was made as a result of a match on the exchange (as opposed to just being hit directly) 4) to know when the response is complete
A parsed work subscription
Class just to support a DSL so you can have:
Class just to support a DSL so you can have:
val routes : WorkerRoutes = ??? routes.withSubscription(XYZ).addHandler( ctxt => ... )
Wraps the input to a computation, allowing the computation (mostly) to call 'request(n)' so it can request more work.
Wraps the input to a computation, allowing the computation (mostly) to call 'request(n)' so it can request more work.
This class is analogous to a Subscription in Reactive Streams
the request type
the interface to an exchange so it can request more work or even cancel the subscription or return the job
the worker routes containing this handler
the details of the subscription
the http request context which contains the original HttpRequest, etc
the unmarshalled handler input
A short-lived handle to something which can send requests to a worker
A short-lived handle to something which can send requests to a worker
It also contains a context in which the request are sent (e.g. the match details, worker details and path)