Documentation ¶
Overview ¶
Package local integrates the proxycfg Manager with the agent's local state.
Index ¶
- func Sync(ctx context.Context, cfg SyncConfig)
- type ConfigManager
- type ConfigSource
- type MockConfigManager
- func (_m *MockConfigManager) Deregister(proxyID proxycfg.ProxyID, source proxycfg.ProxySource)
- func (_m *MockConfigManager) Register(proxyID proxycfg.ProxyID, service *structs.NodeService, ...) error
- func (_m *MockConfigManager) RegisteredProxies(source proxycfg.ProxySource) []proxycfg.ProxyID
- func (_m *MockConfigManager) Watch(id proxycfg.ProxyID) (<-chan *proxycfg.ConfigSnapshot, proxycfg.CancelFunc)
- type SyncConfig
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 ¶
func (m *ConfigSource) Watch(serviceID structs.ServiceID, nodeName string, _ string) (<-chan *proxycfg.ConfigSnapshot, proxycfg.CancelFunc, error)
type MockConfigManager ¶
MockConfigManager is an autogenerated mock type for the ConfigManager type
func NewMockConfigManager ¶
func NewMockConfigManager(t testing.TB) *MockConfigManager
NewMockConfigManager creates a new instance of MockConfigManager. It also registers the testing.TB 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 ¶
func (_m *MockConfigManager) Watch(id proxycfg.ProxyID) (<-chan *proxycfg.ConfigSnapshot, proxycfg.CancelFunc)
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 }
SyncConfig contains the dependencies required by Sync.