app

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMemoryLimit

func ApplyMemoryLimit() (int64, string)

ApplyMemoryLimit sets the Go runtime's soft memory limit, so the garbage collector works harder before a container's limit kills the process (GitHub #331). GOMEMLIMIT, when set, wins: the runtime has applied it already. Otherwise memLimitShare of the cgroup limit is used. It returns the limit in bytes (0 = none) and where it came from.

Types

type App

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

App orchestrates all servers and modules.

func New

func New(cfg Config, db *sql.DB, registry *module.Registry, hub *ws.Hub, store event.Store, attachments *storage.AttachmentStore, m *metrics.Collector) *App

func (*App) Run

func (a *App) Run()

Run starts all servers and blocks until shutdown signal.

type AuthConfig

type AuthConfig struct {
	Enabled      bool   `yaml:"enabled"`       // Enable authentication (default: false).
	Provider     string `yaml:"provider"`      // Provider type: "auth0", "google", "github", "keycloak", "gitlab", "oidc" (default: "oidc").
	ProviderURL  string `yaml:"provider_url"`  // OIDC issuer URL (e.g., https://xxx.us.auth0.com). Used for OIDC discovery.
	ClientID     string `yaml:"client_id"`     // OAuth2 client ID.
	ClientSecret string `yaml:"client_secret"` // OAuth2 client secret.
	CallbackURL  string `yaml:"callback_url"`  // OAuth2 callback URL (e.g., http://localhost:8000/auth/sso/callback).
	Scopes       string `yaml:"scopes"`        // Comma-separated scopes (default: "openid,email,profile").
	JWTSecret    string `yaml:"jwt_secret"`    // Secret for signing internal JWT tokens. Required when auth is enabled.
}

AuthConfig controls authentication via OAuth2/OIDC providers.

type Config

type Config struct {
	Server   ServerConfig   `yaml:"server"`
	Database DatabaseConfig `yaml:"database"`
	Storage  StorageConfig  `yaml:"storage"`
	TCP      TCPConfig      `yaml:"tcp"`
	Metrics  MetricsConfig  `yaml:"metrics"`
	MCP      MCPConfig      `yaml:"mcp"`
	Xdebug   XdebugConfig   `yaml:"xdebug"`
	Auth     AuthConfig     `yaml:"auth"`
	UI       UIConfig       `yaml:"ui"`
	Modules  ModulesConfig  `yaml:"modules"`
	Webhooks []WebhookDef   `yaml:"webhooks"`
	Projects []ProjectDef   `yaml:"projects"`
	Mocks    []MockDef      `yaml:"mocks"`
	// MocksOpenAPI are OpenAPI specs turned into read-only mock rules at start.
	MocksOpenAPI []MockOpenAPIDef `yaml:"mocks_openapi"`
	// UpdateCheck asks GitHub for the latest release so the UI can say a new
	// version is out.
	UpdateCheck UpdateCheckConfig `yaml:"update_check"`
	// XdebugTrace bounds uploaded Xdebug function traces (module xdebug-trace).
	XdebugTrace XdebugTraceConfig `yaml:"xdebug_trace"`
	Version     string            `yaml:"-"`

	// Shortcuts.
	HTTPAddr      string `yaml:"-"`
	DatabaseDSN   string `yaml:"-"`
	SMTPAddr      string `yaml:"-"`
	MonologAddr   string `yaml:"-"`
	VarDumperAddr string `yaml:"-"`
	ProxyAddr     string `yaml:"-"`
}

Config holds application configuration.

func LoadConfig

func LoadConfig() Config

func (Config) String

func (c Config) String() string

type DatabaseConfig

type DatabaseConfig struct {
	Driver string `yaml:"driver"`
	DSN    string `yaml:"dsn"`

	// MaxOpenConns is the size of the SQLite connection pool (default 4).
	//
	// With a single connection ingestion and UI queries share one queue: a heavy
	// list slows down writes, and writes slow down the list. In WAL mode readers
	// disturb neither each other nor the writer, so a pool is safe; the writer is
	// still serialized by SQLite itself, and busy_timeout in the DSN makes a
	// competing write wait instead of failing.
	MaxOpenConns int `yaml:"max_open_conns"`
}

type MCPConfig

type MCPConfig struct {
	Enabled    bool   `yaml:"enabled"`     // Enable MCP server (default: false).
	Transport  string `yaml:"transport"`   // "socket" (Unix socket, default) or "http" (HTTP SSE for remote access).
	SocketPath string `yaml:"socket_path"` // Unix socket path (for transport=socket). Default: /tmp/buggregator-mcp.sock
	Addr       string `yaml:"addr"`        // HTTP listen address (for transport=http). Default: :8001
	AuthToken  string `yaml:"auth_token"`  // Bearer token for HTTP transport auth. Empty = no auth.
	// MockWrite exposes the MCP tools that create, change and delete mock
	// rules (default: true; false leaves the read and preview tools).
	MockWrite *bool `yaml:"mock_write"`
}

MCPConfig controls the MCP (Model Context Protocol) server.

func (MCPConfig) MockWriteOn

func (c MCPConfig) MockWriteOn() bool

MockWriteOn reports whether the MCP mock write tools are on (default true).

type MetricsConfig

type MetricsConfig struct {
	Enabled bool   `yaml:"enabled"`
	Addr    string `yaml:"addr"` // Separate metrics server address (e.g., ":9090"). Empty = use main HTTP server.
}

MetricsConfig controls Prometheus metrics.

type MockDef

type MockDef struct {
	Name    string            `yaml:"name"`
	Method  string            `yaml:"method"` // GET, POST, … or ANY (default)
	Path    string            `yaml:"path"`   // /users/me, /users/{id}, /files/*
	Status  int               `yaml:"status"` // default 200
	Headers map[string]string `yaml:"headers"`
	Body    string            `yaml:"body"`
	Delay   string            `yaml:"delay"`   // e.g. "150ms", at most 30s
	Project string            `yaml:"project"` // empty = every project
	// Template makes body and header values Go templates (request values, fake data).
	Template bool  `yaml:"template"`
	Seed     int64 `yaml:"seed"` // not 0: the same fake data on every request
}

type MockOpenAPIDef

type MockOpenAPIDef struct {
	File     string  `yaml:"file"`      // path to the spec, YAML or JSON
	Project  string  `yaml:"project"`   // empty = every project
	Group    string  `yaml:"group"`     // default openapi:<info.title>, openapi:<project>:<info.title> with a project
	BasePath *string `yaml:"base_path"` // default the path of servers[0].url; "" = none
}

WebhookDef defines a webhook from config. MockDef is a read-only mock rule from the config file (see #332): requests to /mock<path> get this response. MockOpenAPIDef is one OpenAPI spec file of the mocks_openapi section.

type ModulesConfig

type ModulesConfig struct {
	Sentry    *bool `yaml:"sentry"`
	Ray       *bool `yaml:"ray"`
	VarDump   *bool `yaml:"var-dump"`
	Inspector *bool `yaml:"inspector"`
	Monolog   *bool `yaml:"monolog"`
	SMTP      *bool `yaml:"smtp"`
	SMS       *bool `yaml:"sms"`
	HttpDump  *bool `yaml:"http-dump"`
	Profiler  *bool `yaml:"profiler"`
	// XdebugTrace is the Xdebug function trace upload (type xdebug-trace).
	XdebugTrace *bool `yaml:"xdebug-trace"`
}

ModulesConfig controls which modules are enabled. By default all modules are enabled. Set to false to disable.

func (*ModulesConfig) Disable

func (m *ModulesConfig) Disable(moduleType string)

Disable turns a module off, e.g. when it cannot start, so EnabledTypes (the UI menu) no longer lists it.

func (ModulesConfig) EnabledTypes

func (m ModulesConfig) EnabledTypes() []string

EnabledTypes returns a list of enabled module type strings.

func (ModulesConfig) IsEnabled

func (m ModulesConfig) IsEnabled(moduleType string) bool

IsEnabled returns true if a module is enabled (default: true).

type ProjectDef

type ProjectDef struct {
	Key  string `yaml:"key"`
	Name string `yaml:"name"`
}

ProjectDef defines a project from config.

type ServerConfig

type ServerConfig struct {
	Addr        string   `yaml:"addr"`
	CORSOrigins []string `yaml:"cors_origins"` // Allowed CORS origins. Empty = all ("*"), so browser SDKs (Sentry JS) work from any page.
}

type StorageConfig

type StorageConfig struct {
	Mode string `yaml:"mode"` // "memory" (default) or "filesystem"
	Path string `yaml:"path"` // Directory for filesystem mode
}

type TCPConfig

type TCPConfig struct {
	SMTP      TCPServerConfig `yaml:"smtp"`
	Monolog   TCPServerConfig `yaml:"monolog"`
	VarDumper TCPServerConfig `yaml:"var-dumper"`
	Proxy     TCPServerConfig `yaml:"proxy"`
}

type TCPServerConfig

type TCPServerConfig struct {
	Addr string `yaml:"addr"`
}

type UIConfig

type UIConfig struct {
	DefaultLimit  *int   `yaml:"default_limit"`  // events returned without a limit param; unset or 0 = unlimited
	MaxLimit      *int   `yaml:"max_limit"`      // ceiling for an explicit limit (default 5000); 0 = no ceiling
	DefaultWindow string `yaml:"default_window"` // time window without from/to: "24h", "7d"; empty or "all" = no window
}

UIConfig bounds the event lists served to the UI.

/api/events and /api/events/preview used to return everything stored for a project. By default they still do: the current UI loads the list once and does not page, so a cap would hide older events. default_limit and default_window opt in to smaller responses.

The limits are pointers so an explicit 0 (no limit) differs from "not set".

type UpdateCheckConfig

type UpdateCheckConfig struct {
	Enabled  *bool  `yaml:"enabled"`  // default true; false = no network call at all
	Interval string `yaml:"interval"` // Go duration between checks, default 12h, at least 1h

	IntervalDur time.Duration `yaml:"-"`
}

UpdateCheckConfig controls the new-version check (GitHub releases/latest).

func (UpdateCheckConfig) On

func (c UpdateCheckConfig) On() bool

On reports whether the check runs (default true).

type WebhookDef

type WebhookDef struct {
	Event     string            `yaml:"event"`      // Event type to match ("sentry", "ray", "*" for all).
	URL       string            `yaml:"url"`        // Target URL.
	Headers   map[string]string `yaml:"headers"`    // Custom HTTP headers.
	VerifySSL *bool             `yaml:"verify_ssl"` // Verify SSL certificates (default: false).
	Retry     *bool             `yaml:"retry"`      // Retry on failure (default: true).
}

type XdebugConfig

type XdebugConfig struct {
	Enabled          bool   `yaml:"enabled"`             // Enable the proxy (default: false).
	Addr             string `yaml:"addr"`                // Where Xdebug connects. Default: 127.0.0.1:9003
	IDEAddr          string `yaml:"ide_addr"`            // Where the IDE listens. Default: 127.0.0.1:9004
	AllowEval        bool   `yaml:"allow_eval"`          // Expose the xdebug_eval MCP tool (default: false).
	AllowControl     *bool  `yaml:"allow_control"`       // Expose the MCP control tools: step, continue, stop, wait (default: true).
	Mode             string `yaml:"mode"`                // proxy, auto or standalone. Default: auto
	PauseOnFirstLine bool   `yaml:"pause_on_first_line"` // A session driven here stops at the first line (default: false).
	IdleTimeout      string `yaml:"idle_timeout"`        // Release a session paused here after this long without a command. Default: 10m; 0 = never

	IdleTimeoutDur time.Duration `yaml:"-"` // parsed IdleTimeout: 0 = default, <0 = never
}

XdebugConfig controls the Xdebug (DBGp) proxy: Xdebug → Buggregator → IDE, or Buggregator drives the session itself when there is no IDE.

func (XdebugConfig) AllowControlOn

func (c XdebugConfig) AllowControlOn() bool

AllowControlOn reports whether the MCP control tools are on (default true).

type XdebugTraceConfig

type XdebugTraceConfig struct {
	MaxUpload string `yaml:"max_upload"` // request body, gzip or not. Default: 100MB
	MaxSize   string `yaml:"max_size"`   // uncompressed bytes read; a longer trace is cut. Default: 256MB
	Keep      int    `yaml:"keep"`       // traces kept, the oldest go first. Default: 20

	MaxUploadBytes int64 `yaml:"-"`
	MaxSizeBytes   int64 `yaml:"-"`
}

XdebugTraceConfig bounds uploaded Xdebug traces. Sizes take a plain byte count or a KB/MB/GB suffix (1024-based).

Jump to

Keyboard shortcuts

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