Documentation ¶
Overview ¶
Package contour contains the translation business logic that listens to Kubernetes ResourceEventHandler events and translates those into additions/deletions in caches connected to the Envoy xDS gRPC API server.
Package contour contains the translation business logic that listens to Kubernetes ResourceEventHandler events and translates those into additions/deletions in caches connected to the Envoy xDS gRPC API server.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cond ¶ added in v0.3.0
type Cond struct {
// contains filtered or unexported fields
}
Cond implements a condition variable, a rendezvous point for goroutines waiting for or announcing the ocurence of an event.
Unlike sync.Cond, Cond communciates with waiters via channels registered by the waiters. This permits goroutines to wait on Cond events using select.
Example ¶
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel() ch := make(chan int, 1) last := 0 var c Cond go func() { for { time.Sleep(100 * time.Millisecond) c.Notify() } }() for { c.Register(ch, last) select { case last = <-ch: fmt.Println("notification received:", last) case <-ctx.Done(): fmt.Println("timeout") return } }
Output:
func (*Cond) Notify ¶ added in v0.3.0
Notify notifies all interested waiters that an event has ocured.
func (*Cond) Register ¶ added in v0.3.0
Register registers ch to receive a value when Notify is called. The value of last is the count of the times Notify has been called on this Cond. It functions of a sequence counter, if the value of last supplied to Register is less than the Conds internal counter, then the caller has missed at least one notification and will fire immediately.
Sends by the broadcaster to ch must not block, therefore ch must have a capacity of at least 1.
type EventHandler ¶ added in v1.0.0
type EventHandler struct { Builder dag.Builder Observer dag.Observer HoldoffDelay, HoldoffMaxDelay time.Duration StatusUpdater k8s.StatusUpdater logrus.FieldLogger // IsLeader will become ready to read when this EventHandler becomes // the leader. If IsLeader is not readable, or nil, status events will // be suppressed. IsLeader chan struct{} // Sequence is a channel that receives a incrementing sequence number // for each update processed. The updates may be processed immediately, or // delayed by a holdoff timer. In each case a non blocking send to Sequence // will be made once the resource update is received (note // that the DAG is not guaranteed to be called each time). Sequence chan int // contains filtered or unexported fields }
EventHandler implements cache.ResourceEventHandler, filters k8s events towards a dag.Builder and calls through to the Observer to notify it that a new DAG is available.
func (*EventHandler) OnAdd ¶ added in v1.0.0
func (e *EventHandler) OnAdd(obj interface{})
func (*EventHandler) OnDelete ¶ added in v1.0.0
func (e *EventHandler) OnDelete(obj interface{})
func (*EventHandler) OnUpdate ¶ added in v1.0.0
func (e *EventHandler) OnUpdate(oldObj, newObj interface{})
func (*EventHandler) Start ¶ added in v1.0.0
func (e *EventHandler) Start() func(<-chan struct{}) error
Start initializes the EventHandler and returns a function suitable for registration with a workgroup.Group.
func (*EventHandler) UpdateNow ¶ added in v1.0.0
func (e *EventHandler) UpdateNow()
UpdateNow enqueues a DAG update subject to the holdoff timer.
type EventRecorder ¶ added in v1.2.0
type EventRecorder struct { Next cache.ResourceEventHandler Counter *prometheus.CounterVec }
EventRecorder records the count and kind of events forwarded to another ResourceEventHandler.
func (*EventRecorder) OnAdd ¶ added in v1.2.0
func (e *EventRecorder) OnAdd(obj interface{})
func (*EventRecorder) OnDelete ¶ added in v1.2.0
func (e *EventRecorder) OnDelete(obj interface{})
func (*EventRecorder) OnUpdate ¶ added in v1.2.0
func (e *EventRecorder) OnUpdate(oldObj, newObj interface{})
type Observer ¶ added in v1.9.0
type Observer interface {
Refresh()
}
Observer is an interface for receiving notifications.
func ComposeObservers ¶ added in v1.9.0
ComposeObservers returns a new Observer that calls each of its arguments in turn.
type ObserverFunc ¶ added in v1.9.0
type ObserverFunc func()
ObserverFunc is a function that implements the Observer interface by calling itself. It can be nil.
func (ObserverFunc) Refresh ¶ added in v1.9.0
func (f ObserverFunc) Refresh()
type RebuildMetricsObserver ¶ added in v1.8.0
type RebuildMetricsObserver struct { // Metrics to emit. Metrics *metrics.Metrics // IsLeader will become ready to read when this EventHandler becomes // the leader. If IsLeader is not readable, or nil, status events will // be suppressed. IsLeader chan struct{} // NextObserver contains the stack of dag.Observers that act on DAG rebuilds. NextObserver dag.Observer }
RebuildMetricsObserver is a dag.Observer that emits metrics for DAG rebuilds.
func (*RebuildMetricsObserver) OnChange ¶ added in v1.8.0
func (m *RebuildMetricsObserver) OnChange(d *dag.DAG)