Skip to content
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

perf: improve get environment api key latency #1380

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cre8ivejp
Copy link
Member

@cre8ivejp cre8ivejp commented Dec 12, 2024

Fixes #1381

Things done

  • Removed GetAPIKeyBySearchingAllEnvironments API
  • Added GetEnvironmentAPIKey API
  • Added ListAllEnvironmentAPIKeys storage interface for API key cacher
  • Refactored getEnvironmentApiKey in API svc to improve latency
  • Refactored the API key cacher to improve latency

This pull request includes significant changes to the api-description/web-api.swagger.yaml file, the pkg/account/api/api_key.go file, and several other files to refactor the API key retrieval process and improve the overall code structure. The most important changes include modifying the API endpoint method, updating the request and response schemas, and refactoring the related service and storage methods.

Changes to API endpoints and schemas:

  • Changed the method of the /v1/account/get_environment_api_key endpoint from post to get and updated the response schema reference. (api-description/web-api.swagger.yaml)
  • Updated the parameters for the /v1/account/get_environment_api_key endpoint to include apiKey as a query parameter instead of a body parameter. (api-description/web-api.swagger.yaml)
  • Removed the accountGetAPIKeyBySearchingAllEnvironmentsRequest and accountGetAPIKeyBySearchingAllEnvironmentsResponse definitions and added the accountGetEnvironmentAPIKeyResponse definition. (api-description/web-api.swagger.yaml) [1] [2]

Refactoring service methods:

  • Renamed the GetAPIKeyBySearchingAllEnvironments method to GetEnvironmentAPIKey and simplified the logic by removing the project and environment list retrievals. (pkg/account/api/api_key.go) [1] [2] [3]

Updating storage methods:

  • Added the GetEnvironmentAPIKey and ListAllEnvironmentAPIKeys methods to the accountStorage interface and implemented them in the storage layer. (pkg/account/storage/v2/api_key.go, pkg/account/storage/v2/storage.go) [1] [2]
  • Embedded new SQL queries for selecting environment API keys. (pkg/account/storage/v2/sql/api_key_v2/select_all_environment_api_keys_v2.sql, pkg/account/storage/v2/sql/api_key_v2/select_environment_api_key_v2.sql) [1] [2]

Mock client updates:

  • Removed the GetAPIKeyBySearchingAllEnvironments method from the mock client and added the GetEnvironmentAPIKey method. (pkg/account/client/mock/client.go) [1] [2]
  • Updated the mock storage to include the new GetEnvironmentAPIKey and ListAllEnvironmentAPIKeys methods. (pkg/account/storage/v2/mock/storage.go) [1] [2]

Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
pkg/account/api/api_key.go Dismissed Show dismissed Hide dismissed
pkg/batch/jobs/cacher/apikeycacher.go Dismissed Show dismissed Hide dismissed
pkg/batch/jobs/cacher/apikeycacher.go Dismissed Show dismissed Hide dismissed
@cre8ivejp cre8ivejp marked this pull request as ready for review December 12, 2024 09:35
Copy link
Collaborator

@Ubisoft-potato Ubisoft-potato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great performance improvement! 🚀🚀

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

Successfully merging this pull request may close these issues.

perf: improve get environment api key latency
2 participants