3 ms·
> I wrote some code that takes a list of servers to query for some particular thing, and it was easy to write it to do them all simultaneously In javascript th
by u320 9y ago
> I wrote some code that takes a list of servers to query for some particular thing, and it was easy to write it to do them all simultaneously
In javascript that would be:
Promise.all(list_of_servers.map(query_server))
Other mainstream languages with similar concurrency primitives (pretty much all of them that either is dynamic or has generics) is similar. I don't think this is an area where Go shines.
- jerf 9y agoThat is not what I wrote. You need something smarter to deal with the fact I want the first server returned that replied with a successful response, which is, in general, not expected to be the first server that replied. If you want parity you'll also need to cancel the remaining requests once the successful one has returned. You still won't have to add very much more stuff, but you're not going to be that much shorter than my Go in the end, either.