Asynchronous dependency resolution #392
danielcondemarin
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Some backend servers act as API aggregators with many external dependencies downstream. The order in which dependencies are called is not always simple, for example some could be called in parallel using goroutines, some others might need to wait for one or more dependencies to complete before they can run, etc. For a large application this can be hard to maintain. Such problem can be modelled with a DAG and the order in which external services are called defined by topologically sorting the graph.
Wire implements a large part of the above, except the code emitted is designed for synchronous execution. Essentially what I wanted is for Wire to do the following,
where the emitted code is,
Granted this example doesn't really shine but imagine for large complex aggregations this can be really useful.
I actually went ahead and tried implementing it, with some nice results: https://github.com/deliveroo/async-wire
I was wondering if this has come up in the past and thoughts on merging this kind of functionality upstream?
PS. Initally I implemented a reflection based solution using https://github.com/twitter/nodes API as a guide, but I really wanted compile time safety and realised Wire did a lot of what I needed already.
Beta Was this translation helpful? Give feedback.
All reactions