import "istio.io/istio/pkg/config/event"
buffer.go dispatcher.go event.go handler.go handlers.go kind.go processor.go queue.go router.go source.go transformer.go
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a growing event buffer.
NewBuffer returns new Buffer instance
func WithBuffer(s Dispatcher) *Buffer
WithBuffer returns a new Buffer instance that listens to the given Source.
Clear the buffer contents.
Dispatch implements Source
Handle implements Handler
Process events in the buffer. This method will not return until the Buffer is stopped.
Stop processing
Dispatcher is an event source that can dispatch events to Handlers.
type Event struct { Kind Kind // Source collection that this event is emanating from. Source collection.Schema // A single entry, in case the event is Added, Updated or Deleted. Resource *resource.Instance }
Event represents a change that occurred against a resource in the source config system.
AddFor creates an Add event for the given source and entry.
DeleteFor creates a Delete event for the given source and name.
DeleteForResource creates a Deleted event for the given source and entry.
func FullSyncFor(source collection.Schema) Event
FullSyncFor creates a FullSync event for the given source.
UpdateFor creates an Update event for the given source and entry.
Clone creates a deep clone of the event.
func (e *Event) IsSource(s collection.Name) bool
IsSource checks whether the event has the appropriate source and returns false if it does not.
func (e *Event) IsSourceAny(names ...collection.Name) bool
IsSourceAny checks whether the event has the appropriate source and returns false if it does not.
func (e *Event) SourceName() collection.Name
SourceName is a utility method that returns the name of the source. If nil, returns "".
String implements Stringer.String
func (e *Event) WithSource(s collection.Schema) Event
WithSource returns a new event with the source changed to the given collection.Name, if the event.Kind != Reset.
type FnTransform struct {
// contains filtered or unexported fields
}
FnTransform is a base type for handling common Transformer operations.
func NewFnTransform(inputs, outputs collection.Schemas, startFn, stopFn func(), fn func(e Event, handler Handler)) *FnTransform
NewFnTransform returns a Transformer based on the given start, stop and input event handler functions.
func (t *FnTransform) DispatchFor(c collection.Schema, h Handler)
DispatchFor implements Transformer
func (t *FnTransform) Handle(e Event)
Handle implements Transformer
func (t *FnTransform) Inputs() collection.Schemas
Inputs partially implements Transformer
func (t *FnTransform) Outputs() collection.Schemas
Outputs partially implements Transformer
func (t *FnTransform) Start()
Start implements Transformer
func (t *FnTransform) Stop()
Stop implements Transformer
Handler handles an incoming resource event.
CombineHandlers combines two handlers into a single set of handlers and returns. If any of the Handlers is an instance of Handlers, then their contains will be flattened into a single list.
HandlerFromFn returns a new Handler, based on the Handler function.
SentinelHandler is a special handler that does nothing with the event. It is useful to avoid nil checks on Handler fields. Specialized operations, such as CombineHandlers recognize SentinelHandlers and elide them when merging.
type Handlers struct {
// contains filtered or unexported fields
}
Handlers is a group of zero or more Handlers. Handlers is an instance of Handler, dispatching incoming events to the Handlers it contains.
Add a new handler to handlers
Handle implements Handler
Size returns number of handlers in this handler set.
Kind is the type of an event for a resource collection.
const ( // None is a sentinel value. Should not be used. None Kind = iota // Added indicates that a new resource has been added to a collection. Added // Updated indicates that an existing resource has been updated in a collection. Updated // Deleted indicates an existing resource has been deleted from a collection. Deleted // FullSync indicates that the source has completed the publishing of initial state of a collection as a series // of add events. Events after FullSync are incremental change events that were applied to the origin collection. FullSync // Reset indicates that the originating event.Source had a change that cannot be recovered from (e.g. CRDs have // changed). It indicates that the listener should abandon its internal state and restart. This is a source-level // event and applies to all collections. Reset )
String implements Stringer.String
Processor is a config event processor.
- Start and Stop can be called multiple times, idempotently. - A processor can keep internal state after it is started, but it *must* not carry state over between multiple start/stop calls. - It must complete all its internal initialization, by the time Start call returns. That is, the callers will assume that events can be sent (be be processed) after Start returns. - Processor may still receive events after Stop is called. These events must be discarded.
Router distributes events to different handlers, based on collection name.
AddToRouter adds the given handler for the given source collection.
NewRouter returns a new instance of Router
type Source interface { Dispatcher // Start sending events. Start() // Stop sending events. Stop() }
Source is an event source for a single collection.
- A Source can be started/stopped multiple times, idempotently. - Every time a Source is started, it is expected to send the full list of events, including a FullSync event for each collection. - It must halt its dispatch of events before the Stop() call returns. The callers will assume that once Stop() returns, none of the registered handlers will receive any new events from this source.
CombineSources combines multiple Sources and returns it as a single Source
type Transformer interface { Processor // DispatchFor registers the given handler for a particular output collection. DispatchFor(c collection.Schema, h Handler) // Inputs for this transformer Inputs() collection.Schemas // Outputs for this transformer Outputs() collection.Schemas }
Transformer is a Processor that transforms input events from one or more collections to a set of output events to one or more collections.
- A transformer must declare its inputs and outputs collections. via Inputs and Outputs methods. These must return idempotent results. - For every output collection that Transformer exposes, it must send a FullSync event, once the Transformer is started.
Package event imports 6 packages (graph) and is imported by 14 packages. Updated 2020-11-12. Refresh now. Tools for package owners.