swappable

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package swappable provides an http.Handler that delegates all HTTP requests to an underlying multichannelfanout.Handler. When a new configuration is available, a new multichannelfanout.Handler 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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

http.Handler that atomically swaps between underlying handlers.

func NewEmptyHandler

func NewEmptyHandler(logger *zap.Logger) (*Handler, error)

func NewHandler

func NewHandler(handler *multichannelfanout.Handler, logger *zap.Logger) *Handler

NewHandler creates a new swappable.Handler.

func (*Handler) ServeHTTP

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

ServeHTTP delegates all HTTP requests to the current multichannelfanout.Handler.

func (*Handler) UpdateConfig

func (h *Handler) UpdateConfig(config *multichannelfanout.Config) error

UpdateConfig copies the current inner multichannelfanout.Handler 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

Jump to

Keyboard shortcuts

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