Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

It is not possible to start the application when source API is down #27

Open
rauann opened this issue Jul 20, 2021 · 4 comments
Open

It is not possible to start the application when source API is down #27

rauann opened this issue Jul 20, 2021 · 4 comments
Assignees

Comments

@rauann
Copy link

rauann commented Jul 20, 2021

Currently when the source API's are down the CurrencyConversion supervisor does not start because the UpdateWorker is not started.

Would it be possible to start the CurrencyConversion process using the seed data in this case? In this case the UpdateWorker would need to keep retrying to fetch the rates from the source instead of stopping.

@maennchen
Copy link
Contributor

@rauann I'm not sure how much I like that idea. There's a few libraries like for example ex_cldr or tzdata that include some seed and then refresh that in a given interval.

However: those libraries operate on a lot more static datasets. Currency data is basically outdated a minute after it was loaded.

I would consider an approach that works along the following lines:

  • An optional function can be supplied when starting CurrencyConversion. That function returns the initial data and a DateTime when that data is from. (This means that the user is concerned himself to supply starting data.)
  • The UpdateWorker is seeded with that data.
  • The UpdateWorker has a setting max_data_age
  • If the UpdateWorker refresh fails, it does the following:
    • If data refresh date is newer than max_age_ms: Log Error and retry later
    • If it is older: crash with the refresh error
    • If there's no data (for example when starting and no seed was provided): crash with the refresh error

This will allow you to provide your own data, set a max_age_ms to a value that you're fine with.

The default should be no seed and max_age_ms so that one refresh can fail.

I do not have the time to implement this, but I would for sure merge a PR that implements this.

@rauann
Copy link
Author

rauann commented Jul 21, 2021

Thanks, @maennchen, your suggested approach makes total sense. I will give a try to implement it.

@maennchen
Copy link
Contributor

@rauann Just a heads up, I'm going to be on vacation for the next two weeks. Therefore if you send a PR, I will have a look after my vacation.

@rauann
Copy link
Author

rauann commented Jul 24, 2021

@maennchen No problem, enjoy your vacation :) ... About the suggested approach you did, I was looking at the scenario that I am trying to solve in my project and realized that have seed data for currencies rates is not a good idea because as you said, they will be easily outdated, also, have a config that defines how long this seed would be valid does not help too much since I would end up having to change this config constantly.

What do you think about to make possible to define more than one source for the currencies? One would behave as a fallback source in the case where the primary one is not available. Looking at how the UpdateWorker works, I think it could be implemented.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants