-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] Fallback Mechanisms #540
Comments
@digitalbuddha Wanted to get this out of my head into an issue. My hunch is we will want to provide guidance through documentation and not change Store |
Yup this looks great. I think it opens up new use cases like managing feature flags where on first launch you don't have network and need the local default flag value. I'll read in way more detail but on first glance I love the direction you are going |
I think this looks good. I have 1 question on the first use case listed: |
Thanks for reviewing! There is an outstanding feature request for enabling SOT as a fallback on failure to fetch fresh data (#394). My thinking has been fallbacks would be available regardless of whether the Store has data. It's possible to use the SOT as a warehouse. For example take a look at this test case. So a user could choose to provide the SOT as a warehouse, or for instance a secondary API and then SOT bindings. |
Hmm - But yeah I did not consider:
Thoughts? |
Hmm, it sounds a bit weird for I feel like SOT serving as Warehouse is a bit weird. The data flow graph looks complicated, as in, there are 2 paths where it might fetch from SOT. If we are adding warehouse just for I think there is still the case for the WareHouse when SOT is empty, but in that case, should this be something that goes under SOT instead of above Store? e.g. what if you could create SOT with a fallback Warehouse ? I'm wondering if that is a more accurate way to model it (and then Warehouse should not be using SOT). Or we could even create an API on SOT builder that lets you chain multiple SOTs? e.g.
that way, it can even be chained indefinitely :) I don't think this solves some options listed above (e..g. Geo case) but maybe the solution for that is to also allow chaining Fetchers? Both of these would also be just convenience APIs since these can all be done w/ coroutine operators (i think) |
Signed-off-by: Matt Ramotar <[email protected]>
Thanks, very helpful! Chaining fetchers makes a lot of sense to me. WIP - 2d1cb0b. Will finish refactoring and documenting tomorrow |
* Superstore Signed-off-by: Matt Ramotar <[email protected]> * Move to impl Signed-off-by: Matt Ramotar <[email protected]> * Add firstData Signed-off-by: Matt Ramotar <[email protected]> * Add Superstore factory Signed-off-by: Matt Ramotar <[email protected]> * Add README Signed-off-by: Matt Ramotar <[email protected]> * Add SuperstoreTests Signed-off-by: Matt Ramotar <[email protected]> * Move to util Signed-off-by: Matt Ramotar <[email protected]> * Rename to primary Signed-off-by: Matt Ramotar <[email protected]> * Address comments from @tsenggordon Signed-off-by: Matt Ramotar <[email protected]> * Format Signed-off-by: Matt Ramotar <[email protected]> * Cover fallback to SOT on fresh fail Signed-off-by: Matt Ramotar <[email protected]> * Refactor based on @yigit feedback in #540 Signed-off-by: Matt Ramotar <[email protected]> * Enable Fetcher identification Signed-off-by: Matt Ramotar <[email protected]> * Cover failing fallback Signed-off-by: Matt Ramotar <[email protected]> * Remove superstore Signed-off-by: Matt Ramotar <[email protected]> * Format Signed-off-by: Matt Ramotar <[email protected]> * Remove logs Signed-off-by: Matt Ramotar <[email protected]> * Update README.md Signed-off-by: Matt Ramotar <[email protected]> * Add Proposal template (#523) Signed-off-by: Matt Ramotar <[email protected]> * Support Rx2 (#531) * Add rx2 module * Support Rx2 Signed-off-by: Matt Ramotar <[email protected]> * Add unit tests Signed-off-by: Matt Ramotar <[email protected]> * Format Signed-off-by: Matt Ramotar <[email protected]> --------- Signed-off-by: Matt Ramotar <[email protected]> * Superstore Signed-off-by: Matt Ramotar <[email protected]> * Remove superstore Signed-off-by: Matt Ramotar <[email protected]> * Remove ReactiveCircus/android-emulator-runner Signed-off-by: Matt Ramotar <[email protected]> * Fix Rx2 merge issues Signed-off-by: Matt Ramotar <[email protected]> * Send failure if no fallback Signed-off-by: Matt Ramotar <[email protected]> * Remove Fallback interface and FallbackResponse class Signed-off-by: matt-ramotar <[email protected]> * Document Fetcher.name Signed-off-by: matt-ramotar <[email protected]> --------- Signed-off-by: Matt Ramotar <[email protected]> Signed-off-by: matt-ramotar <[email protected]>
Closed with #545 |
I think the documentation for the
To me the portion "as well" signals that the resulting flow emits first the cached value (if any), then the network data (if any) -- and potentially races the two sources? It's unclear as an end user. |
TLDR
Introduce
Superstore
andWarehouse
to handle data retrieval and fallback mechanisms when a primary data source fails or returns an error.Abstract
When a primary data source fails or returns an error, it is desirable to have a fallback mechanism in place. One proposed solution is to introduce two new classes,
Warehouse
andSuperstore
, to handle the fallback mechanism. TheWarehouse
contains the fallback data source and provides a simple API for fetching the data. TheSuperstore
coordinates theStore
andWarehouse
, attempting to fetch data from theStore
first, and if that fails, it will fetch data from theWarehouse
.Problem
For some use cases, it is desirable to have a fallback mechanism in place for when the Store encounters an error or is unable to fetch data. Currently, there is no built-in mechanism to handle such scenarios, leaving developers to implement custom solutions.
Alternatives considered
Modify the existing Store class: We could modify the Store class to include an additional fallback mechanism. However, this approach would increase the complexity of the Store class and could break existing implementations.
Create a new FallbackStore class: We could create a new FallbackStore class that inherits from the Store class and provides a fallback mechanism. This approach would keep the existing Store class intact but may result in code duplication and maintenance overhead.
Provide guidance to users: By providing comprehensive documentation on handling fallback scenarios, developers can implement a fallback mechanism that fits their specific use case while avoiding unnecessary complexity or potential issues with modifying existing code.
Proposed solution
My proposal is to introduce two new classes,
Warehouse
andSuperstore
, to handle the fallback mechanism:Warehouse
The
Warehouse
will contain hardcoded data or any other fallback data source. It will provide a simple API for fetching the fallback data.Superstore
A class that coordinates the
Store
andWarehouse
. TheSuperstore
will first attempt to fetch data from theStore
. If theStore
fails or returns an error, theSuperstore
will fetch the data from theWarehouse
.The text was updated successfully, but these errors were encountered: