{"modulePath":"github.com/UnityTech/client-go","version":"v11.0.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package record\n\nPackage record has all client logic for recording and reporting events.\n\n## Functions\n\n```go\nfunc EventAggregatorByReasonFunc(event *v1.Event) (string, string)\n```\nEventAggregatorByReasonFunc aggregates events by exact match on event.Source, event.InvolvedObject, event.Type and event.Reason\n\n```go\nfunc EventAggregatorByReasonMessageFunc(event *v1.Event) string\n```\nEventAggregratorByReasonMessageFunc returns an aggregate message by prefixing the incoming message\n\n## Types\n\n```go\ntype EventAggregator struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nEventAggregator identifies similar events and aggregates them into a single event\n\n```go\nfunc NewEventAggregator(lruCacheSize int, keyFunc EventAggregatorKeyFunc, messageFunc EventAggregatorMessageFunc,\n\tmaxEvents int, maxIntervalInSeconds int, clock clock.Clock) *EventAggregator\n```\nNewEventAggregator returns a new instance of an EventAggregator\n\n```go\nfunc (e *EventAggregator) EventAggregate(newEvent *v1.Event) (*v1.Event, string)\n```\nEventAggregate checks if a similar event has been seen according to the aggregation configuration (max events, max interval, etc) and returns:\n\n  - The (potentially modified) event that should be created\n  - The cache key for the event, for correlation purposes. This will be set to the full key for normal events, and to the result of EventAggregatorMessageFunc for aggregate events.\n\n```go\ntype EventAggregatorKeyFunc func(event *v1.Event) (aggregateKey string, localKey string)\n```\nEventAggregatorKeyFunc 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\n\n```go\ntype EventAggregatorMessageFunc func(event *v1.Event) string\n```\nEventAggregatorMessageFunc is responsible for producing an aggregation message\n\n```go\ntype EventBroadcaster interface {\n\t// StartEventWatcher starts sending events received from this EventBroadcaster to the given\n\t// event handler function. The return value can be ignored or used to stop recording, if\n\t// desired.\n\tStartEventWatcher(eventHandler func(*v1.Event)) watch.Interface\n\n\t// StartRecordingToSink starts sending events received from this EventBroadcaster to the given\n\t// sink. The return value can be ignored or used to stop recording, if desired.\n\tStartRecordingToSink(sink EventSink) watch.Interface\n\n\t// StartLogging starts sending events received from this EventBroadcaster to the given logging\n\t// function. The return value can be ignored or used to stop recording, if desired.\n\tStartLogging(logf func(format string, args ...interface{})) watch.Interface\n\n\t// NewRecorder returns an EventRecorder that can be used to send events to this EventBroadcaster\n\t// with the event source set to the given event source.\n\tNewRecorder(scheme *runtime.Scheme, source v1.EventSource) EventRecorder\n}\n```\nEventBroadcaster knows how to receive events and send them to any EventSink, watcher, or log.\n\n```go\nfunc NewBroadcaster() EventBroadcaster\n```\nCreates a new event broadcaster.\n\n```go\nfunc NewBroadcasterForTests(sleepDuration time.Duration) EventBroadcaster\n```\n\n```go\ntype EventCorrelateResult struct {\n\t// the event after correlation\n\tEvent *v1.Event\n\t// if provided, perform a strategic patch when updating the record on the server\n\tPatch []byte\n\t// if true, do no further processing of the event\n\tSkip bool\n}\n```\nEventCorrelateResult is the result of a Correlate\n\n```go\ntype EventCorrelator struct {\n\t// contains filtered or unexported fields\n}\n```\nEventCorrelator 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.\n\n```go\nfunc NewEventCorrelator(clock clock.Clock) *EventCorrelator\n```\nNewEventCorrelator returns an EventCorrelator configured with default values.\n\nThe EventCorrelator is responsible for event filtering, aggregating, and counting prior to interacting with the API server to record the event.\n\nThe default behavior is as follows:\n\n  - 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.\n  - Events are incrementally counted if the exact same event is encountered multiple times.\n  - A source may burst 25 events about an object, but has a refill rate budget per object of 1 event every 5 minutes to control long-tail of spam.\n\n```go\nfunc (c *EventCorrelator) EventCorrelate(newEvent *v1.Event) (*EventCorrelateResult, error)\n```\nEventCorrelate filters, aggregates, counts, and de-duplicates all incoming events\n\n```go\nfunc (c *EventCorrelator) UpdateState(event *v1.Event)\n```\nUpdateState based on the latest observed state from server\n\n```go\ntype EventFilterFunc func(event *v1.Event) bool\n```\nEventFilterFunc is a function that returns true if the event should be skipped\n\n```go\ntype EventRecorder interface {\n\t// Event constructs an event from the given information and puts it in the queue for sending.\n\t// 'object' is the object this event is about. Event will make a reference-- or you may also\n\t// pass a reference to the object directly.\n\t// 'type' of this event, and can be one of Normal, Warning. New types could be added in future\n\t// 'reason' is the reason this event is generated. 'reason' should be short and unique; it\n\t// should be in UpperCamelCase format (starting with a capital letter). \"reason\" will be used\n\t// to automate handling of events, so imagine people writing switch statements to handle them.\n\t// You want to make that easy.\n\t// 'message' is intended to be human readable.\n\t//\n\t// The resulting event will be created in the same namespace as the reference object.\n\tEvent(object runtime.Object, eventtype, reason, message string)\n\n\t// Eventf is just like Event, but with Sprintf for the message field.\n\tEventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})\n\n\t// PastEventf is just like Eventf, but with an option to specify the event's 'timestamp' field.\n\tPastEventf(object runtime.Object, timestamp metav1.Time, eventtype, reason, messageFmt string, args ...interface{})\n\n\t// AnnotatedEventf is just like eventf, but with annotations attached\n\tAnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})\n}\n```\nEventRecorder knows how to record events on behalf of an EventSource.\n\n```go\ntype EventSink interface {\n\tCreate(event *v1.Event) (*v1.Event, error)\n\tUpdate(event *v1.Event) (*v1.Event, error)\n\tPatch(oldEvent *v1.Event, data []byte) (*v1.Event, error)\n}\n```\nEventSink 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.\n\n```go\ntype EventSourceObjectSpamFilter struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nEventSourceObjectSpamFilter is responsible for throttling the amount of events a source and object can produce.\n\n```go\nfunc NewEventSourceObjectSpamFilter(lruCacheSize, burst int, qps float32, clock clock.Clock) *EventSourceObjectSpamFilter\n```\nNewEventSourceObjectSpamFilter allows burst events from a source about an object with the specified qps refill.\n\n```go\nfunc (f *EventSourceObjectSpamFilter) Filter(event *v1.Event) bool\n```\nFilter controls that a given source+object are not exceeding the allowed rate.\n\n```go\ntype FakeRecorder struct {\n\tEvents chan string\n}\n```\nFakeRecorder is used as a fake during tests. It is thread safe. It is usable when created manually and not by NewFakeRecorder, however all events may be thrown away in this case.\n\n```go\nfunc NewFakeRecorder(bufferSize int) *FakeRecorder\n```\nNewFakeRecorder creates new fake event recorder with event channel with buffer of given size.\n\n```go\nfunc (f *FakeRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})\n```\n\n```go\nfunc (f *FakeRecorder) Event(object runtime.Object, eventtype, reason, message string)\n```\n\n```go\nfunc (f *FakeRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})\n```\n\n```go\nfunc (f *FakeRecorder) PastEventf(object runtime.Object, timestamp metav1.Time, eventtype, reason, messageFmt string, args ...interface{})\n```\n\n","path":"github.com/UnityTech/client-go/tools/record","name":"record","synopsis":"Package record has all client logic for recording and reporting events.","isRedistributable":true}
