Skip to content

Commit

Permalink
PLATFORM-9039 code review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
korzepadawid authored and adpaste committed Feb 19, 2024
1 parent e6fd7cb commit 3b90cf7
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions driver/registry_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type RegistryDefault struct {
rwl sync.RWMutex
l *logrusx.Logger
c *config.Config
rc map[string]*retryablehttp.Client
rc *sync.Map

ctxer contextx.Contextualizer

Expand Down Expand Up @@ -237,7 +237,7 @@ func (m *RegistryDefault) RegisterRoutes(ctx context.Context, public *x.RouterPu
func NewRegistryDefault() *RegistryDefault {
return &RegistryDefault{
trc: otelx.NewNoop(nil, new(otelx.Config)),
rc: map[string]*retryablehttp.Client{},
rc: new(sync.Map),
}
}

Expand Down Expand Up @@ -815,19 +815,8 @@ func (m *RegistryDefault) PrometheusManager() *prometheus.MetricsManager {
}

func (m *RegistryDefault) NamedHTTPClient(ctx context.Context, name string, opts ...httpx.ResilientOptions) *retryablehttp.Client {
var rc *retryablehttp.Client
m.rwl.RLock()
if cl, ok := m.rc[name]; ok {
m.rwl.RUnlock()
rc = cl
} else {
m.rwl.RUnlock()
rc = m.HTTPClient(ctx, opts...)
m.rwl.Lock()
m.rc[name] = rc
m.rwl.Unlock()
}
return rc
res, _ := m.rc.LoadOrStore(name, m.HTTPClient(ctx, opts...))
return res.(*retryablehttp.Client)
}

func (m *RegistryDefault) HTTPClient(ctx context.Context, opts ...httpx.ResilientOptions) *retryablehttp.Client {
Expand Down

0 comments on commit 3b90cf7

Please sign in to comment.