istio: istio.io/istio/galley/pkg/config/event Index | Files

package event

import "istio.io/istio/galley/pkg/config/event"

Index

Package Files

buffer.go dispatcher.go event.go handler.go handlers.go kind.go processor.go queue.go router.go source.go transformer.go

type Buffer Uses

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

Buffer is a growing event buffer.

func NewBuffer Uses

func NewBuffer() *Buffer

NewBuffer returns new Buffer instance

func WithBuffer Uses

func WithBuffer(s Dispatcher) *Buffer

WithBuffer returns a new Buffer instance that listens to the given Source.

func (*Buffer) Clear Uses

func (b *Buffer) Clear()

Clear the buffer contents.

func (*Buffer) Dispatch Uses

func (b *Buffer) Dispatch(handler Handler)

Dispatch implements Source

func (*Buffer) Handle Uses

func (b *Buffer) Handle(e Event)

Handle implements Handler

func (*Buffer) Process Uses

func (b *Buffer) Process()

Process events in the buffer. This method will not return until the Buffer is stopped.

func (*Buffer) Stop Uses

func (b *Buffer) Stop()

Stop processing

type Dispatcher Uses

type Dispatcher interface {
    // Dispatch events to the given handler.
    Dispatch(handler Handler)
}

Dispatcher is an event source that can dispatch events to Handlers.

type Event Uses

type Event struct {
    Kind Kind

    // The collection that this event is emanating from.
    Source collection.Name

    // A single entry, in case the event is Added, Updated or Deleted.
    Entry *resource.Entry
}

Event represents a change that occurred against a resource in the source config system.

func AddFor Uses

func AddFor(source collection.Name, r *resource.Entry) Event

AddFor creates an Add event for the given source and entry.

func DeleteFor Uses

func DeleteFor(source collection.Name, name resource.Name, v resource.Version) Event

DeleteFor creates a Delete event for the given source and name.

func DeleteForResource Uses

func DeleteForResource(source collection.Name, r *resource.Entry) Event

DeleteForResource creates a Deleted event for the given source and entry.

func FullSyncFor Uses

func FullSyncFor(source collection.Name) Event

FullSyncFor creates a FullSync event for the given source.

func UpdateFor Uses

func UpdateFor(source collection.Name, r *resource.Entry) Event

UpdateFor creates an Update event for the given source and entry.

func (*Event) Clone Uses

func (e *Event) Clone() Event

Clone creates a deep clone of the event.

func (*Event) IsSource Uses

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 (*Event) IsSourceAny Uses

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 (Event) String Uses

func (e Event) String() string

String implements Stringer.String

func (*Event) WithSource Uses

func (e *Event) WithSource(s collection.Name) Event

WithSource returns a new event with the source changed to the given collection.Name, if the event.Kind != Reset.

type FnTransform Uses

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

FnTransform is a base type for handling common Transformer operations.

func NewFnTransform Uses

func NewFnTransform(inputs, outputs collection.Names, 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 (*FnTransform) DispatchFor Uses

func (t *FnTransform) DispatchFor(c collection.Name, h Handler)

DispatchFor implements Transformer

func (*FnTransform) Handle Uses

func (t *FnTransform) Handle(e Event)

Handle implements Transformer

func (*FnTransform) Inputs Uses

func (t *FnTransform) Inputs() collection.Names

Inputs partially implements Transformer

func (*FnTransform) Outputs Uses

func (t *FnTransform) Outputs() collection.Names

Outputs partially implements Transformer

func (*FnTransform) Start Uses

func (t *FnTransform) Start()

Start implements Transformer

func (*FnTransform) Stop Uses

func (t *FnTransform) Stop()

Stop implements Transformer

type Handler Uses

type Handler interface {
    Handle(e Event)
}

Handler handles an incoming resource event.

func CombineHandlers Uses

func CombineHandlers(h1 Handler, h2 Handler) Handler

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.

func HandlerFromFn Uses

func HandlerFromFn(fn func(e Event)) Handler

HandlerFromFn returns a new Handler, based on the Handler function.

func SentinelHandler Uses

func SentinelHandler() Handler

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 Uses

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.

func (*Handlers) Add Uses

func (hs *Handlers) Add(h Handler)

Add a new handler to handlers

func (*Handlers) Handle Uses

func (hs *Handlers) Handle(e Event)

Handle implements Handler

func (*Handlers) Size Uses

func (hs *Handlers) Size() int

Size returns number of handlers in this handler set.

type Kind Uses

type Kind int

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
)

func (Kind) String Uses

func (k Kind) String() string

String implements Stringer.String

type Processor Uses

type Processor interface {
    Handler

    Start()
    Stop()
}

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.

type Router Uses

type Router interface {
    Handler
    Broadcast(e Event)
}

Router distributes events to different handlers, based on collection name.

func AddToRouter Uses

func AddToRouter(r Router, source collection.Name, handler Handler) Router

AddToRouter adds the given handler for the given source collection.

func NewRouter Uses

func NewRouter() Router

NewRouter returns a new instance of Router

type Source Uses

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.

func CombineSources Uses

func CombineSources(s ...Source) Source

CombineSources combines multiple Sources and returns it as a single Source

type Transformer Uses

type Transformer interface {
    Processor

    // DispatchFor registers the given handler for a particular output collection.
    DispatchFor(c collection.Name, h Handler)

    // Inputs for this transformer
    Inputs() collection.Names

    // Outputs for this transformer
    Outputs() collection.Names
}

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 19 packages. Updated 2019-10-08. Refresh now. Tools for package owners.