Simplify client handling and reduce concurrency latency by embedding the client in the BackendService struct
hyperioxx opened this issue · comments
Currently, the client map is accessed concurrently, which introduces latency due to mutex locks. It appears that there is a 1-to-1 relationship between clients and backend services. Embedding the client directly in the BackendService struct could simplify the code and avoid the concurrent access latency.
By embedding the client in the BackendService struct, it would also be easier to refresh clients, as we would only need to iterate over the BackendService instances instead of reconciling the client map and the BackendService instances.
Proposed Solution
- Embed the HTTP client directly in the BackendService struct
- Update the related functions to use the embedded client
- Simplify the code for refreshing clients by iterating over the BackendService instances
Sorry but I'm not fully understand why there is need for refreshing the clients? @hyperioxx
@amityahav So that the user can dynamically change things like timeout etc without restarting the whole server
@hyperioxx so that's not really needed as we will modify the conf of the clients when modifying the service via the api
@amityahav Your right ! the api has access, so lets get rid of it