forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan_runner_factory.go
76 lines (64 loc) · 1.86 KB
/
scan_runner_factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package radar
import (
"time"
"github.com/concourse/atc"
"github.com/concourse/atc/creds"
"github.com/concourse/atc/db"
"github.com/concourse/atc/resource"
"code.cloudfoundry.org/clock"
"code.cloudfoundry.org/lager"
)
//go:generate counterfeiter . Scanner
type Scanner interface {
Run(lager.Logger, string) (time.Duration, error)
Scan(lager.Logger, string) error
ScanFromVersion(lager.Logger, string, atc.Version) error
}
//go:generate counterfeiter . ScanRunnerFactory
type ScanRunnerFactory interface {
ScanResourceRunner(lager.Logger, string) IntervalRunner
ScanResourceTypeRunner(lager.Logger, string) IntervalRunner
}
type scanRunnerFactory struct {
clock clock.Clock
resourceScanner Scanner
resourceTypeScanner Scanner
}
func NewScanRunnerFactory(
resourceFactory resource.ResourceFactory,
resourceConfigFactory db.ResourceConfigFactory,
defaultInterval time.Duration,
dbPipeline db.Pipeline,
clock clock.Clock,
externalURL string,
variables creds.Variables,
) ScanRunnerFactory {
resourceScanner := NewResourceScanner(
clock,
resourceFactory,
resourceConfigFactory,
defaultInterval,
dbPipeline,
externalURL,
variables,
)
resourceTypeScanner := NewResourceTypeScanner(
resourceFactory,
resourceConfigFactory,
defaultInterval,
dbPipeline,
externalURL,
variables,
)
return &scanRunnerFactory{
clock: clock,
resourceScanner: resourceScanner,
resourceTypeScanner: resourceTypeScanner,
}
}
func (sf *scanRunnerFactory) ScanResourceRunner(logger lager.Logger, name string) IntervalRunner {
return NewIntervalRunner(logger.Session("interval-runner"), sf.clock, name, sf.resourceScanner)
}
func (sf *scanRunnerFactory) ScanResourceTypeRunner(logger lager.Logger, name string) IntervalRunner {
return NewIntervalRunner(logger.Session("interval-runner"), sf.clock, name, sf.resourceTypeScanner)
}