From 66a632c1f4c15347508d516f6f5d11e8dae1e743 Mon Sep 17 00:00:00 2001 From: atavism Date: Thu, 5 Dec 2024 11:02:51 -0800 Subject: [PATCH] use ChainedThenFronted --- internalsdk/auth/auth.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/internalsdk/auth/auth.go b/internalsdk/auth/auth.go index daad3e277..1f0f07ce6 100644 --- a/internalsdk/auth/auth.go +++ b/internalsdk/auth/auth.go @@ -51,11 +51,6 @@ type AuthClient interface { // NewClient creates a new instance of AuthClient func NewClient(baseURL string, userConfig func() common.UserConfig) AuthClient { - chained, err := proxied.ChainedNonPersistent("") - if err != nil { - log.Fatal(err) - } - frt := proxied.Fronted("auth_fronted_roundtrip", 10*time.Second) rc := webclient.NewRESTClient(&webclient.Opts{ BaseURL: baseURL, OnBeforeRequest: func(client *resty.Client, req *http.Request) error { @@ -65,7 +60,7 @@ func NewClient(baseURL string, userConfig func() common.UserConfig) AuthClient { // The Auth client uses an http.Client that first attempts to connect via chained proxies // and then falls back to using domain fronting with the custom op name above HttpClient: &http.Client{ - Transport: serialTransport{chained, frt}, + Transport: proxied.ChainedThenFronted(), Timeout: 30 * time.Second, }, UserConfig: userConfig, @@ -241,17 +236,3 @@ func (c *authClient) SignOut(ctx context.Context, logoutData *protos.LogoutReque } return true, nil } - -type serialTransport []http.RoundTripper - -func (tr serialTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) { - for _, rt := range tr { - resp, err = rt.RoundTrip(req) - if err == nil { - return - } - log.Debugf("Error roundtripping request to %v, continuing to next transport", req.URL) - } - log.Errorf("Unable to roundtrip request to %v, out of transports", req.URL) - return -}