config

package
v0.0.0-...-6637ac4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoListenerName = errors.New("No listener name specified")
	ErrNoKVStore      = errors.New("No kv store provided")
)
View Source
var ErrNoHealthCheckFn = errors.New("No health check function provided")
View Source
var ErrNoSuchBackend = errors.New("Backend definition not found")
View Source
var ErrNoSuchServer = errors.New("Server definition not found")
View Source
var ListenContext bool

ListenContext is set to true if the listen command is being executed

View Source
var (
	NullJSON = []byte("null")
)

NullJSON represents the marshaling of a nil value

Functions

func ActiveListenerNames

func ActiveListenerNames() []string

ActiveListenerNames reurns the names of the listeners for whom the associated ServiceConfig has been recorded.

func BuildKVStoreTestConfig

func BuildKVStoreTestConfig(t *testing.T) kvstore.KVStore

func RecordActiveConfig

func RecordActiveConfig(serviceConfig *ServiceConfig)

RecordActiveConfig allows a service config constructed from a listener name to be recorded and made available to all code using the xavi framework

func RegisterHealthCheckForBackend

func RegisterHealthCheckForBackend(kvs kvstore.KVStore, backend string, hcfn HealthCheckFn) error

RegisterHealthCheckForBackend registers the given health check for every server associated with the given backend

func RegisterHealthCheckForServer

func RegisterHealthCheckForServer(kvs kvstore.KVStore, server string, hcfn HealthCheckFn) error

RegisterHealthCheckForServer registers a custom health check function for a given server. The configuration store is check for the existence of the specified server definition prior to storing the health check function.

Types

type BackendConfig

type BackendConfig struct {
	Name               string
	ServerNames        []string
	LoadBalancerPolicy string
	CACertPath         string
	TLSOnly            bool
}

BackendConfig defines the data stored for a Backend definition

func JSONToBackend

func JSONToBackend(bytes []byte) *BackendConfig

JSONToBackend unmarshals a JSON representation of a BackendCOnfig

func ListBackendConfigs

func ListBackendConfigs(kvs kvstore.KVStore) ([]*BackendConfig, error)

ListBackendConfigs lists the backend definitions present in the supplied KVS

func ReadBackendConfig

func ReadBackendConfig(name string, kvs kvstore.KVStore) (*BackendConfig, error)

ReadBackendConfig reads a backend config defnition using the supplied KVS

func (*BackendConfig) Store

func (backendConfig *BackendConfig) Store(kvs kvstore.KVStore) error

Store persists a backend definition using the supplied key value store

type HealthCheckFn

type HealthCheckFn func(string, *http.Transport) <-chan bool

HealthCheckFn defines the signature of custom health checks

func HealthCheckForServer

func HealthCheckForServer(server string) HealthCheckFn

HealthCheckForServer returns the custom health check function associated with a server

type ListenerConfig

type ListenerConfig struct {
	Name           string
	RouteNames     []string
	HealthEndpoint bool
}

ListenerConfig represents a listener configuration definition

func JSONToListener

func JSONToListener(bytes []byte) *ListenerConfig

JSONToListener unmarshals the JSON representation of a listener definition

func ListListenerConfigs

func ListListenerConfigs(kvs kvstore.KVStore) ([]*ListenerConfig, error)

ListListenerConfigs retrieves the listener defs from the KVS

func ReadListenerConfig

func ReadListenerConfig(name string, kvs kvstore.KVStore) (*ListenerConfig, error)

ReadListenerConfig retrieves the named listener definition from the supplied KVS

func (*ListenerConfig) Store

func (listenerConfig *ListenerConfig) Store(kvs kvstore.KVStore) (err error)

Store persists the listener defintions in the supplied key value store

type RouteConfig

type RouteConfig struct {
	Name                string
	URIRoot             string
	Backends            []string
	Plugins             []string
	MultiBackendAdapter string
	MsgProps            string
}

RouteConfig represents a route configuration definition

func JSONToRoute

func JSONToRoute(bytes []byte) *RouteConfig

JSONToRoute unmarshals the JSON representation of a route definition

func ListRouteConfigs

func ListRouteConfigs(kvs kvstore.KVStore) ([]*RouteConfig, error)

ListRouteConfigs returns the route configs in the key value store

func ReadRouteConfig

func ReadRouteConfig(name string, kvs kvstore.KVStore) (*RouteConfig, error)

ReadRouteConfig retrieves the specified route config using the supplied key value store

func (*RouteConfig) Store

func (routeConfig *RouteConfig) Store(kvs kvstore.KVStore) error

Store persists the route definition using the supplied KVS

type ServerConfig

type ServerConfig struct {
	Name                string
	Address             string
	Port                int
	PingURI             string
	HealthCheck         string
	HealthCheckInterval int //In milliseconds
	HealthCheckTimeout  int //In milliseconds
}

ServerConfig represents a server configuration definition

func JSONToServer

func JSONToServer(bytes []byte) *ServerConfig

JSONToServer unmarshals a JSON representation of a server definition

func ListServerConfigs

func ListServerConfigs(kvs kvstore.KVStore) ([]*ServerConfig, error)

ListServerConfigs returns a list of the server configurations present in the supplied KVS

func ReadServerConfig

func ReadServerConfig(name string, kvs kvstore.KVStore) (*ServerConfig, error)

ReadServerConfig retrieves the named server defnition using the supplied KVS

func (*ServerConfig) Store

func (serverConfig *ServerConfig) Store(kvs kvstore.KVStore) (err error)

Store persists the server configuration definition in the supplied KVS

type ServiceBackend

type ServiceBackend struct {
	Backend *BackendConfig
	Servers []*ServerConfig
}

ServiceBackend contains the backend definition and all the linked server definitions for the backend

type ServiceConfig

type ServiceConfig struct {
	Listener *ListenerConfig
	Routes   []*ServiceRoute
}

ServiceConfig is the top level structure that joins up all the configuration from the listener def into a single structure, reading the definition from the KVStore

func ActiveConfigForListener

func ActiveConfigForListener(listenerName string) *ServiceConfig

ActiveConfigForListener returns the ServiceConfig associated with the provided listener names

func ReadServiceConfig

func ReadServiceConfig(listenerName string, kvs kvstore.KVStore) (*ServiceConfig, error)

ReadServiceConfig reads all configuration for a given listener and links all the definitions together

func (*ServiceConfig) LogConfig

func (sc *ServiceConfig) LogConfig()

LogConfig logs information associated with the ServiceConfig

type ServiceRoute

type ServiceRoute struct {
	Route    *RouteConfig
	Backends []*ServiceBackend
}

ServiceRoute contains the Route definition read from config and the associated backend configs as well

Jump to

Keyboard shortcuts

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