client

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Overview

Package client is a client usable in the agent or an agent sub-process to receive configs from the core remoteconfig service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAgent

func WithAgent(name, version string) func(opts *Options)

WithAgent specifies the client name and version

func WithCluster

func WithCluster(name, id string) func(opts *Options)

WithCluster specifies the cluster name and id

func WithDirectorRootOverride

func WithDirectorRootOverride(site string, directorRootOverride string) func(opts *Options)

WithDirectorRootOverride specifies the director root to

func WithPollInterval

func WithPollInterval(duration time.Duration) func(opts *Options)

WithPollInterval specifies the polling interval

func WithProducts

func WithProducts(products ...string) func(opts *Options)

WithProducts specifies the product lists

func WithUpdater added in v0.52.0

func WithUpdater() func(opts *Options)

WithUpdater specifies that this client is an updater

func WithoutTufVerification

func WithoutTufVerification() func(opts *Options)

WithoutTufVerification disables TUF verification of configs

Types

type Client

type Client struct {
	Options

	ID string
	// contains filtered or unexported fields
}

Client is a remote-configuration client to obtain configurations from the local API

func NewClient

func NewClient(updater ConfigFetcher, opts ...func(o *Options)) (*Client, error)

NewClient creates a new client

func NewGRPCClient

func NewGRPCClient(ipcAddress string, cmdPort string, authToken string, tlsConfig *tls.Config, opts ...func(o *Options)) (*Client, error)

NewGRPCClient creates a new client that retrieves updates over the datadog-agent's secure GRPC client

func NewUnverifiedGRPCClient

func NewUnverifiedGRPCClient(ipcAddress string, cmdPort string, authToken string, tlsConfig *tls.Config, opts ...func(o *Options)) (*Client, error)

NewUnverifiedGRPCClient creates a new client that does not perform any TUF verification

func NewUnverifiedMRFGRPCClient added in v0.54.0

func NewUnverifiedMRFGRPCClient(ipcAddress string, cmdPort string, authToken string, tlsConfig *tls.Config, opts ...func(o *Options)) (*Client, error)

NewUnverifiedMRFGRPCClient creates a new client that does not perform any TUF verification and gets failover configs via gRPC

func (*Client) Close

func (c *Client) Close()

Close terminates the client's poll loop.

A client that has been closed cannot be restarted

func (*Client) GetClientID added in v0.74.0

func (c *Client) GetClientID() string

GetClientID gets the client ID

func (*Client) GetConfigs

func (c *Client) GetConfigs(product string) map[string]state.RawConfig

GetConfigs returns the current configs applied of a product.

func (*Client) GetInstallerState added in v0.58.0

func (c *Client) GetInstallerState() *pbgo.ClientUpdater

GetInstallerState gets the installer state

func (*Client) SetAgentName

func (c *Client) SetAgentName(agentName string)

SetAgentName updates the agent name of the RC client should only be used by the fx component

func (*Client) SetCWSWorkloads

func (c *Client) SetCWSWorkloads(workloads []string)

SetCWSWorkloads updates the list of workloads that needs cws profiles

func (*Client) SetInstallerState added in v0.58.0

func (c *Client) SetInstallerState(state *pbgo.ClientUpdater)

SetInstallerState sets the installer state

func (*Client) Start

func (c *Client) Start()

Start starts the client's poll loop.

If the client is already started, this is a no-op. At this time, a client that has been stopped cannot be restarted.

func (*Client) Subscribe

func (c *Client) Subscribe(product string, cb func(update map[string]state.RawConfig, applyStateCallback func(string, state.ApplyStatus)))

Subscribe subscribes to config updates of a product.

func (*Client) SubscribeAll added in v0.58.0

func (c *Client) SubscribeAll(product string, listener Listener)

SubscribeAll subscribes to all events (config updates, state changed, ...)

func (*Client) SubscribeIgnoreExpiration added in v0.65.0

func (c *Client) SubscribeIgnoreExpiration(product string, cb func(update map[string]state.RawConfig, applyStateCallback func(string, state.ApplyStatus)))

SubscribeIgnoreExpiration subscribes to config updates of a product, but ignores the case when signatures have expired.

func (*Client) UpdateApplyStatus

func (c *Client) UpdateApplyStatus(cfgPath string, status state.ApplyStatus)

UpdateApplyStatus updates the config's metadata to reflect its applied status

type ConfigFetcher added in v0.52.0

type ConfigFetcher interface {
	ClientGetConfigs(context.Context, *pbgo.ClientGetConfigsRequest) (*pbgo.ClientGetConfigsResponse, error)
}

ConfigFetcher defines the interface that an agent client uses to get config updates

func NewAgentGRPCConfigFetcher

func NewAgentGRPCConfigFetcher(ipcAddress string, cmdPort string, authToken string, tlsConfig *tls.Config) (ConfigFetcher, error)

NewAgentGRPCConfigFetcher returns a gRPC config fetcher using the secure agent client

func NewMRFAgentGRPCConfigFetcher added in v0.54.0

func NewMRFAgentGRPCConfigFetcher(ipcAddress string, cmdPort string, authToken string, tlsConfig *tls.Config) (ConfigFetcher, error)

NewMRFAgentGRPCConfigFetcher returns a gRPC config fetcher using the secure agent MRF client

type Listener added in v0.58.0

type Listener interface {
	// OnUpdate is called when new remote configuration data is available for processing.
	// This method is the primary mechanism for delivering configuration updates to listeners.
	//
	// Parameters:
	//   - configs: A map of configuration file paths to their raw configuration data.
	//             The key is the configuration file path/identifier, and the value contains
	//             the raw configuration content that needs to be processed by the listener.
	//   - applyStateCallback: A callback function that must be called by the listener to report
	//                        the success or failure of applying each configuration. This callback
	//                        takes two parameters:
	//                        * cfgPath: The path/identifier of the configuration being reported
	//                        * status: The apply status indicating success, failure, or error details
	//
	// Behavior:
	//   - Called only when there are actual configuration changes to process
	//   - May be skipped if signature verification fails and ShouldIgnoreSignatureExpiration() returns false
	//   - Listeners should process all provided configurations and report their apply status
	//   - The applyStateCallback must be called for proper state tracking and error reporting
	OnUpdate(map[string]state.RawConfig, func(cfgPath string, status state.ApplyStatus))

	// OnStateChange is called when the remote config client's connectivity state changes.
	// The parameter indicates the health state of the remote config service connection:
	//   - true: The client has successfully connected/reconnected to the remote config service
	//   - false: The client has encountered errors and lost connectivity to the remote config service
	//
	// This callback allows listeners to:
	//   - React to service availability changes
	//   - Implement fallback behavior when remote config is unavailable
	//   - Adjust application behavior based on remote config service health
	//
	// Note: OnStateChange is only called after the first successful connection has been established.
	// Initial connection attempts that fail will not trigger this callback until a successful
	// connection is made, after which subsequent failures will trigger OnStateChange(false).
	OnStateChange(bool)

	// ShouldIgnoreSignatureExpiration determines whether this listener should continue to receive
	// configuration updates even when TUF (The Update Framework) signature verification fails
	// due to expired signatures.
	//
	// If it returns true the listener will continue to receive OnUpdate calls
	// even when signatures, are expired.
	//
	// Security Considerations:
	//   - Returning true bypasses an important security mechanism and should be used cautiously
	//   - Only use true for configurations that are not security-sensitive
	//
	// Usage Context:
	//   - Checked before calling OnUpdate when response.ConfigStatus != CONFIG_STATUS_OK
	//   - Allows selective bypassing of signature expiration per listener
	//   - Enables graceful degradation of service when signature infrastructure has issues
	ShouldIgnoreSignatureExpiration() bool
}

Listener defines the interface of a remote config listener

func NewListener added in v0.58.0

func NewListener(onUpdate func(updates map[string]state.RawConfig, applyStateCallback func(string, state.ApplyStatus)), onStateChange func(bool)) Listener

NewListener creates a remote config listener from a couple of update and state change callbacks

func NewUpdateListener added in v0.58.0

func NewUpdateListener(onUpdate func(updates map[string]state.RawConfig, applyStateCallback func(string, state.ApplyStatus))) Listener

NewUpdateListener creates a remote config listener from a update callback

func NewUpdateListenerIgnoreExpiration added in v0.65.0

func NewUpdateListenerIgnoreExpiration(onUpdate func(updates map[string]state.RawConfig, applyStateCallback func(string, state.ApplyStatus))) Listener

NewUpdateListenerIgnoreExpiration creates a remote config listener that ignores signature expiration

type Options

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

Options describes the client options

Jump to

Keyboard shortcuts

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