github.com/chenbh/concourse/v6@v6.4.2/atc/gc/resource_config_collector.go (about) 1 package gc 2 3 import ( 4 "context" 5 "time" 6 7 "code.cloudfoundry.org/lager/lagerctx" 8 "github.com/chenbh/concourse/v6/atc/db" 9 "github.com/chenbh/concourse/v6/atc/metric" 10 ) 11 12 type resourceConfigCollector struct { 13 configFactory db.ResourceConfigFactory 14 } 15 16 func NewResourceConfigCollector(configFactory db.ResourceConfigFactory) *resourceConfigCollector { 17 return &resourceConfigCollector{ 18 configFactory: configFactory, 19 } 20 } 21 22 func (rcuc *resourceConfigCollector) Run(ctx context.Context) error { 23 logger := lagerctx.FromContext(ctx).Session("resource-config-collector") 24 25 logger.Debug("start") 26 defer logger.Debug("done") 27 28 start := time.Now() 29 defer func() { 30 metric.ResourceConfigCollectorDuration{ 31 Duration: time.Since(start), 32 }.Emit(logger) 33 }() 34 35 return rcuc.configFactory.CleanUnreferencedConfigs() 36 }