type eventType … func (e eventType) String() string { … } const addEvent … const updateEvent … const deleteEvent … type event … type QuotaMonitor … // NewMonitor creates a new instance of a QuotaMonitor func NewMonitor(informersStarted <-chan struct{ … } type monitor … // Run is intended to be called in a goroutine. Multiple calls of this is an // error. func (m *monitor) Run() { … } type monitors … type UpdateFilter … func (qm *QuotaMonitor) controllerFor(ctx context.Context, resource schema.GroupVersionResource) (cache.Controller, error) { … } // SyncMonitors rebuilds the monitor set according to the supplied resources, // creating or deleting monitors as necessary. It will return any error // encountered, but will make an attempt to create a monitor for each resource // instead of immediately exiting on an error. It may be called before or after // Run. Monitors are NOT started as part of the sync. To ensure all existing // monitors are started, call StartMonitors. func (qm *QuotaMonitor) SyncMonitors(ctx context.Context, resources map[schema.GroupVersionResource]struct{ … } // StartMonitors ensures the current set of monitors are running. Any newly // started monitors will also cause shared informers to be started. // // If called before Run, StartMonitors does nothing (as there is no stop channel // to support monitor/informer execution). func (qm *QuotaMonitor) StartMonitors(ctx context.Context) { … } // IsSynced returns true if any monitors exist AND all those monitors' // controllers HasSynced functions return true. This means IsSynced could return // true at one time, and then later return false if all monitors were // reconstructed. func (qm *QuotaMonitor) IsSynced(ctx context.Context) bool { … } // Run sets the stop channel and starts monitor execution until stopCh is // closed. Any running monitors will be stopped before Run returns. func (qm *QuotaMonitor) Run(ctx context.Context) { … } func (qm *QuotaMonitor) runProcessResourceChanges(ctx context.Context) { … } // Dequeueing an event from resourceChanges to process func (qm *QuotaMonitor) processResourceChanges(ctx context.Context) bool { … }