fanout

package
v0.46.6 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 21 Imported by: 27

Documentation

Overview

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. Logically, it represents all the Subscriptions to a single Knative Channel. It will normally be used in conjunction with multichannelfanout.EventHandler, which contains multiple fanout.EventHandler, each corresponding to a single Knative Channel.

Index

Constants

View Source
const (
	ScopeName = "knative.dev/eventing/pkg/channel/fanout"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Subscriptions []Subscription `json:"subscriptions"`
	// AsyncHandler controls whether the Subscriptions are called synchronous or asynchronously.
	// It is expected to be false when used as a sidecar.
	//
	// Async handler is subject to event loss since it responds with 200 before forwarding the event
	// to all subscriptions.
	AsyncHandler bool `json:"asyncHandler,omitempty"`
}

Config for a fanout.EventHandler.

type DispatchResult added in v0.24.0

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

func NewDispatchResult added in v0.24.0

func NewDispatchResult(err error, info *kncloudevents.DispatchInfo) DispatchResult

func (DispatchResult) Error added in v0.24.0

func (d DispatchResult) Error() error

func (DispatchResult) Info added in v0.24.0

type EventHandler added in v0.39.0

type EventHandler interface {
	nethttp.Handler
	SetSubscriptions(ctx context.Context, subs []Subscription)
	GetSubscriptions(ctx context.Context) []Subscription
}

EventHandler is an http.Handler but has methods for managing the fanout Subscriptions. Get/Set methods are synchronized, and GetSubscriptions returns a copy of the Subscriptions, so you can use it to fetch a snapshot and use it after that safely.

type FanoutEventHandler added in v0.39.0

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

FanoutEventHandler is a http.Handler that takes a single request in and fans it out to N other servers.

func NewFanoutEventHandler added in v0.39.0

func NewFanoutEventHandler(
	logger *zap.Logger,
	config Config,
	eventTypeHandler *eventtype.EventTypeAutoHandler,
	channelRef *duckv1.KReference,
	channelUID *types.UID,
	eventDispatcher *kncloudevents.Dispatcher,
	meterProvider metric.MeterProvider,
	traceProvider trace.TracerProvider,
	receiverOpts ...channel.EventReceiverOptions,
) (*FanoutEventHandler, error)

NewFanoutEventHandler creates a new fanout.EventHandler.

func (*FanoutEventHandler) GetSubscriptions added in v0.39.0

func (f *FanoutEventHandler) GetSubscriptions(ctx context.Context) []Subscription

func (*FanoutEventHandler) ServeHTTP added in v0.39.0

func (f *FanoutEventHandler) ServeHTTP(response nethttp.ResponseWriter, request *nethttp.Request)

func (*FanoutEventHandler) SetSubscriptions added in v0.39.0

func (f *FanoutEventHandler) SetSubscriptions(ctx context.Context, subs []Subscription)

type Subscription added in v0.17.0

type Subscription struct {
	Subscriber     duckv1.Addressable
	Reply          *duckv1.Addressable
	DeadLetter     *duckv1.Addressable
	RetryConfig    *kncloudevents.RetryConfig
	ServiceAccount *types.NamespacedName
	Name           string
	Namespace      string
	UID            types.UID
}

func SubscriberSpecToFanoutConfig added in v0.17.0

func SubscriberSpecToFanoutConfig(sub eventingduckv1.SubscriberSpec) (*Subscription, error)

Jump to

Keyboard shortcuts

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