Documentation
¶
Index ¶
- Constants
- func DecodeBody(ctx context.Context, fallback map[string]any) (map[string]any, error)
- func NormalizeConfigDir(value string) string
- func ResolveConfigDir(args []string) string
- func ResolveDBURL(args []string) string
- func ResolveDataDir(args []string) string
- func ResolveProfilesDir(args []string) string
- func WriteSchemas(dir string) error
- type App
- func (a *App) RegisterEntities(ctx context.Context) error
- func (a *App) RunTop(ctx context.Context, name string, options sessions.TopOptions) error
- func (a *App) RunTrace(ctx context.Context, name string, options sessions.TraceOptions) error
- func (a *App) Serve(parent context.Context, root *cobra.Command, configDir string, ...) error
- type DatabaseOptions
- type Options
- type Runtime
- func (r *Runtime) Close() error
- func (r *Runtime) ConnectionString() string
- func (r *Runtime) Context() dbcontext.Context
- func (r *Runtime) Database() (*gorm.DB, error)
- func (r *Runtime) EnsureDatabase(ctx context.Context) error
- func (r *Runtime) ProfileStore() (profiles.Store, error)
- func (r *Runtime) SetContext(ctx dbcontext.Context) error
- func (r *Runtime) SetDatabase(db *gorm.DB) error
- func (r *Runtime) SetDatabaseOptions(options DatabaseOptions)
- func (r *Runtime) SetProfileStore(store profiles.Store) error
- type ServeOptions
Constants ¶
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.
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 NormalizeConfigDir ¶
func ResolveConfigDir ¶
func ResolveDBURL ¶ added in v0.1.29
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 ResolveProfilesDir ¶
func WriteSchemas ¶
WriteSchemas renders each schema to <dir>/<file>, creating the directory.
Types ¶
type App ¶
type App struct {
Runtime *Runtime
Connections *connections.Service
Profiles *profiles.Service
Sessions *sessions.Runner
// contains filtered or unexported fields
}
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 (*Runtime) Close ¶ added in v0.1.29
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 (*Runtime) EnsureDatabase ¶ added in v0.1.29
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 ¶
ProfileStore is the database-backed store whenever --db names one, and the YAML file store otherwise.
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.
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