Documentation ¶
Overview ¶
Package swappable provides an http.Handler that delegates all HTTP requests to an underlying multichannelfanout.MessageHandler. When a new configuration is available, a new multichannelfanout.MessageHandler is created and swapped in. All subsequent requests go to the new handler. It is often used in conjunction with something that notices changes to ConfigMaps, such as configmap.watcher or configmap.filesystem.
Index ¶
- type MessageHandler
- func (h *MessageHandler) GetHandler() *multichannelfanout.MessageHandler
- func (h *MessageHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (h *MessageHandler) SetHandler(nh *multichannelfanout.MessageHandler)
- func (h *MessageHandler) UpdateConfig(context context.Context, dispatcherConfig channel.EventDispatcherConfig, ...) error
- type UpdateConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageHandler ¶ added in v0.14.0
type MessageHandler struct {
// contains filtered or unexported fields
}
Handler is an http.Handler that atomically swaps between underlying handlers.
func NewEmptyMessageHandler ¶ added in v0.14.0
func NewEmptyMessageHandler(context context.Context, logger *zap.Logger, messageDispatcher channel.MessageDispatcher) (*MessageHandler, error)
NewEmptyMessageHandler creates a new swappable.Handler with an empty configuration.
func NewMessageHandler ¶ added in v0.14.0
func NewMessageHandler(handler *multichannelfanout.MessageHandler, logger *zap.Logger) *MessageHandler
NewMessageHandler creates a new swappable.Handler.
func (*MessageHandler) GetHandler ¶ added in v0.15.0
func (h *MessageHandler) GetHandler() *multichannelfanout.MessageHandler
GetHandler gets the current multichannelfanout.MessageHandler to delegate all HTTP requests to.
func (*MessageHandler) ServeHTTP ¶ added in v0.14.0
func (h *MessageHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)
ServeHTTP delegates all HTTP requests to the current multichannelfanout.MessageHandler.
func (*MessageHandler) SetHandler ¶ added in v0.15.0
func (h *MessageHandler) SetHandler(nh *multichannelfanout.MessageHandler)
SetHandler sets a new multichannelfanout.MessageHandler to delegate all subsequent HTTP requests to.
func (*MessageHandler) UpdateConfig ¶ added in v0.14.0
func (h *MessageHandler) UpdateConfig(context context.Context, dispatcherConfig channel.EventDispatcherConfig, config *multichannelfanout.Config) error
UpdateConfig copies the current inner multichannelfanout.MessageHandler with the new configuration. If the new configuration is valid, then the new inner handler is swapped in and will start serving HTTP traffic.
type UpdateConfig ¶
type UpdateConfig func(config *multichannelfanout.Config) error
UpdateConfig updates the configuration to use the new config, returning an error if it can't.