hyperioxx / frontman

Frontman is an open-source API gateway written in Go that allows you to manage your microservices and expose them as a single API endpoint. It acts as a reverse proxy and handles requests from clients, routing them to the appropriate backend service.

Home Page:https://frontman-labs.github.io/frontman/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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