app

package
v0.0.0-...-5a0e1f5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 63 Imported by: 0

Documentation

Overview

Package app wires the control-plane monolith.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run() int

Run starts the control-plane monolith.

Types

type AuthConfig

type AuthConfig struct {
	Disabled     bool          `envconfig:"AUTH_DISABLED" default:"true"`
	ProxySecret  string        `envconfig:"AUTH_PROXY_SECRET"`
	AdminSubject string        `envconfig:"DCM_ADMIN_SUBJECT"`
	CacheTTL     time.Duration `envconfig:"AUTH_CACHE_TTL" default:"60s"`
	IssuerURL    string        `envconfig:"AUTH_ISSUER_URL"`
	Audience     string        `envconfig:"AUTH_JWT_AUDIENCE"`
}

type Checker

type Checker interface {
	Name() string
	Check(ctx context.Context) error
}

Checker verifies a dependency used by the monolith health endpoint.

func NewNATSChecker

func NewNATSChecker(c natsPinger) Checker

NewNATSChecker returns a Checker that verifies NATS connectivity.

func NewPostgresChecker

func NewPostgresChecker(db *gorm.DB) Checker

NewPostgresChecker returns a Checker that pings the database via GORM's SQL pool.

type Config

type Config struct {
	Service  ServiceConfig
	Database DatabaseConfig
	Auth     AuthConfig
	Seed     SeedConfig
	NATS     NATSConfig
	SP       SPConfig
	Wiring   WiringConfig
}

Config holds monolith runtime configuration.

func LoadConfig

func LoadConfig() (*Config, error)

type DatabaseConfig

type DatabaseConfig struct {
	Type     string `envconfig:"DB_TYPE" default:"pgsql"`
	Hostname string `envconfig:"DB_HOST" default:"localhost"`
	Port     string `envconfig:"DB_PORT" default:"5432"`
	Name     string `envconfig:"DB_NAME" default:"control-plane"`
	User     string `envconfig:"DB_USER"`
	Password string `envconfig:"DB_PASSWORD"`
}

type NATSConfig

type NATSConfig struct {
	URL          string `envconfig:"NATS_URL" default:"nats://localhost:4222"`
	Subject      string `envconfig:"NATS_STATUS_SUBJECT" default:"dcm.*"`
	StreamName   string `envconfig:"NATS_STREAM_NAME" default:"dcm-status"`
	ConsumerName string `envconfig:"NATS_CONSUMER_NAME" default:"control-plane"`
	Disabled     bool   `envconfig:"NATS_DISABLED" default:"false"`
}

type SPConfig

type SPConfig struct {
	HealthCheckInterval               time.Duration `envconfig:"HEALTH_CHECK_INTERVAL" default:"10s"`
	HealthCheckTimeout                time.Duration `envconfig:"HEALTH_CHECK_TIMEOUT" default:"5s"`
	HealthCheckMaxConsecutiveFailures int           `envconfig:"HEALTH_CHECK_MAX_CONSECUTIVE_FAILURES" default:"3"`
	HealthCheckBaseBackoffInterval    time.Duration `envconfig:"HEALTH_CHECK_BASE_BACKOFF_INTERVAL" default:"10s"`
	HealthCheckMaxBackoffInterval     time.Duration `envconfig:"HEALTH_CHECK_MAX_BACKOFF_INTERVAL" default:"5m"`
	CleanupInterval                   time.Duration `envconfig:"CLEANUP_INTERVAL" default:"1m"`
	CleanupMaxRetries                 int           `envconfig:"CLEANUP_MAX_RETRIES" default:"10"`
	CleanupTimeout                    time.Duration `envconfig:"CLEANUP_TIMEOUT" default:"10s"`
}

type SeedConfig

type SeedConfig struct {
	RegionDefault string   `envconfig:"SEED_REGION_DEFAULT" default:""`
	RegionEnum    []string `envconfig:"SEED_REGION_ENUM" default:"region-a,region-b"`
}

type ServiceConfig

type ServiceConfig struct {
	BindAddress       string        `envconfig:"BIND_ADDRESS" default:"127.0.0.1:8080"`
	LogLevel          string        `envconfig:"LOG_LEVEL" default:"info"`
	ReadHeaderTimeout time.Duration `envconfig:"READ_HEADER_TIMEOUT" default:"10s"`
	ReadTimeout       time.Duration `envconfig:"READ_TIMEOUT" default:"15s"`
	WriteTimeout      time.Duration `envconfig:"WRITE_TIMEOUT" default:"15s"`
	IdleTimeout       time.Duration `envconfig:"IDLE_TIMEOUT" default:"60s"`
	MaxHeaderBytes    int           `envconfig:"MAX_HEADER_BYTES" default:"1048576"`
}

type WiringConfig

type WiringConfig struct {
	PlacementManagerURL     string        `envconfig:"PLACEMENT_MANAGER_URL"`
	PlacementManagerTimeout time.Duration `envconfig:"PLACEMENT_MANAGER_TIMEOUT" default:"10s"`
}

WiringConfig holds optional HTTP client URLs for subsystem tests. When empty, cross-domain calls use in-process implementations.

Jump to

Keyboard shortcuts

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