Add async provider pod status updates (#493)
This adds a new interface that a provider can implement which enables async notifications of pod status changes rather than the existing loop which goes through every pod in k8s and checks the status in the provider. In practice this should be significantly more efficient since we are not constantly listing all pods and then looking up the status in the provider. For providers that do not support this interface, the old method is still used to sync state from the provider. This commit does not update any of the providers to support this interface.
This commit is contained in:
@@ -61,3 +61,14 @@ type Provider interface {
|
||||
type PodMetricsProvider interface {
|
||||
GetStatsSummary(context.Context) (*stats.Summary, error)
|
||||
}
|
||||
|
||||
// PodNotifier notifies callers of pod changes.
|
||||
// Providers should implement this interface to enable callers to be notified
|
||||
// of pod status updates asyncronously.
|
||||
type PodNotifier interface {
|
||||
// NotifyPods instructs the notifier to call the passed in function when
|
||||
// the pod status changes.
|
||||
//
|
||||
// NotifyPods should not block callers.
|
||||
NotifyPods(context.Context, func(*v1.Pod))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user