ronoaldo / swgohapi

Cached, parsed https://swgoh.gg/ player profile data unofficial API
https://swgoh-api.appspot.com/
GNU Affero General Public License v3.0
1 stars 0 forks source link

Convert synchronous to asynchronous profile updates #2

Closed ronoaldo closed 6 years ago

ronoaldo commented 6 years ago

Now that profiles are always on cache, instead of making user-facing requests take longer time, the API behavior should be:

  1. For a never-seen profile, instead of fetch basic info, return a 202 Accepted status code, and schedule the full sync in background task queue. Return the estimated time the result will be ready (can be hard coded as of now to 5s).
  2. For cached profiles, if cache is expired (i.e., < 24hs), schedule a full sync in background with a named task to avoid overload.

Now that we have a periodic check of cached profiles every 6hrs, we can rely on that periodic updates to provide properly updated info, and make response-times of user-facing request a constant (<100ms).