-
Notifications
You must be signed in to change notification settings - Fork 23
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
⚡️ verify github connection only once #4980
Conversation
When a user scans a single GH repository, this was not a problem, but for users that scan an entire organization with thousands of repositories, we were creating a connection for each asset and validating it thousands of times. This changes the behavior to verify the connection only once which will save us thousands of GH API requests. Signed-off-by: Salim Afiune Maya <[email protected]>
Signed-off-by: Salim Afiune Maya <[email protected]>
@@ -38,25 +40,75 @@ type GithubConnection struct { | |||
asset *inventory.Asset | |||
client *github.Client | |||
ctx context.Context | |||
|
|||
// Used to avoid verifying a client with the same options more than once | |||
Hash uint64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we call this optionsHash or something similar to make its purpose more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rename it in a diff PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supersedes #4976
When a user scans a single GH repository, this was not a problem, but for users that scan an entire organization with thousands of repositories, we were creating a connection for each asset and validating it thousands of times.
This changes the behavior to verify the connection only once which will save us thousands of GH API requests.