multichannelfanout

package
v0.0.0-...-157142f Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

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.Handler and each incoming request is inspected to determine which Channel it is on. This Handler delegates the HTTP handling to the fanout.Handler 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.Handler. When a new configuration is available, a new multichannelfanout.Handler is created and swapped in for all subsequent requests. The old multichannelfanout.Handler 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        `json:"namespace"`
	Name         string        `json:"name"`
	FanoutConfig fanout.Config `json:"fanoutConfig"`
}

ChannelConfig is the configuration for a single Channel.

type Config

type Config struct {
	// The configuration of each channel in this handler.
	ChannelConfigs []ChannelConfig `json:"channelConfigs"`
}

Config for a multichannelfanout.Handler.

func Parse

func Parse(logger *zap.Logger, str string) (*Config, error)

Parse attempts to parse the YAML string into a multichannelfanout.Config.

type Handler

type Handler 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.Handler corresponding to that Channel.

func NewHandler

func NewHandler(logger *zap.Logger, conf Config) (*Handler, error)

NewHandler creates a new Handler.

func (*Handler) ConfigDiff

func (h *Handler) 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 (*Handler) CopyWithNewConfig

func (h *Handler) CopyWithNewConfig(conf Config) (*Handler, 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 (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP delegates the actual handling of the request to a fanout.Handler, based on the request's channel key.

Jump to

Keyboard shortcuts

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