frontend

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package frontend implements the frontend server of the load balancer

Index

Constants

This section is empty.

Variables

View Source
var (
	// MinTime is the default timestamp used for the begin of optional time ranges.
	// Exposed to let downstream projects to reference it.
	MinTime = time.Unix(math.MinInt64/1000+62135596801, 0).UTC()

	// MaxTime is the default timestamp used for the end of optional time ranges.
	// Exposed to let downstream projects to reference it.
	MaxTime = time.Unix(math.MaxInt64/1000-62135596801, 999999999).UTC()
)

These functions are nicked from https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go

View Source
var (
	ErrUnknownClusterID = errors.New("unknown cluster ID")
)

Custom errors.

Functions

func AllowRetry

func AllowRetry(r *http.Request) bool

AllowRetry checks if a failed request can be retried.

func ErrorHandler added in v0.5.1

func ErrorHandler(u *url.URL, backendServer backend.Server, lb LoadBalancer, logger *slog.Logger) func(http.ResponseWriter, *http.Request, error)

ErrorHandler returns a custom error handler for reverse proxy.

func Monitor

func Monitor(ctx context.Context, manager serverpool.Manager, logger *slog.Logger)

Monitor checks the backend servers health.

Types

type Config

type Config struct {
	Logger           *slog.Logger
	LBType           base.LBType
	Address          string
	WebSystemdSocket bool
	WebConfigFile    string
	APIServer        ceems_api_cli.CEEMSAPIServerConfig
	Manager          serverpool.Manager
}

Config makes a server config from CLI args.

type LoadBalancer

type LoadBalancer interface {
	Serve(w http.ResponseWriter, r *http.Request)
	Start() error
	Shutdown(ctx context.Context) error
	ValidateClusterIDs(ctx context.Context) error
}

LoadBalancer is the interface to implement.

func New added in v0.2.0

func New(c *Config) (LoadBalancer, error)

New returns a new instance of load balancer.

type ReqParams added in v0.5.1

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

ReqParams is the context value.

type ReqParamsContextKey added in v0.5.1

type ReqParamsContextKey struct{}

ReqParamsContextKey is the key used to set context value for request parameters.

type RetryContextKey

type RetryContextKey struct{}

RetryContextKey is the key used to set context value for retry.

Jump to

Keyboard shortcuts

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