perf: improve get environment api key latency #1380
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.
Fixes #1381
Things done
getEnvironmentApiKey
in API svc to improve latencyThis pull request includes significant changes to the
api-description/web-api.swagger.yaml
file, thepkg/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:
/v1/account/get_environment_api_key
endpoint frompost
toget
and updated the response schema reference. (api-description/web-api.swagger.yaml
)/v1/account/get_environment_api_key
endpoint to includeapiKey
as a query parameter instead of a body parameter. (api-description/web-api.swagger.yaml
)accountGetAPIKeyBySearchingAllEnvironmentsRequest
andaccountGetAPIKeyBySearchingAllEnvironmentsResponse
definitions and added theaccountGetEnvironmentAPIKeyResponse
definition. (api-description/web-api.swagger.yaml
) [1] [2]Refactoring service methods:
GetAPIKeyBySearchingAllEnvironments
method toGetEnvironmentAPIKey
and simplified the logic by removing the project and environment list retrievals. (pkg/account/api/api_key.go
) [1] [2] [3]Updating storage methods:
GetEnvironmentAPIKey
andListAllEnvironmentAPIKeys
methods to theaccountStorage
interface and implemented them in the storage layer. (pkg/account/storage/v2/api_key.go
,pkg/account/storage/v2/storage.go
) [1] [2]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:
GetAPIKeyBySearchingAllEnvironments
method from the mock client and added theGetEnvironmentAPIKey
method. (pkg/account/client/mock/client.go
) [1] [2]GetEnvironmentAPIKey
andListAllEnvironmentAPIKeys
methods. (pkg/account/storage/v2/mock/storage.go
) [1] [2]