kubernetes: github.com/bboreham/kubernetes/pkg/client/record Index | Files

package record

import "github.com/bboreham/kubernetes/pkg/client/record"

Package record has all client logic for recording and reporting events.

Index

Package Files

doc.go event.go events_cache.go fake.go

func DefaultEventFilterFunc Uses

func DefaultEventFilterFunc(event *api.Event) bool

DefaultEventFilterFunc returns false for all incoming events

func EventAggregatorByReasonFunc Uses

func EventAggregatorByReasonFunc(event *api.Event) (string, string)

EventAggregatorByReasonFunc aggregates events by exact match on event.Source, event.InvolvedObject, event.Type and event.Reason

func EventAggregatorByReasonMessageFunc Uses

func EventAggregatorByReasonMessageFunc(event *api.Event) string

EventAggregratorByReasonMessageFunc returns an aggregate message by prefixing the incoming message

type EventAggregator Uses

type EventAggregator struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

EventAggregator identifies similar events and aggregates them into a single event

func NewEventAggregator Uses

func NewEventAggregator(lruCacheSize int, keyFunc EventAggregatorKeyFunc, messageFunc EventAggregatorMessageFunc,
    maxEvents int, maxIntervalInSeconds int, clock util.Clock) *EventAggregator

NewEventAggregator returns a new instance of an EventAggregator

func (*EventAggregator) EventAggregate Uses

func (e *EventAggregator) EventAggregate(newEvent *api.Event) (*api.Event, error)

EventAggregate identifies similar events and groups into a common event if required

type EventAggregatorKeyFunc Uses

type EventAggregatorKeyFunc func(event *api.Event) (aggregateKey string, localKey string)

EventAggregatorKeyFunc is responsible for grouping events for aggregation It returns a tuple of the following: aggregateKey - key the identifies the aggregate group to bucket this event localKey - key that makes this event in the local group

type EventAggregatorMessageFunc Uses

type EventAggregatorMessageFunc func(event *api.Event) string

EventAggregatorMessageFunc is responsible for producing an aggregation message

type EventBroadcaster Uses

type EventBroadcaster interface {
    // StartEventWatcher starts sending events received from this EventBroadcaster to the given
    // event handler function. The return value can be ignored or used to stop recording, if
    // desired.
    StartEventWatcher(eventHandler func(*api.Event)) watch.Interface

    // StartRecordingToSink starts sending events received from this EventBroadcaster to the given
    // sink. The return value can be ignored or used to stop recording, if desired.
    StartRecordingToSink(sink EventSink) watch.Interface

    // StartLogging starts sending events received from this EventBroadcaster to the given logging
    // function. The return value can be ignored or used to stop recording, if desired.
    StartLogging(logf func(format string, args ...interface{})) watch.Interface

    // NewRecorder returns an EventRecorder that can be used to send events to this EventBroadcaster
    // with the event source set to the given event source.
    NewRecorder(source api.EventSource) EventRecorder
}

EventBroadcaster knows how to receive events and send them to any EventSink, watcher, or log.

func NewBroadcaster Uses

func NewBroadcaster() EventBroadcaster

Creates a new event broadcaster.

type EventCorrelateResult Uses

type EventCorrelateResult struct {
    // the event after correlation
    Event *api.Event
    // if provided, perform a strategic patch when updating the record on the server
    Patch []byte
    // if true, do no further processing of the event
    Skip bool
}

EventCorrelateResult is the result of a Correlate

type EventCorrelator Uses

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

EventCorrelator processes all incoming events and performs analysis to avoid overwhelming the system. It can filter all incoming events to see if the event should be filtered from further processing. It can aggregate similar events that occur frequently to protect the system from spamming events that are difficult for users to distinguish. It performs de-duplication to ensure events that are observed multiple times are compacted into a single event with increasing counts.

func NewEventCorrelator Uses

func NewEventCorrelator(clock util.Clock) *EventCorrelator

NewEventCorrelator returns an EventCorrelator configured with default values.

The EventCorrelator is responsible for event filtering, aggregating, and counting prior to interacting with the API server to record the event.

The default behavior is as follows:

* No events are filtered from being recorded
* Aggregation is performed if a similar event is recorded 10 times in a
  in a 10 minute rolling interval.  A similar event is an event that varies only by
  the Event.Message field.  Rather than recording the precise event, aggregation
  will create a new event whose message reports that it has combined events with
  the same reason.
* Events are incrementally counted if the exact same event is encountered multiple
  times.

func (*EventCorrelator) EventCorrelate Uses

func (c *EventCorrelator) EventCorrelate(newEvent *api.Event) (*EventCorrelateResult, error)

EventCorrelate filters, aggregates, counts, and de-duplicates all incoming events

func (*EventCorrelator) UpdateState Uses

func (c *EventCorrelator) UpdateState(event *api.Event)

UpdateState based on the latest observed state from server

type EventFilterFunc Uses

type EventFilterFunc func(event *api.Event) bool

EventFilterFunc is a function that returns true if the event should be skipped

type EventRecorder Uses

type EventRecorder interface {
    // Event constructs an event from the given information and puts it in the queue for sending.
    // 'object' is the object this event is about. Event will make a reference-- or you may also
    // pass a reference to the object directly.
    // 'type' of this event, and can be one of Normal, Warning. New types could be added in future
    // 'reason' is the reason this event is generated. 'reason' should be short and unique; it
    // should be in UpperCamelCase format (starting with a capital letter). "reason" will be used
    // to automate handling of events, so imagine people writing switch statements to handle them.
    // You want to make that easy.
    // 'message' is intended to be human readable.
    //
    // The resulting event will be created in the same namespace as the reference object.
    Event(object runtime.Object, eventtype, reason, message string)

    // Eventf is just like Event, but with Sprintf for the message field.
    Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

    // PastEventf is just like Eventf, but with an option to specify the event's 'timestamp' field.
    PastEventf(object runtime.Object, timestamp unversioned.Time, eventtype, reason, messageFmt string, args ...interface{})
}

EventRecorder knows how to record events on behalf of an EventSource.

type EventSink Uses

type EventSink interface {
    Create(event *api.Event) (*api.Event, error)
    Update(event *api.Event) (*api.Event, error)
    Patch(oldEvent *api.Event, data []byte) (*api.Event, error)
}

EventSink knows how to store events (client.Client implements it.) EventSink must respect the namespace that will be embedded in 'event'. It is assumed that EventSink will return the same sorts of errors as pkg/client's REST client.

type FakeRecorder Uses

type FakeRecorder struct {
    Events []string
}

FakeRecorder is used as a fake during tests.

func (*FakeRecorder) Event Uses

func (f *FakeRecorder) Event(object runtime.Object, eventtype, reason, message string)

func (*FakeRecorder) Eventf Uses

func (f *FakeRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

func (*FakeRecorder) PastEventf Uses

func (f *FakeRecorder) PastEventf(object runtime.Object, timestamp unversioned.Time, eventtype, reason, messageFmt string, args ...interface{})

Package record imports 17 packages (graph). Updated 2017-03-08. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).