local

package
v1.16.109 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package local integrates the proxycfg Manager with the agent's local state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sync

func Sync(ctx context.Context, cfg SyncConfig)

Sync watches the agent's local state and registers/deregisters services with the proxycfg Manager ahead-of-time so they're ready immediately when a proxy begins an xDS stream.

It runs until the given context is canceled, so should be called it its own goroutine.

Note: proxy service definitions from the agent's local state will always overwrite definitions of the same service from other sources (e.g. the catalog).

Types

type ConfigManager

type ConfigManager interface {
	Watch(id proxycfg.ProxyID) (<-chan *proxycfg.ConfigSnapshot, proxycfg.CancelFunc)
	Register(proxyID proxycfg.ProxyID, service *structs.NodeService, source proxycfg.ProxySource, token string, overwrite bool) error
	Deregister(proxyID proxycfg.ProxyID, source proxycfg.ProxySource)
	RegisteredProxies(source proxycfg.ProxySource) []proxycfg.ProxyID
}

type ConfigSource

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

ConfigSource wraps a proxycfg.Manager to create watches on services local to the agent (pre-registered by Sync).

func NewConfigSource

func NewConfigSource(cfgMgr ConfigManager) *ConfigSource

NewConfigSource builds a ConfigSource with the given proxycfg.Manager.

func (*ConfigSource) Watch

type MockConfigManager

type MockConfigManager struct {
	mock.Mock
}

MockConfigManager is an autogenerated mock type for the ConfigManager type

func NewMockConfigManager

func NewMockConfigManager(t mockConstructorTestingTNewMockConfigManager) *MockConfigManager

NewMockConfigManager creates a new instance of MockConfigManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockConfigManager) Deregister

func (_m *MockConfigManager) Deregister(proxyID proxycfg.ProxyID, source proxycfg.ProxySource)

Deregister provides a mock function with given fields: proxyID, source

func (*MockConfigManager) Register

func (_m *MockConfigManager) Register(proxyID proxycfg.ProxyID, service *structs.NodeService, source proxycfg.ProxySource, token string, overwrite bool) error

Register provides a mock function with given fields: proxyID, service, source, token, overwrite

func (*MockConfigManager) RegisteredProxies

func (_m *MockConfigManager) RegisteredProxies(source proxycfg.ProxySource) []proxycfg.ProxyID

RegisteredProxies provides a mock function with given fields: source

func (*MockConfigManager) Watch

Watch provides a mock function with given fields: id

type SyncConfig

type SyncConfig struct {
	// Manager is the proxycfg Manager with which proxy services will be registered.
	Manager ConfigManager

	// State is the agent's local state that will be watched for proxy registrations.
	State *local.State

	// Tokens is used to retrieve a fallback ACL token if a service is registered
	// without one.
	Tokens *token.Store

	// NodeName is the name of the local agent node.
	NodeName string

	// Logger will be used to write log messages.
	Logger hclog.Logger

	// ResyncFrequency is how often to do a resync and recreate any terminated
	// watches.
	ResyncFrequency time.Duration
}

SyncConfig contains the dependencies required by Sync.

Jump to

Keyboard shortcuts

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