config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr                  string        `mapstructure:"REDGE_ADDR" validate:"required"`
	HTTPEnabled           bool          `mapstructure:"REDGE_HTTP_ENABLED"`
	HTTPAddr              string        `mapstructure:"REDGE_HTTP_ADDR" validate:"required"`
	AdminEnabled          bool          `mapstructure:"REDGE_ADMIN_ENABLED"`
	AdminAddr             string        `mapstructure:"REDGE_ADMIN_ADDR" validate:"required"`
	Environment           string        `mapstructure:"REDGE_ENV" validate:"required,oneof=development test production"`
	LogLevel              string        `mapstructure:"REDGE_LOG_LEVEL" validate:"required,oneof=debug info warn error"`
	LogFormat             string        `mapstructure:"REDGE_LOG_FORMAT" validate:"required,oneof=json console"`
	ShutdownTimeout       time.Duration `mapstructure:"REDGE_SHUTDOWN_TIMEOUT"`
	Password              string        `mapstructure:"REDGE_PASSWORD"`
	APIToken              string        `mapstructure:"REDGE_API_TOKEN"`
	RequireAuth           bool          `mapstructure:"REDGE_REQUIRE_AUTH"`
	ProtectedMode         bool          `mapstructure:"REDGE_PROTECTED_MODE"`
	AllowedIPs            string        `mapstructure:"REDGE_ALLOWED_IPS"`
	MaxConnections        int           `mapstructure:"REDGE_MAX_CONNECTIONS" validate:"min=0"`
	AuthFailureDelay      time.Duration `mapstructure:"REDGE_AUTH_FAILURE_DELAY"`
	TLSEnabled            bool          `mapstructure:"REDGE_TLS_ENABLED"`
	TLSCertPEM            string        `mapstructure:"REDGE_TLS_CERT_PEM"`
	TLSKeyPEM             string        `mapstructure:"REDGE_TLS_KEY_PEM"`
	TLSCertB64            string        `mapstructure:"REDGE_TLS_CERT_B64"`
	TLSKeyB64             string        `mapstructure:"REDGE_TLS_KEY_B64"`
	TLSCertFile           string        `mapstructure:"REDGE_TLS_CERT_FILE"`
	TLSKeyFile            string        `mapstructure:"REDGE_TLS_KEY_FILE"`
	TLSMinVersion         string        `mapstructure:"REDGE_TLS_MIN_VERSION" validate:"oneof=1.2 1.3"`
	MaxRequestBytes       int64         `mapstructure:"REDGE_MAX_REQUEST_BYTES" validate:"min=1024"`
	ReadTimeout           time.Duration `mapstructure:"REDGE_READ_TIMEOUT"`
	WriteTimeout          time.Duration `mapstructure:"REDGE_WRITE_TIMEOUT"`
	DatabaseURL           string        `mapstructure:"DATABASE_URL" validate:"required"`
	TursoAuthToken        string        `mapstructure:"TURSO_AUTH_TOKEN"`
	D1APIToken            string        `mapstructure:"D1_API_TOKEN"`
	D1BaseURL             string        `mapstructure:"D1_BASE_URL"`
	D1RetryMax            int           `mapstructure:"D1_RETRY_MAX" validate:"min=0"`
	D1RetryMinBackoff     time.Duration `mapstructure:"D1_RETRY_MIN_BACKOFF"`
	D1RetryMaxBackoff     time.Duration `mapstructure:"D1_RETRY_MAX_BACKOFF"`
	DatabaseMaxOpenConns  int           `mapstructure:"DATABASE_MAX_OPEN_CONNS" validate:"min=1"`
	DatabaseMaxIdleConns  int           `mapstructure:"DATABASE_MAX_IDLE_CONNS" validate:"min=1"`
	DatabaseConnMaxLife   time.Duration `mapstructure:"DATABASE_CONN_MAX_LIFETIME"`
	MigrationsAuto        bool          `mapstructure:"REDGE_MIGRATIONS_AUTO"`
	CacheEnabled          bool          `mapstructure:"REDGE_CACHE_ENABLED"`
	CacheMaxKeys          int           `mapstructure:"REDGE_CACHE_MAX_KEYS" validate:"min=1"`
	CacheMaxBytes         int64         `mapstructure:"REDGE_CACHE_MAX_BYTES" validate:"min=1"`
	CacheDefaultTTL       time.Duration `mapstructure:"REDGE_CACHE_DEFAULT_TTL"`
	ExpiryCleanupEnabled  bool          `mapstructure:"REDGE_EXPIRY_CLEANUP_ENABLED"`
	ExpiryCleanupInterval time.Duration `mapstructure:"REDGE_EXPIRY_CLEANUP_INTERVAL"`
	ExpiryCleanupLimit    int           `mapstructure:"REDGE_EXPIRY_CLEANUP_LIMIT" validate:"min=1"`
	AdminToken            string        `mapstructure:"REDGE_ADMIN_TOKEN"`
	AdminAllowedIPs       string        `mapstructure:"REDGE_ADMIN_ALLOWED_IPS"`
	AdminIPCheckEnabled   bool          `mapstructure:"REDGE_ADMIN_IP_CHECK_ENABLED"`
	AdminReadOnly         bool          `mapstructure:"REDGE_ADMIN_READONLY"`
	APIMaxBodyBytes       int64         `mapstructure:"REDGE_API_MAX_BODY_BYTES" validate:"min=1024"`
	APIAllowedIPs         string        `mapstructure:"REDGE_API_ALLOWED_IPS"`
	APIIPCheckEnabled     bool          `mapstructure:"REDGE_API_IP_CHECK_ENABLED"`
	APICORSEnabled        bool          `mapstructure:"REDGE_API_CORS_ENABLED"`
	APICORSOrigins        string        `mapstructure:"REDGE_API_CORS_ORIGINS"`
	APIRateLimit          bool          `mapstructure:"REDGE_API_RATE_LIMIT_ENABLED"`
	APIRateLimitRPS       int           `mapstructure:"REDGE_API_RATE_LIMIT_RPS" validate:"min=1"`
	APIRateLimitBurst     int           `mapstructure:"REDGE_API_RATE_LIMIT_BURST" validate:"min=1"`
	DocAPIEnabled         bool          `mapstructure:"REDGE_DOCAPI_ENABLED"`
	WSEnabled             bool          `mapstructure:"REDGE_WS_ENABLED"`
	WSMaxBytes            int64         `mapstructure:"REDGE_WS_MAX_MESSAGE_BYTES" validate:"min=1024"`
	WSIdleTimeout         time.Duration `mapstructure:"REDGE_WS_IDLE_TIMEOUT"`
	WSMaxSubs             int           `mapstructure:"REDGE_WS_MAX_SUBSCRIPTIONS" validate:"min=1"`
	StoreAPIEnabled       bool          `mapstructure:"REDGE_STOREAPI_ENABLED"`
}

func Load

func Load() (*Config, error)

func (*Config) D1Parts

func (c *Config) D1Parts() (accountID, databaseID string, err error)

func (*Config) DatabaseType

func (c *Config) DatabaseType() string

func (*Config) GetAPIAllowedIPs

func (c *Config) GetAPIAllowedIPs() []string

func (*Config) GetAPICORSOrigins

func (c *Config) GetAPICORSOrigins() []string

func (*Config) GetAPIToken

func (c *Config) GetAPIToken() string

func (*Config) GetAdminAllowedIPs

func (c *Config) GetAdminAllowedIPs() []string

func (*Config) GetAllowedIPs

func (c *Config) GetAllowedIPs() []string

func (*Config) GetD1APIToken

func (c *Config) GetD1APIToken() string

func (*Config) GetD1BaseURL

func (c *Config) GetD1BaseURL() string

func (*Config) GetResolvedDatabaseURL

func (c *Config) GetResolvedDatabaseURL() string

func (*Config) GetTLSMaterialSource

func (c *Config) GetTLSMaterialSource() (string, error)

func (*Config) GetTursoAuthToken

func (c *Config) GetTursoAuthToken() string

func (*Config) IsDevelopment

func (c *Config) IsDevelopment() bool

func (*Config) IsProduction

func (c *Config) IsProduction() bool

Jump to

Keyboard shortcuts

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