Skip to content

Commit

Permalink
rename helpers -> cachingProxies
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjat committed Feb 15, 2024
1 parent 018403c commit 415a39c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions cmd/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func wipeStorage(cfg *config.StorageConfig) error {
type Service struct {
analyzers []SyncedAnalyzer
fastSyncAnalyzers []SyncedAnalyzer
helpers []*http.Server
cachingProxies []*http.Server

sources *sourceFactory
target storage.TargetStorage
Expand Down Expand Up @@ -282,14 +282,14 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return nil, err
}

// Initialize analyzer helpers.
helpers := []*http.Server{}
// Initialize analyzer cachingProxies.
cachingProxies := []*http.Server{}
for _, proxyCfg := range cfg.Helpers.CachingProxies {
helper, err2 := httpproxy.NewHttpServer(*cfg.Source.Cache, proxyCfg)
proxy, err2 := httpproxy.NewHttpServer(*cfg.Source.Cache, proxyCfg)
if err2 != nil {
return nil, err2
}
helpers = append(helpers, helper)
cachingProxies = append(cachingProxies, proxy)
}

// Initialize fast-sync analyzers.
Expand Down Expand Up @@ -510,7 +510,7 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return &Service{
fastSyncAnalyzers: fastSyncAnalyzers,
analyzers: analyzers,
helpers: helpers,
cachingProxies: cachingProxies,

sources: sources,
target: dbClient,
Expand All @@ -526,12 +526,12 @@ func (a *Service) Start() {
ctx, cancelAnalyzers := context.WithCancel(context.Background())
defer cancelAnalyzers() // Start() only returns when analyzers are done, so this should be a no-op, but it makes the compiler happier.

// Start helpers.
for _, helper := range a.helpers {
helper := helper
// Start caching proxies.
for _, proxy := range a.cachingProxies {
proxy := proxy
go func() {
if err := helper.ListenAndServe(); err != nil {
a.logger.Error("helper server failed", "server_addr", helper.Addr, "error", err.Error())
if err := proxy.ListenAndServe(); err != nil {
a.logger.Error("caching proxy server failed", "server_addr", proxy.Addr, "error", err.Error())
}
}()
}
Expand Down

0 comments on commit 415a39c

Please sign in to comment.