apprun

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 11 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

Overview

Package apprun is the single owner of the long-lived process boot sequence shared by `gadak serve` and gadak-desktop.

This is a move, not a redesign: each step is the same work the two mains already did. Caller-specific surfaces stay with the caller (serve: addr bind, GuardBrowser, /healthz; desktop: wails window, deeplink, Origin-strip mux). Intentional order differences are options, not a merged sequence:

  • GDK-658: desktop runs wails SingleInstance (application.New) before AcquireBuiltIn / StartOriginPassthrough.

Process-start workspace selection (GDK-644) is SelectWorkspace, called from each main before flags. Persist flush on the CLI process is still cmd/gadak main (every verb, os.Exit(1) on failure); desktop sets FlushOnClose so Runtime.Close does that flush.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectWorkspace

func SelectWorkspace()

SelectWorkspace is the process-start workspace pick (GDK-644). Both mains call this before flags (CLI) or early-exit probes (desktop). Importing internal/config no longer selects a workspace.

func StartOriginPassthrough

func StartOriginPassthrough(cfg *config.Config) (func(), error)

StartOriginPassthrough embeds the built-in origin for this process. It does not open a loopback listener and does not write serve-origin.json (GDK-936: local writes embed the persist WAL directly; pairing remotes use the main serve's RESTPrefix). Connected workspaces are a no-op.

The desktop caller invokes this after application.New so wails SingleInstance can os.Exit the second process before persist is opened (GDK-658).

Types

type Options

type Options struct {
	// Version stamps server.Version. Empty leaves the current value.
	Version string

	// Log receives watch-loop status lines. Default is log.Print. Never
	// pass secrets.
	Log func(string)

	// OpenStore, if set, replaces store.Open(config.DBPath()). serve
	// passes cmd/gadak openStore so rejectUnknownProfile stays there.
	OpenStore func() (*store.DB, error)

	// DeferBuiltIn skips persist acquire during Open. Desktop sets this
	// so wails SingleInstance (application.New) can os.Exit a second
	// instance before persist is taken (GDK-658).
	DeferBuiltIn bool

	// FlushOnClose runs origin.Close from Runtime.Close. Desktop sets this
	// (GDK-342/348). serve leaves it false: cmd/gadak main flushes every
	// verb and os.Exit(1)s on failure.
	FlushOnClose bool
}

Options configures caller-specific boot differences. Zero value is the serve-shaped path: persist is taken during Open.

type Runtime

type Runtime struct {
	Cfg *config.Config
	DB  *store.DB
	API *server.Handler
	Reg *workspace.Registry
	// contains filtered or unexported fields
}

Runtime is the opened app surface both mains hold. Callers own when to Close (LIFO with their own resources: signal ctx, HTTP listener, wails).

func Open

func Open(opts Options) (*Runtime, error)

Open loads config, opens the mirror, builds the API handler (attachment cache + server.New), and creates the workspace registry. Version stamp is first when Options.Version is set. Persist acquire for built-in runs here unless DeferBuiltIn is set.

func (*Runtime) Close

func (rt *Runtime) Close() error

Close flushes built-in persist when FlushOnClose is set or persist was acquired here, then closes the registry, API handler, and store — API before DB (GDK-270). Safe on a partial Open.

func (*Runtime) StartOriginPassthrough

func (rt *Runtime) StartOriginPassthrough() (func(), error)

StartOriginPassthrough embeds persist (if not already held). Desktop calls this after application.New (GDK-658).

func (*Runtime) StartWatch

func (rt *Runtime) StartWatch(ctx context.Context, noSync bool)

StartWatch starts the incremental sync loops (primary profile + workspace mounts). Order and log strings match the previous inlined cmdServe / desktop ApplicationStarted body.

Watch re-entry is syncer.WatchLoop, not Watch (GDK-663): Watch returns on fatal auth and would leave the process alive with sync permanently stopped.

noSync skips the watch loops (serve --no-sync). Desktop always passes false.

Jump to

Keyboard shortcuts

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