4 ms·
Certainly, or even with two layers of futures. Notably, this changes the interface. I'm not saying it's not solvable, just that it was so silently mentioned in
by tel 12y ago
Certainly, or even with two layers of futures. Notably, this changes the interface.
I'm not saying it's not solvable, just that it was so silently mentioned in the article. You should have to work to reproof your code after RPCing something.
It can just be scary if you've spent time making it out as though MchineLearningProvider can never fail. Interacting with an outside object can be a painful experience.
This gives you some of the worries of a true distributed system within your monolith.
- yummyfajitas 12y agoIf only there were a way of transforming F[F[X]] to F[X]. Then we could avoid nested futures!
- jeremyjh 12y agoEspecially if it had some nice syntax sugar. Then we could chain together as many as we want!
- tel 12y agoYou're being sarcastic, but I meant to suggest that there would be value in running those layers independently so that you don't combine errors. If you present it as F[X] then you've thrown away potentially interesting information. IO (IO ()) is pretty valuable, for instance.
- yummyfajitas 12y agoJust curious, what is the advantage? Near as I can tell EmailProvider will return one of two sorts of errors - either a ServiceError (the microservice was unable to send) or a NetworkError (unable to talk to micro service). These will be represented in the class of the exception the future wraps. What benefit does two levels of futures provide? I was sarcastic before, but now I'm honestly asking.
- tel 12y agoThe two differences I can think of are 1. If you don't assume exception throwing (which may be valuable) then you can more easily distinguish one failure from the other. 2. It reflects in the type a more accurate representation of the effect going on. If such distinctions are undesirable it's a trivial `join` to eliminate them but if the distinction is never exposed then you can't get it back. So really, my thought is that given greater opportunity to distinguish between end-user meaningful effects it's worth exposing them by default. It should be a deliberate choice to hide them with join.
- deleted 12y ago[deleted]
- yummyfajitas 12y agoTel I have no idea why, but your reply is dead. It is a good answer, however, and provides me with food for thought.
- tel 12y agoStrange. I see it appearing twice. I will try deleting one.