I have a Playframework application written in Scala. As you might expect, it's primary function is to respond to user requests. Typical request flow:
- Parse input and figure out what the user wants us to do
- Gather external resources from db, AWS and so on (relatively slow, async IO calls).
- When IO calls return, execute a series of functions (some of them long-running, some of them not), that do whatever the user has requested, ultimately producing some output.
- Translate output to a HTTP response and return it to to user.
What are the downsides of having ever major function return Future[SomeResult], even when the function doesn't do long-running work? (In those cases we'd just use Future.successful or equivalent to lift value into a Future.)
One upside is that it makes it easy to compose everything + we get the nice for-comprehension syntactic sugar.
One downside I can see is that the function signatures are "lying" -- they suggest the function performs an async operation, but in many cases it does not. This means you'd have to actually look at the function to see what's going on.