Suppose I need to a Scala component to process incoming requests concurrently and return the processing results. Suppose also that the request processing consists of a few steps. Some of the steps are resource and time consuming, some of them are either I/O or CPU-bound, etc.
Assuming that requests come from inside the JVM I would design the component as follows:
- actor "Facade" is the entry point: it receives requests and sends the results to the clients.
- actor "Dispatcher" execute processing steps asynchronously with
Futures, which wrap the steps - steps send their results back to the "Dispatcher" actor. It's implemented with
Futurecallbacks. - When the request processing finish "Dispatcher" sends the results to "Facade".
Does it make sense? Are there any good examples of such a component in Scala?