4 ms·
Why block the caller? Subsequent calls will have the same promise returned and notification will happen for all once the promise is resolved.
by davinic 7y ago
Why block the caller? Subsequent calls will have the same promise returned and notification will happen for all once the promise is resolved.
- deleted 7y ago[deleted]
- vhost- 7y agoBecause then your caller will need to implement something that understands what a promise is instead of just getting a data object it already has to understand. Not only this, but the caller will need to also implement a polling mechanism to keep trying. Put into code: func get_value(key): value = backend.get(key) return value Is way better than something along these lines: func get_value(key): while true: response = backend.get(key) if response.type == "promise": sleep duration continue return response.value If your service looks like the former, then suddenly your unit tests can use a postgres database, a sqlite database, a rest client... that all implement the same backend.get(key) interface.