This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
Reduce API calls needed to discover apps & services #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Previously this made two API calls for every application the user was
able to see:
Some orgs have large numbers of apps (65 apps in one org -> 130 API
calls).
Because there are no sleeps between calls, this ends up putting a lot of
traffic through the API all at once, which then gets queued.
Once API requests start getting queued, the healthcheck starts failing
(because the healthcheck requests time out while they're in the queue).
Once the healthcheck starts failing the API servers start getting taken
out of the load balancer, at which point we start having Bad Vibes.
This PR changes the API calls we make so that there's one call to
get all the orgs the user can see, one to get all the spaces the user
can see, and one to get all the apps the user can see. Because this
doesn't vary with the number of apps the performance should be much more
predictable.
I've also added some tests that mock the HTTP traffic so it's more obvious
what API calls our client makes (this should be enough to prevent a regression,
or someone accidentally making a new API call using the overly chatty go-cfclient).
How to review