leric opened a new issue, #5993: URL: https://github.com/apache/incubator-devlake/issues/5993
## What and why to refactor Many plugins provide remote-api and proxy for client to request upstream datasource api through devlake, so the request can be organized under devlake data source connection, and devlake will handle the authentication stuff. Currently the ApiClient is created on every API request using NewApiClientFromConnection in pluginhelper package. There's a PrepareApiClient stage before a new ApiClient is used, different plugins can do some preparation by implement this interface, get access token, set authorization header, etc. Problem is this PrepareApiClient can be really slow. I've got a performance problem with gitlab proxy api, gitlab plugin's PrepareApiClient implementation have requested `user` and `version` to get userId and api version for the new ApiClient, beside setting authorization header, this added about 0.6s-1.0s delay to every request. ## Describe the solution you'd like I guest every plugin do external request in PrepareApiClient could suffer from this problem. PrepareApiClient is neccesery, but don't need to do it for every request. We can reuse prepared ApiClient to optimize this issue. Maybe we change isolate this connection reuse logic in NewApiClientFromConnection. I'll try this path and make a PR later this week. ## Related issues Please link any other ## Additional context Add any other context or screenshots about the feature request here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
