dependent data sources?
mwotton opened this issue · 5 comments
perhaps i've missed something - I have some datasources that rely on other datasources to get their data. Is there some way of indicating in the Datasource implementation that fetch should be a Haxl expression, rather than just IO?
I probably don't fully understand your use case, but have you looked at cachedComputation
? This allows you to build a data source with the usual caching properties but whose implementation is a Haxl
computation. We use this to wrap other data sources at Facebook.
I think I sort of want the dual of that - I have a datasource Foo, and another datasource Baz that fetches some things, and also uses Foo. Looking at the typesig of fetch, it returns
data PerformFetch
= SyncFetch (IO ())
| AsyncFetch (IO () -> IO ())
so I can only do IO in that fetch - I can't drop back into the Haxl env to use data from elsewhere.
Have I just mis-structured my app? I can sort of see how I could just use the DataSource to fetch, and then write the combination as computations in the Haxl applicative.
pretty sure I have mis-structured it now. Sorry for the noise.
As I understand your question, we solve this problem in haxl "client" code. We have, for example, abstractions that fetch Widgets and those will attempt to fetch them first from memcache, and them from the WidgetStore if memcache fails. This is done with normal haxl-like conditionals and conditional fetching. This method for multi-stage fetching plays nicely with the rest of haxl as the memcache fetch in the first round will go out with other requests in that round.
Yep, I just misunderstood the model. All the dependencies are expressed in
Haxl expressions, not in data sources - all happy (and infinitely better
than my homebrew) now.
On Fri, 1 May 2015 2:15 am Louis Brandy notifications@github.com wrote:
As I understand your question, we solve this problem in haxl "client"
code. We have, for example, abstractions that fetch Widgets and those will
attempt to fetch them first from memcache, and them from the WidgetStore if
memcache store (this is normal haxl code). This method for multi-stage
fetching plays nicely with the rest of haxl as the memcache fetch in the
first round will go out with other requests in that round.—
Reply to this email directly or view it on GitHub
#29 (comment).