-
Notifications
You must be signed in to change notification settings - Fork 250
/
notifier.go
31 lines (26 loc) · 1.04 KB
/
notifier.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
package util
import (
corev1 "k8s.io/api/core/v1"
)
// ContainerNotifier receives updates about the status of a poll action on a pod. The caller
// is required to define what notifications are made.
type ContainerNotifier interface {
// Notify indicates that the provided container name has transitioned to an appropriate state and
// any per container actions should be taken.
Notify(pod *corev1.Pod, containerName string)
// Complete indicates the specified pod has completed execution, been deleted, or that no further
// Notify() calls can be made.
Complete(podName string)
// Done returns a channel that can be used to wait for the specified pod name to complete the work it has pending.
Done(podName string) <-chan struct{}
}
// NopNotifier takes no action when notified.
var NopNotifier = nopNotifier{}
type nopNotifier struct{}
func (nopNotifier) Notify(_ *corev1.Pod, _ string) {}
func (nopNotifier) Complete(_ string) {}
func (nopNotifier) Done(string) <-chan struct{} {
ret := make(chan struct{})
close(ret)
return ret
}