Documentation
¶
Overview ¶
Package multichannelfanout provides an http.Handler that takes in one request to a Knative Channel and fans it out to N other requests. Logically, it represents multiple Knative Channels. It is made up of a map, map[channel]fanout.MessageHandler and each incoming request is inspected to determine which Channel it is on. This Handler delegates the HTTP handling to the fanout.MessageHandler corresponding to the incoming request's Channel. It is often used in conjunction with a swappable.Handler. The swappable.Handler delegates all its requests to the multichannelfanout.MessageHandler. When a new configuration is available, a new multichannelfanout.MessageHandler is created and swapped in for all subsequent requests. The old multichannelfanout.MessageHandler is discarded.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelConfig ¶
type ChannelConfig struct { Namespace string Name string HostName string FanoutConfig fanout.Config }
ChannelConfig is the configuration for a single Channel.
type Config ¶
type Config struct { // The configuration of each channel in this handler. ChannelConfigs []ChannelConfig }
Config for a multichannelfanout.Handler.
type MessageHandler ¶ added in v0.14.0
type MessageHandler struct {
// contains filtered or unexported fields
}
Handler is an http.Handler that introspects the incoming request to determine what Channel it is on, and then delegates handling of that request to the single fanout.MessageHandler corresponding to that Channel.
func NewMessageHandler ¶ added in v0.14.0
func NewMessageHandler(_ context.Context, logger *zap.Logger, messageDispatcher channel.MessageDispatcher, conf Config) (*MessageHandler, error)
NewHandler creates a new Handler.
func (*MessageHandler) ConfigDiff ¶ added in v0.14.0
func (h *MessageHandler) ConfigDiff(updated Config) string
ConfigDiffs diffs the new config with the existing config. If there are no differences, then the empty string is returned. If there are differences, then a non-empty string is returned describing the differences.
func (*MessageHandler) CopyWithNewConfig ¶ added in v0.14.0
func (h *MessageHandler) CopyWithNewConfig(ctx context.Context, dispatcherConfig channel.EventDispatcherConfig, conf Config) (*MessageHandler, error)
CopyWithNewConfig creates a new copy of this Handler with all the fields identical, except the new Handler uses conf, rather than copying the existing Handler's config.
func (*MessageHandler) ServeHTTP ¶ added in v0.14.0
func (h *MessageHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)
ServeHTTP delegates the actual handling of the request to a fanout.MessageHandler, based on the request's channel key.