agent

package
v0.0.0-...-0cb8421 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPrometheusCPURequests    = "100m"
	DefaultPrometheusCPULimits      = "500m"
	DefaultPrometheusMemoryRequests = "512Mi"
	DefaultPrometheusMemoryLimits   = "2Gi"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

func New

func New(cfg *Config) (*Agent, error)

func (*Agent) MetricsAddr

func (a *Agent) MetricsAddr() string

MetricsAddr blocks until the metrics server has bound its listener, then returns the address it is listening on.

func (*Agent) Run

func (a *Agent) Run() error

func (*Agent) Shutdown

func (a *Agent) Shutdown()

Shutdown gracefully shuts down the agent (useful for testing)

type Config

type Config struct {
	LogLevel        string        `mapstructure:"log_level"`
	LogFormat       string        `mapstructure:"log_format"`
	PollingInterval time.Duration `mapstructure:"polling_interval"`
	GracefulTimeout time.Duration `mapstructure:"graceful_timeout"`

	// API Configuration
	APIURLs       []string `mapstructure:"api_urls"` // List of complete API URLs to poll
	LabelSelector string   `mapstructure:"label_selector"`
	JWTToken      string   `mapstructure:"jwt_token"`

	// OIDC Configuration for API authentication
	OIDCClientID     string `mapstructure:"oidc_client_id"`
	OIDCClientSecret string `mapstructure:"oidc_client_secret"`
	OIDCIssuerURL    string `mapstructure:"oidc_issuer_url"`

	// Kubernetes Configuration
	KubeConfig string `mapstructure:"kube_config"`
	Namespace  string `mapstructure:"namespace"`

	// Prometheus Configuration
	Prometheus PrometheusConfig `mapstructure:"prometheus"`

	// Blackbox Configuration
	Blackbox k8s.BlackboxConfig `mapstructure:"blackbox"`

	// Metrics server address (default ":8080")
	MetricsAddr string `mapstructure:"metrics_addr"`

	// Leader election (safe to run multiple replicas)
	LeaderElect bool `mapstructure:"leader_elect"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) GetAPIURLs

func (c *Config) GetAPIURLs() []string

GetAPIURLs returns the list of complete API URLs

func (*Config) String

func (c *Config) String() string

String returns a formatted string representation of the configuration

type PrometheusConfig

type PrometheusConfig struct {
	RemoteWriteURL    string `mapstructure:"remote_write_url"`
	RemoteWriteTenant string `mapstructure:"remote_write_tenant"`
	CPURequests       string `mapstructure:"cpu_requests"`
	CPULimits         string `mapstructure:"cpu_limits"`
	MemoryRequests    string `mapstructure:"memory_requests"`
	MemoryLimits      string `mapstructure:"memory_limits"`
	ManagedByOperator string `mapstructure:"managed_by_operator"`
	APIGroup          string `mapstructure:"api_group"`
}

func (*PrometheusConfig) ApplyDefaults

func (pc *PrometheusConfig) ApplyDefaults()

func (*PrometheusConfig) Validate

func (pc *PrometheusConfig) Validate() error

Validate validates the PrometheusConfig fields

type Worker

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

func NewWorker

func NewWorker(cfg *Config) (*Worker, error)

func (*Worker) SetReadinessCallback

func (w *Worker) SetReadinessCallback(callback func(bool))

SetReadinessCallback sets the callback function to signal readiness state changes

func (*Worker) Start

func (w *Worker) Start(ctx context.Context, taskWG *sync.WaitGroup, shutdownChan chan struct{}) error

Jump to

Keyboard shortcuts

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