mesh

package
v0.0.0-...-a142011 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 21 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMeshConfig

func ApplyMeshConfig(yaml string, defaultConfig *meshconfig.MeshConfig) (*meshconfig.MeshConfig, error)

ApplyMeshConfig returns a new MeshConfig decoded from the input YAML with the provided defaults applied to omitted configuration values.

func ApplyMeshConfigDefaults

func ApplyMeshConfigDefaults(yaml string) (*meshconfig.MeshConfig, error)

ApplyMeshConfigDefaults returns a new MeshConfig decoded from the input YAML with defaults applied to omitted configuration values.

func ApplyProxyConfig

func ApplyProxyConfig(yaml string, meshConfig *meshconfig.MeshConfig) (*meshconfig.MeshConfig, error)

ApplyProxyConfig applies the give proxy config yaml to a mesh config object. The passed in mesh config will not be modified.

func DeepCopyMeshConfig

func DeepCopyMeshConfig(mc *meshconfig.MeshConfig) (*meshconfig.MeshConfig, error)

func DefaultMeshConfig

func DefaultMeshConfig() *meshconfig.MeshConfig

DefaultMeshConfig returns the default mesh config. This is merged with values from the mesh config map.

func DefaultMeshNetworks

func DefaultMeshNetworks() *meshconfig.MeshNetworks

DefaultMeshNetworks returns a default meshnetworks configuration. By default, it is empty.

func DefaultProxyConfig

func DefaultProxyConfig() *meshconfig.ProxyConfig

DefaultProxyConfig for individual proxies

func EmptyMeshNetworks

func EmptyMeshNetworks() meshconfig.MeshNetworks

EmptyMeshNetworks configuration with no networks

func MergeProxyConfig

func MergeProxyConfig(yaml string, proxyConfig *meshconfig.ProxyConfig) (*meshconfig.ProxyConfig, error)

MergeProxyConfig merges the given proxy config yaml with the given proxy config object.

func ParseMeshNetworks

func ParseMeshNetworks(yaml string) (*meshconfig.MeshNetworks, error)

ParseMeshNetworks returns a new MeshNetworks decoded from the input YAML.

func PrettyFormatOfMeshConfig

func PrettyFormatOfMeshConfig(meshConfig *meshconfig.MeshConfig) string

func ReadMeshConfig

func ReadMeshConfig(filename string) (*meshconfig.MeshConfig, error)

ReadMeshConfig gets mesh configuration from a config file

func ReadMeshConfigData

func ReadMeshConfigData(filename string) (string, error)

ReadMeshConfigData gets mesh configuration yaml from a config file

func ReadMeshNetworks

func ReadMeshNetworks(filename string) (*meshconfig.MeshNetworks, error)

ReadMeshNetworks gets mesh networks configuration from a config file

Types

type Holder

type Holder interface {
	Mesh() *meshconfig.MeshConfig
}

Holder of a mesh configuration.

type MultiWatcher

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

MultiWatcher is a struct wrapping the internal injector to let users know that both

func NewMultiWatcher

func NewMultiWatcher(config *meshconfig.MeshConfig) *MultiWatcher

func (MultiWatcher) AddMeshHandler

func (w MultiWatcher) AddMeshHandler(h func()) *WatcherHandlerRegistration

AddMeshHandler registers a callback handler for changes to the mesh config.

func (*MultiWatcher) AddNetworksHandler

func (w *MultiWatcher) AddNetworksHandler(h func()) *WatcherHandlerRegistration

AddNetworksHandler registers a callback handler for changes to the mesh network config.

func (MultiWatcher) DeleteMeshHandler

func (w MultiWatcher) DeleteMeshHandler(registration *WatcherHandlerRegistration)

func (*MultiWatcher) DeleteNetworksHandler

func (w *MultiWatcher) DeleteNetworksHandler(registration *WatcherHandlerRegistration)

DeleteNetworksHandler deregister a callback handler for changes to the mesh network config.

func (MultiWatcher) HandleMeshConfig

func (w MultiWatcher) HandleMeshConfig(meshConfig *meshconfig.MeshConfig)

HandleMeshConfig calls all handlers for a given mesh configuration update. This must be called with a lock on w.Mutex, or updates may be applied out of order.

func (MultiWatcher) HandleMeshConfigData

func (w MultiWatcher) HandleMeshConfigData(yaml string)

HandleMeshConfigData keeps track of the standard mesh config. These are merged with the user mesh config, but takes precedence.

func (MultiWatcher) HandleUserMeshConfig

func (w MultiWatcher) HandleUserMeshConfig(yaml string)

HandleUserMeshConfig keeps track of user mesh config overrides. These are merged with the standard mesh config, which takes precedence.

func (MultiWatcher) Mesh

func (w MultiWatcher) Mesh() *meshconfig.MeshConfig

Mesh returns the latest mesh config.

func (*MultiWatcher) Networks

func (w *MultiWatcher) Networks() *meshconfig.MeshNetworks

Networks returns the latest network configuration for the mesh.

func (*MultiWatcher) PrevNetworks

func (w *MultiWatcher) PrevNetworks() *meshconfig.MeshNetworks

PrevNetworks returns the previous network configuration for the mesh.

func (*MultiWatcher) SetNetworks

func (w *MultiWatcher) SetNetworks(meshNetworks *meshconfig.MeshNetworks)

SetNetworks will use the given value for mesh networks and notify all handlers of the change

type NetworksHolder

type NetworksHolder interface {
	SetNetworks(*meshconfig.MeshNetworks)
	Networks() *meshconfig.MeshNetworks
	PrevNetworks() *meshconfig.MeshNetworks
}

NetworksHolder is a holder of a mesh networks configuration.

type NetworksWatcher

type NetworksWatcher interface {
	NetworksHolder

	// AddNetworksHandler registers a callback handler for changes to the networks config.
	AddNetworksHandler(func()) *WatcherHandlerRegistration

	// DeleteNetworksHandler unregisters a callback handler when remote cluster is removed.
	DeleteNetworksHandler(registration *WatcherHandlerRegistration)
}

NetworksWatcher watches changes to the mesh networks config.

func NewFixedNetworksWatcher

func NewFixedNetworksWatcher(networks *meshconfig.MeshNetworks) NetworksWatcher

NewFixedNetworksWatcher creates a new NetworksWatcher that always returns the given config. It will never fire any events, since the config never changes.

func NewNetworksWatcher

func NewNetworksWatcher(fileWatcher filewatcher.FileWatcher, filename string) (NetworksWatcher, error)

NewNetworksWatcher creates a new watcher for changes to the given networks config file.

type TestWatcher

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

only used for testing, exposes a blocking Update method that allows test environments to trigger meshConfig updates

func NewTestWatcher

func NewTestWatcher(meshConfig *meshconfig.MeshConfig) *TestWatcher

func (*TestWatcher) AddMeshHandler

func (w *TestWatcher) AddMeshHandler(h func()) *WatcherHandlerRegistration

AddMeshHandler registers a callback handler for changes to the mesh config.

func (*TestWatcher) DeleteMeshHandler

func (w *TestWatcher) DeleteMeshHandler(registration *WatcherHandlerRegistration)

func (*TestWatcher) HandleMeshConfig

func (w *TestWatcher) HandleMeshConfig(meshConfig *meshconfig.MeshConfig)

HandleMeshConfig calls all handlers for a given mesh configuration update. This must be called with a lock on w.Mutex, or updates may be applied out of order.

func (*TestWatcher) HandleMeshConfigData

func (w *TestWatcher) HandleMeshConfigData(yaml string)

HandleMeshConfigData keeps track of the standard mesh config. These are merged with the user mesh config, but takes precedence.

func (*TestWatcher) HandleUserMeshConfig

func (w *TestWatcher) HandleUserMeshConfig(yaml string)

HandleUserMeshConfig keeps track of user mesh config overrides. These are merged with the standard mesh config, which takes precedence.

func (*TestWatcher) Mesh

func (w *TestWatcher) Mesh() *meshconfig.MeshConfig

Mesh returns the latest mesh config.

func (*TestWatcher) Update

func (t *TestWatcher) Update(meshConfig *meshconfig.MeshConfig, timeout time.Duration) error

blocks until watcher handlers trigger

type Watcher

type Watcher interface {
	Holder

	// AddMeshHandler registers a callback handler for changes to the mesh config.
	AddMeshHandler(h func()) *WatcherHandlerRegistration

	// DeleteMeshHandler unregisters a callback handler when remote cluster is removed.
	DeleteMeshHandler(registration *WatcherHandlerRegistration)

	// HandleUserMeshConfig keeps track of user mesh config overrides. These are merged with the standard
	// mesh config, which takes precedence.
	HandleUserMeshConfig(string)
}

Watcher is a Holder whose mesh config can be updated asynchronously.

func NewFileWatcher

func NewFileWatcher(fileWatcher filewatcher.FileWatcher, filename string, multiWatch bool) (Watcher, error)

NewFileWatcher creates a new Watcher for changes to the given mesh config file. Returns an error if the given file does not exist or failed during parsing.

func NewFixedWatcher

func NewFixedWatcher(mesh *meshconfig.MeshConfig) Watcher

NewFixedWatcher creates a new Watcher that always returns the given mesh config. It will never fire any events, since the config never changes.

type WatcherHandlerRegistration

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

WatcherHandlerRegistration will be returned to caller to remove the handler later.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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