(config *Config)
| 88 | } |
| 89 | |
| 90 | func NewCacheManager(config *Config) (*CacheManager, error) { |
| 91 | if config.Registrar == nil { |
| 92 | return nil, fmt.Errorf("registrar must be non-nil") |
| 93 | } |
| 94 | if config.ProcessExcluder == nil { |
| 95 | return nil, fmt.Errorf("processExcluder must be non-nil") |
| 96 | } |
| 97 | if config.Tracker == nil { |
| 98 | return nil, fmt.Errorf("tracker must be non-nil") |
| 99 | } |
| 100 | if config.Reader == nil { |
| 101 | return nil, fmt.Errorf("reader must be non-nil") |
| 102 | } |
| 103 | |
| 104 | if config.GVKAggregator == nil { |
| 105 | config.GVKAggregator = aggregator.NewGVKAggregator() |
| 106 | } |
| 107 | |
| 108 | cfClient := config.CfClient |
| 109 | if cfClient == nil { |
| 110 | cfClient = &noopCFDataClient{} |
| 111 | } |
| 112 | |
| 113 | cm := &CacheManager{ |
| 114 | cfClient: cfClient, |
| 115 | syncMetricsCache: config.SyncMetricsCache, |
| 116 | tracker: config.Tracker, |
| 117 | processExcluder: config.ProcessExcluder, |
| 118 | registrar: config.Registrar, |
| 119 | watchedSet: watch.NewSet(), |
| 120 | reader: config.Reader, |
| 121 | gvksToSync: config.GVKAggregator, |
| 122 | backgroundManagementTicker: *time.NewTicker(3 * time.Second), |
| 123 | gvksToDeleteFromCache: watch.NewSet(), |
| 124 | danglingWatches: watch.NewSet(), |
| 125 | } |
| 126 | |
| 127 | return cm, nil |
| 128 | } |
| 129 | |
| 130 | func (c *CacheManager) Start(ctx context.Context) error { |
| 131 | go c.manageCache(ctx) |
searching dependent graphs…