infrastructure

package
v0.0.0-...-63fad0f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *zap.Logger

Functions

func InitLogger

func InitLogger()

Types

type Backend

type Backend struct {
	URL    string `mapstructure:"url"`
	Health string `mapstructure:"health"`
}

Backend holds the individual backend server configuration

type BackendRegistry

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

func NewBackendRegistry

func NewBackendRegistry() *BackendRegistry

Initialize the registry

func (*BackendRegistry) AddBackendToRegistry

func (r *BackendRegistry) AddBackendToRegistry(backend domain.Backend)

func (*BackendRegistry) GetBackendById

func (r *BackendRegistry) GetBackendById(backendId uint64) (domain.Backend, bool)

Get the backend with id

func (*BackendRegistry) Subscribe

func (r *BackendRegistry) Subscribe(backendId uint64) <-chan domain.BackendStatus

Method for load balancers to subscribe to specific backend health updates

func (*BackendRegistry) UpdateHealth

func (r *BackendRegistry) UpdateHealth(status domain.BackendStatus) error

Method to update the health status of a backend

type Config

type Config struct {
	Routes        []Route       `mapstructure:"routes"`
	RateLimiter   RateLimiter   `mapstructure:"rateLimiter"`
	LoadBalancer  LoadBalancer  `mapstructure:"loadbalancer"`
	HealthChecker HealthChecker `mapstructure:"healthchecker"`
}

func LoadConfig

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

type HealthChecker

type HealthChecker struct {
	HealthyServerFrequency   string `mapstructure:"healthyserver_freq"`
	UnhealthyServerFrequency string `mapstructure:"unhealthyserver_freq"`
}

Healthchecker holds the health checker info

type LoadBalancer

type LoadBalancer struct {
	Address  string `mapstructure:"address"`
	CertFile string `mapstructure:"cert_file"`
	KeyFile  string `mapstructure:"key_file"`
}

LoadBalancer holds the load balancer address

type RateLimiter

type RateLimiter struct {
	Type   string `mapstructure:"type"`   // e.g. "none", "sliding_window", "token_bucket"
	Limit  int    `mapstructure:"limit"`  // request limit for the time window/bucket
	Window string `mapstructure:"window"` // only for window-based rate limiters
}

RateLimiter defines the structure for rate limiter configuration

type Route

type Route struct {
	Path     string
	Backends []Backend `mapstructure:"backends"`
}

Route holds the backends for each route

Jump to

Keyboard shortcuts

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