sesame

package
v0.0.0-...-a1fe31f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package sesame 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 sesame 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

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

func (c *Cond) Notify(hints ...string)

Notify notifies all interested waiters that an event has ocured.

func (*Cond) Register

func (c *Cond) Register(ch chan int, last int, hints ...string)

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

type EventHandler struct {
	logrus.FieldLogger
	// 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 NewEventHandler

func NewEventHandler(config EventHandlerConfig) *EventHandler

func (*EventHandler) NeedLeaderElection

func (e *EventHandler) NeedLeaderElection() bool

func (*EventHandler) OnAdd

func (e *EventHandler) OnAdd(obj interface{})

func (*EventHandler) OnDelete

func (e *EventHandler) OnDelete(obj interface{})

func (*EventHandler) OnElectedLeader

func (e *EventHandler) OnElectedLeader()

Implements leadership.NeedLeaderElectionNotification

func (*EventHandler) OnUpdate

func (e *EventHandler) OnUpdate(oldObj, newObj interface{})

func (*EventHandler) Sequence

func (e *EventHandler) Sequence() <-chan int

Sequence returns 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 the sequence channel will be made once the resource update is received (note that the DAG is not guaranteed to be called each time).

func (*EventHandler) Start

func (e *EventHandler) Start(ctx context.Context) error

type EventHandlerConfig

type EventHandlerConfig struct {
	Logger                        logrus.FieldLogger
	Builder                       *dag.Builder
	Observer                      dag.Observer
	HoldoffDelay, HoldoffMaxDelay time.Duration
	StatusUpdater                 k8s.StatusUpdater
}

type EventRecorder

type EventRecorder struct {
	Next    cache.ResourceEventHandler
	Counter *prometheus.CounterVec
}

EventRecorder records the count and kind of events forwarded to another ResourceEventHandler.

func (*EventRecorder) OnAdd

func (e *EventRecorder) OnAdd(obj interface{})

func (*EventRecorder) OnDelete

func (e *EventRecorder) OnDelete(obj interface{})

func (*EventRecorder) OnUpdate

func (e *EventRecorder) OnUpdate(oldObj, newObj interface{})

type Observer

type Observer interface {
	Refresh()
}

Observer is an interface for receiving notifications.

func ComposeObservers

func ComposeObservers(observers ...Observer) Observer

ComposeObservers returns a new Observer that calls each of its arguments in turn.

type ObserverFunc

type ObserverFunc func()

ObserverFunc is a function that implements the Observer interface by calling itself. It can be nil.

func (ObserverFunc) Refresh

func (f ObserverFunc) Refresh()

type RebuildMetricsObserver

type RebuildMetricsObserver struct {
	// contains filtered or unexported fields
}

RebuildMetricsObserver is a dag.Observer that emits metrics for DAG rebuilds.

func NewRebuildMetricsObserver

func NewRebuildMetricsObserver(metrics *metrics.Metrics, nextObserver dag.Observer) *RebuildMetricsObserver

func (*RebuildMetricsObserver) OnChange

func (m *RebuildMetricsObserver) OnChange(d *dag.DAG)

func (*RebuildMetricsObserver) OnElectedLeader

func (m *RebuildMetricsObserver) OnElectedLeader()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL