channel

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2020 License: Apache-2.0 Imports: 24 Imported by: 26

Documentation

Index

Constants

View Source
const (
	// EventHistory is the header containing all channel hosts traversed by the event.
	// This is an experimental header: https://github.com/knative/eventing/issues/638.
	EventHistory          = "knativehistory"
	EventHistorySeparator = "; "
)
View Source
const EventDispatcherConfigMap = "config-imc-event-dispatcher"

EventDispatcherConfigMap is the name of the configmap for event dispatcher.

Variables

This section is empty.

Functions

func AddHistory added in v0.14.0

func AddHistory(host string) binding.Transformer

func AppendHistory added in v0.10.0

func AppendHistory(event *cloudevents.Event, host string)

AppendToHistory appends a new host at the end of the list of hosts of the event history.

Types

type ChannelReference

type ChannelReference struct {
	Namespace string
	Name      string
}

ChannelReference references a Channel within the cluster by name and namespace.

func ParseChannel

func ParseChannel(host string) (ChannelReference, error)

ParseChannel converts the channel's hostname into a channel reference.

func (*ChannelReference) String

func (r *ChannelReference) String() string

type DeliveryOptions added in v0.11.0

type DeliveryOptions struct {
	// DeadLetterSink is the sink receiving events that could not be dispatched.
	DeadLetterSink string
}

DeliveryOptions are the delivery options supported by this dispatcher

type Dispatcher

type Dispatcher interface {
	// DispatchEvent dispatches an event to a destination over HTTP.
	//
	// The destination and reply are URLs.
	DispatchEvent(ctx context.Context, event cloudevents.Event, destination, reply string) error

	// DispatchEventWithDelivery dispatches an event to a destination over HTTP with delivery options
	//
	// The destination and reply are URLs.
	DispatchEventWithDelivery(ctx context.Context, event cloudevents.Event, destination, reply string, delivery *DeliveryOptions) error
}

type EventDispatcher added in v0.10.0

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

EventDispatcher dispatches events to a destination over HTTP.

func NewEventDispatcher added in v0.10.0

func NewEventDispatcher(logger *zap.Logger) *EventDispatcher

NewEventDispatcher creates a new event dispatcher that can dispatch events to HTTP destinations.

func NewEventDispatcherFromConfig added in v0.13.0

func NewEventDispatcherFromConfig(logger *zap.Logger, config EventDispatcherConfig) *EventDispatcher

NewEventDispatcherFromConfig creates a new event dispatcher based on config.

func (*EventDispatcher) DispatchEvent added in v0.10.0

func (d *EventDispatcher) DispatchEvent(ctx context.Context, event cloudevents.Event, destination, reply string) error

DispatchEvent dispatches an event to a destination over HTTP.

The destination and reply are URLs.

func (*EventDispatcher) DispatchEventWithDelivery added in v0.11.0

func (d *EventDispatcher) DispatchEventWithDelivery(ctx context.Context, event cloudevents.Event, destination, reply string, delivery *DeliveryOptions) error

DispatchEventWithDelivery dispatches an event to a destination over HTTP with delivery options

The destination and reply are URLs.

type EventDispatcherConfig added in v0.13.0

type EventDispatcherConfig struct {
	kncloudevents.ConnectionArgs
}

EventDispatcherConfig holds the configuration parameters for the event dispatcher.

func NewEventDisPatcherConfigFromConfigMap added in v0.13.0

func NewEventDisPatcherConfigFromConfigMap(config *corev1.ConfigMap) (EventDispatcherConfig, error)

NewEventDisPatcherConfigFromConfigMap converts a k8s configmap into EventDispatcherConfig.

type EventDispatcherConfigStore added in v0.13.0

type EventDispatcherConfigStore struct {
	*knconfigmap.UntypedStore
	// contains filtered or unexported fields
}

EventDispatcherConfigStore loads/unloads untyped configuration from configmap.

func NewEventDispatcherConfigStore added in v0.13.0

func NewEventDispatcherConfigStore(logger knconfigmap.Logger, onAfterStore ...func(name string, value interface{})) *EventDispatcherConfigStore

NewEventDispatcherConfigStore creates a configuration Store

func (*EventDispatcherConfigStore) GetConfig added in v0.13.0

GetConfig returns the current config in the store.

type EventReceiver added in v0.10.0

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

EventReceiver starts a server to receive new events for the channel dispatcher. The new event is emitted via the receiver function.

func NewEventReceiver added in v0.10.0

func NewEventReceiver(receiverFunc ReceiverFunc, logger *zap.Logger, opts ...ReceiverOptions) (*EventReceiver, error)

NewEventReceiver creates an event receiver passing new events to the receiverFunc.

func (*EventReceiver) ServeHTTP added in v0.10.0

func (r *EventReceiver) ServeHTTP(ctx context.Context, event cloudevents.Event, resp *cloudevents.EventResponse) error

func (*EventReceiver) Start added in v0.10.0

func (r *EventReceiver) Start(ctx context.Context) error

Start begins to receive events for the receiver.

Only HTTP POST requests to the root path (/) are accepted. If other paths or methods are needed, use the HandleRequest method directly with another HTTP server.

type MessageDispatcher

type MessageDispatcher interface {
	// DispatchMessage dispatches an event to a destination over HTTP.
	//
	// The destination and reply are URLs.
	DispatchMessage(ctx context.Context, message cloudevents.Message, additionalHeaders nethttp.Header, destination *url.URL, reply *url.URL, deadLetter *url.URL) error
}

type MessageDispatcherImpl added in v0.14.0

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

MessageDispatcherImpl dispatches events to a destination over HTTP.

func NewMessageDispatcher

func NewMessageDispatcher(logger *zap.Logger) *MessageDispatcherImpl

NewMessageDispatcher creates a new event dispatcher that can dispatch events to HTTP destinations.

func NewMessageDispatcherFromConfig added in v0.14.0

func NewMessageDispatcherFromConfig(logger *zap.Logger, config EventDispatcherConfig) *MessageDispatcherImpl

NewMessageDispatcherFromConfig creates a new event dispatcher based on config.

func (*MessageDispatcherImpl) DispatchMessage added in v0.14.0

func (d *MessageDispatcherImpl) DispatchMessage(ctx context.Context, initialMessage cloudevents.Message, initialAdditionalHeaders nethttp.Header, destination *url.URL, reply *url.URL, deadLetter *url.URL) error

type MessageReceiver

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

MessageReceiver starts a server to receive new events for the channel dispatcher. The new event is emitted via the receiver function.

func NewMessageReceiver

func NewMessageReceiver(receiverFunc UnbufferedMessageReceiverFunc, logger *zap.Logger, opts ...MessageReceiverOptions) (*MessageReceiver, error)

NewMessageReceiver creates an event receiver passing new events to the receiverFunc.

func (*MessageReceiver) ServeHTTP added in v0.14.0

func (r *MessageReceiver) ServeHTTP(response nethttp.ResponseWriter, request *nethttp.Request)

func (*MessageReceiver) Start

func (r *MessageReceiver) Start(ctx context.Context) error

Start begins to receive events for the receiver.

Only HTTP POST requests to the root path (/) are accepted. If other paths or methods are needed, use the HandleRequest method directly with another HTTP server.

type MessageReceiverOptions added in v0.14.0

type MessageReceiverOptions func(*MessageReceiver) error

ReceiverOptions provides functional options to MessageReceiver function.

func ResolveMessageChannelFromHostHeader added in v0.14.0

func ResolveMessageChannelFromHostHeader(hostToChannelFunc ResolveChannelFromHostFunc) MessageReceiverOptions

ResolveMessageChannelFromHostHeader is a ReceiverOption for NewMessageReceiver which enables the caller to overwrite the default behaviour defined by ParseChannel function.

type ReceiverFunc added in v0.10.0

ReceiverFunc is the function to be called for handling the event.

type ReceiverOptions

type ReceiverOptions func(*EventReceiver) error

ReceiverOptions provides functional options to EventReceiver function.

func ResolveChannelFromHostHeader

func ResolveChannelFromHostHeader(hostToChannelFunc ResolveChannelFromHostFunc) ReceiverOptions

ResolveChannelFromHostHeader is a ReceiverOption for NewEventReceiver which enables the caller to overwrite the default behaviour defined by ParseChannel function.

type ResolveChannelFromHostFunc

type ResolveChannelFromHostFunc func(string) (ChannelReference, error)

ResolveChannelFromHostFunc function enables EventReceiver to get the Channel Reference from incoming request HostHeader before calling receiverFunc. Returns UnknownHostError if the channel is not found, otherwise returns a generic error.

type UnbufferedMessageReceiverFunc added in v0.14.0

type UnbufferedMessageReceiverFunc func(context.Context, ChannelReference, binding.Message, []binding.Transformer, nethttp.Header) error

UnbufferedMessageReceiverFunc is the function to be called for handling the message. The provided message is not buffered, so it can't be safely read more times. When you perform the write (or the buffering) of the Message, you must use the transformers provided as parameters. This function is responsible for invoking Message.Finish().

type UnknownChannelError added in v0.10.0

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

UnknownChannelError represents the error when an event is received by a channel dispatcher for a channel that does not exist.

func (*UnknownChannelError) Error added in v0.10.0

func (e *UnknownChannelError) Error() string

type UnknownHostError added in v0.14.0

type UnknownHostError string

UnknownHostError represents the error when a ResolveMessageChannelFromHostHeader func cannot resolve an host

func (UnknownHostError) Error added in v0.14.0

func (e UnknownHostError) Error() string

Directories

Path Synopsis
Package fanout provides an http.Handler that takes in one request and fans it out to N other requests, based on a list of Subscriptions.
Package fanout provides an http.Handler that takes in one request and fans it out to N other requests, based on a list of Subscriptions.
Package multichannelfanout provides an http.Handler that takes in one request to a Knative Channel and fans it out to N other requests.
Package multichannelfanout provides an http.Handler that takes in one request to a Knative Channel and fans it out to N other requests.
Package swappable provides an http.Handler that delegates all HTTP requests to an underlying multichannelfanout.Handler.
Package swappable provides an http.Handler that delegates all HTTP requests to an underlying multichannelfanout.Handler.

Jump to

Keyboard shortcuts

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