Help us shape the future of Go! Take the 2026 Go Developer Survey

app

package
v0.1.52 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const EmbeddedDatabase = "embedded"

EmbeddedDatabase is the --db value that resolves to the embedded PostgreSQL cluster under the data dir — the same store `query serve` and the web UI use.

View Source
const SchemaContentType = profiles.SchemaContentType

SchemaContentType is the media type a client sends in Accept to request a resource's JSON Schema instead of its data, served on the same endpoint.

Variables

This section is empty.

Functions

func DecodeBody

func DecodeBody(ctx context.Context, fallback map[string]any) (map[string]any, error)

func NormalizeConfigDir

func NormalizeConfigDir(value string) string

func ResolveConfigDir

func ResolveConfigDir(args []string) string

func ResolveDBURL added in v0.1.29

func ResolveDBURL(args []string) string

ResolveDBURL reads --db before cobra parses, because the profile store the command tree is generated from has to exist first. An explicitly empty value is not the same as an absent one: it selects the YAML file store.

func ResolveDataDir added in v0.1.29

func ResolveDataDir(args []string) string

func ResolveProfilesDir

func ResolveProfilesDir(args []string) string

func WriteSchemas

func WriteSchemas(dir string) error

WriteSchemas renders each schema to <dir>/<file>, creating the directory.

Types

type App

type App struct {
	Runtime     *Runtime
	Connections *connections.Service
	Profiles    *profiles.Service
	Schedules   *schedules.Service
	Sessions    *sessions.Runner
	// contains filtered or unexported fields
}

func New

func New(options Options) (*App, error)

func (*App) RegisterEntities

func (a *App) RegisterEntities(ctx context.Context) error

func (*App) RunTop

func (a *App) RunTop(ctx context.Context, name string, options sessions.TopOptions) error

func (*App) RunTrace

func (a *App) RunTrace(ctx context.Context, name string, options sessions.TraceOptions) error

func (*App) Serve

func (a *App) Serve(parent context.Context, root *cobra.Command, configDir string, options ServeOptions) error

type DatabaseOptions added in v0.1.29

type DatabaseOptions struct {
	// URL is empty for no database, EmbeddedDatabase for the cluster under
	// DataDir, or a PostgreSQL DSN.
	URL string
	// DataDir backs EmbeddedDatabase and is ignored for a DSN.
	DataDir string
	// KeepEmbeddedRunning leaves a cluster this process started running once the
	// returned stop is called. Sub-commands set it so the next invocation reuses
	// the cluster instead of paying another cold start; `serve` owns its cluster
	// for the length of the process and does not.
	KeepEmbeddedRunning bool
}

DatabaseOptions is how every entry point — the CLI sub-commands and `serve` — names the same store. URL is the resolved --db value.

func ResolveDatabaseOptions added in v0.1.29

func ResolveDatabaseOptions(args []string) DatabaseOptions

ResolveDatabaseOptions resolves --db and --data-dir straight off the raw arguments, for the same reason ResolveConfigDir does.

func (DatabaseOptions) Enabled added in v0.1.29

func (o DatabaseOptions) Enabled() bool

type Options

type Options struct {
	Args   []string
	Stdout io.Writer
	Stderr io.Writer
	// Database selects the profile and connection store. A zero value keeps the
	// YAML file store, which is what metadata-only invocations pass so that
	// building the command tree never starts PostgreSQL.
	Database DatabaseOptions
}

type Runtime

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

func NewRuntime

func NewRuntime(ctx dbcontext.Context, fileStore profilestore.Store, dbOptions DatabaseOptions) (*Runtime, error)

func (*Runtime) Close added in v0.1.29

func (r *Runtime) Close() error

Close releases what EnsureDatabase opened. Reused and KeepRunning clusters are left running by design, so this is a no-op for them.

func (*Runtime) ConnectionString added in v0.1.29

func (r *Runtime) ConnectionString() string

func (*Runtime) Context

func (r *Runtime) Context() dbcontext.Context

func (*Runtime) Database

func (r *Runtime) Database() (*gorm.DB, error)

func (*Runtime) EnsureDatabase added in v0.1.29

func (r *Runtime) EnsureDatabase(ctx context.Context) error

EnsureDatabase opens the configured database once and rebinds the context and profile store onto it. Connecting is deferred to the first caller that needs it so `query --help` never starts PostgreSQL.

func (*Runtime) ProfileStore

func (r *Runtime) ProfileStore() (profilestore.Store, error)

ProfileStore is the database-backed store whenever --db names one, and the YAML file store otherwise.

func (*Runtime) SetContext

func (r *Runtime) SetContext(ctx dbcontext.Context) error

func (*Runtime) SetDatabase

func (r *Runtime) SetDatabase(db *gorm.DB) error

func (*Runtime) SetDatabaseOptions added in v0.1.29

func (r *Runtime) SetDatabaseOptions(options DatabaseOptions)

SetDatabaseOptions replaces the options resolved from the command line. It must be called before anything opens the database — `serve` uses it to own the embedded cluster it starts.

func (*Runtime) SetProfileStore

func (r *Runtime) SetProfileStore(store profilestore.Store) error

type ServeOptions

type ServeOptions struct {
	Host                    string
	Port                    int
	DatabaseURL             string
	DataDir                 string
	Dev                     bool
	HideErrorDetails        bool
	MaxSessions             int
	MaxSessionDuration      time.Duration
	SessionRetention        time.Duration
	ReconcileSnapshotMaxAge time.Duration
}

func DefaultServeOptions

func DefaultServeOptions() ServeOptions

Jump to

Keyboard shortcuts

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