config

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Type     string      `json:"type" mapstructure:"type"`         // "tokenCount", "parameter", "model"
	Operator string      `json:"operator" mapstructure:"operator"` // ">", "<", "==", "contains"
	Value    interface{} `json:"value" mapstructure:"value"`
}

Condition represents a routing condition

type Config

type Config struct {
	Providers       []Provider        `json:"providers" mapstructure:"providers"`
	Routes          map[string]Route  `json:"routes" mapstructure:"routes"`
	Log             bool              `json:"log" mapstructure:"log"`
	LogFile         string            `json:"log_file" mapstructure:"log_file"`
	Host            string            `json:"host" mapstructure:"host"`
	Port            int               `json:"port" mapstructure:"port"`
	APIKey          string            `json:"apikey" mapstructure:"apikey"`
	ProxyURL        string            `json:"proxy_url" mapstructure:"proxy_url"`
	Performance     PerformanceConfig `json:"performance" mapstructure:"performance"`
	ShutdownTimeout time.Duration     `json:"shutdown_timeout" mapstructure:"shutdown_timeout"`
}

Config represents the main configuration structure for CCProxy

func DefaultConfig

func DefaultConfig() *Config

Default configuration values

func LoadFromFile

func LoadFromFile(path string) (*Config, error)

LoadFromFile loads configuration from a specific file

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

type PerformanceConfig

type PerformanceConfig struct {
	MetricsEnabled          bool          `json:"metrics_enabled" mapstructure:"metrics_enabled"`
	RateLimitEnabled        bool          `json:"rate_limit_enabled" mapstructure:"rate_limit_enabled"`
	RateLimitRequestsPerMin int           `json:"rate_limit_requests_per_min" mapstructure:"rate_limit_requests_per_min"`
	CircuitBreakerEnabled   bool          `json:"circuit_breaker_enabled" mapstructure:"circuit_breaker_enabled"`
	RequestTimeout          time.Duration `json:"request_timeout" mapstructure:"request_timeout"`
	MaxRequestBodySize      int64         `json:"max_request_body_size" mapstructure:"max_request_body_size"`
}

PerformanceConfig represents performance monitoring configuration

type Provider

type Provider struct {
	Name          string              `json:"name" mapstructure:"name"`
	APIBaseURL    string              `json:"api_base_url" mapstructure:"api_base_url"`
	APIKey        string              `json:"api_key" mapstructure:"api_key"`
	Models        []string            `json:"models" mapstructure:"models"`
	Enabled       bool                `json:"enabled" mapstructure:"enabled"`
	Transformers  []TransformerConfig `json:"transformers" mapstructure:"transformers"`
	CreatedAt     time.Time           `json:"created_at" mapstructure:"created_at"`
	UpdatedAt     time.Time           `json:"updated_at" mapstructure:"updated_at"`
	MessageFormat string              `json:"message_format,omitempty" mapstructure:"message_format"` // Message format used by provider
}

Provider represents a LLM provider configuration

type Route

type Route struct {
	Provider   string                 `json:"provider" mapstructure:"provider"`
	Model      string                 `json:"model" mapstructure:"model"`
	Conditions []Condition            `json:"conditions" mapstructure:"conditions"`
	Parameters map[string]interface{} `json:"parameters,omitempty" mapstructure:"parameters"`
}

Route represents a routing configuration

type Service

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

Service handles configuration loading and management

func NewService

func NewService() *Service

NewService creates a new configuration service

func (*Service) DeleteProvider

func (s *Service) DeleteProvider(name string) error

DeleteProvider removes a provider by name

func (*Service) Get

func (s *Service) Get() *Config

Get returns the current configuration (returns a copy to prevent race conditions)

func (*Service) GetProvider

func (s *Service) GetProvider(name string) (*Provider, error)

GetProvider returns a provider by name

func (*Service) Load

func (s *Service) Load() error

Load reads and parses the configuration from all sources

func (*Service) Reload

func (s *Service) Reload() error

Reload reloads the configuration

func (*Service) Save

func (s *Service) Save() error

Save saves the current configuration to file

func (*Service) SaveProvider

func (s *Service) SaveProvider(provider *Provider) error

SaveProvider saves a new provider

func (*Service) SetConfig

func (s *Service) SetConfig(cfg *Config)

SetConfig sets the configuration (mainly for testing)

func (*Service) UpdateProvider

func (s *Service) UpdateProvider(name string, provider *Provider) error

UpdateProvider updates a provider by name

func (*Service) Validate

func (s *Service) Validate() error

Validate checks if the configuration is valid

type TransformerConfig

type TransformerConfig struct {
	Name   string                 `json:"name" mapstructure:"name"`
	Config map[string]interface{} `json:"config,omitempty" mapstructure:"config"`
}

TransformerConfig represents transformer configuration

Jump to

Keyboard shortcuts

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