config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfig

func SaveConfig(filename string, config *Config) error

SaveConfig saves configuration to a JSON file

Types

type BackendConfig

type BackendConfig struct {
	URL    string `json:"url"`
	Weight int    `json:"weight"`
}

BackendConfig holds backend server configuration

type Config

type Config struct {
	Server      ServerConfig      `json:"server"`
	Backends    []BackendConfig   `json:"backends"`
	HealthCheck HealthCheckConfig `json:"healthCheck"`
	Strategy    StrategyConfig    `json:"strategy"`
	Logging     LoggingConfig     `json:"logging"`
}

Config represents the application configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads configuration from a JSON file

type HealthCheckConfig

type HealthCheckConfig struct {
	Interval time.Duration `json:"interval"`
	Timeout  time.Duration `json:"timeout"`
	Path     string        `json:"path"`
}

HealthCheckConfig holds health check settings

type LoggingConfig

type LoggingConfig struct {
	Level  string `json:"level"`  // debug, info, warn, error
	Format string `json:"format"` // text, json
}

LoggingConfig holds logging settings

type ServerConfig

type ServerConfig struct {
	Port         int           `json:"port"`
	ReadTimeout  time.Duration `json:"readTimeout"`
	WriteTimeout time.Duration `json:"writeTimeout"`
	IdleTimeout  time.Duration `json:"idleTimeout"`
}

ServerConfig holds server-specific settings

type StrategyConfig

type StrategyConfig struct {
	Type string `json:"type"` // roundrobin, leastconnections, random, weighted
}

StrategyConfig holds load balancing strategy settings

Jump to

Keyboard shortcuts

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