Documentation
¶
Overview ¶
Package dev implements `gombit dev`: one command that runs the Go API (with reload when air or watchexec is available), the Vite frontend with HMR, and live OpenAPI → TypeScript client regeneration.
Index ¶
- Constants
- func APIPrefixFromConfig(cfg config.Config) string
- func AdminURLFromConfig(cfg config.Config, httpAddr string) string
- func FormatServiceTable(services Services) string
- func HTTPAddrFromConfig(cfg config.Config) string
- func Run(ctx context.Context, opts Options) error
- func RunProcess(ctx context.Context, spec ProcSpec, stdout, stderr io.Writer, ...) error
- func ValidateFlags(httpAddr string, frontendHost string, frontendPort int, poll time.Duration, ...) error
- type CommandFunc
- type GenerateFunc
- type HTTPGetFunc
- type LookPathFunc
- type Options
- type ProcSpec
- type Services
Constants ¶
const ( // DefaultHTTPAddr is the Go API listen address when config and flags omit it. DefaultHTTPAddr = ":8080" // DefaultFrontendHost is the Vite bind host. DefaultFrontendHost = "127.0.0.1" // DefaultFrontendPort is Vite's conventional port. DefaultFrontendPort = 5173 // DefaultPollInterval is how often the OpenAPI watcher fetches /openapi.json. DefaultPollInterval = time.Second // DefaultClientOut is the generated TypeScript client directory (design §23.3). DefaultClientOut = client.DefaultOutDir )
Variables ¶
This section is empty.
Functions ¶
func APIPrefixFromConfig ¶ added in v0.1.3
APIPrefixFromConfig returns config.API.Prefix, or D8 `/api/v1`.
func AdminURLFromConfig ¶ added in v0.1.3
AdminURLFromConfig returns the admin SPA URL for cookie-mode apps with auth enabled. JWT apps and auth-disabled configs return "".
func FormatServiceTable ¶
FormatServiceTable renders the Backend / Frontend / OpenAPI / API docs table. Cookie-mode apps also get an Admin row when Admin is set.
func HTTPAddrFromConfig ¶
HTTPAddrFromConfig returns the listen address from cfg, or DefaultHTTPAddr.
func Run ¶
Run starts the backend, Vite frontend, and OpenAPI client watcher until ctx is cancelled.
func RunProcess ¶ added in v0.5.0
func RunProcess(ctx context.Context, spec ProcSpec, stdout, stderr io.Writer, killAfter time.Duration) error
RunProcess runs spec in its own process group until it exits or ctx is canceled. On cancel it sends the group SIGTERM (a graceful stop) and kills it if it has not exited after killAfter. `gombit worker` uses it with the worker's shutdown budget, so in-flight jobs can finish.
A stop it asked for returns ctx.Err() only when the process then exited cleanly; a process that failed its shutdown (a non-zero status) or had to be killed returns that failure.
Types ¶
type CommandFunc ¶
CommandFunc starts a subprocess. Tests replace this with short-lived fakes.
type GenerateFunc ¶
GenerateFunc regenerates the TypeScript client from an OpenAPI document.
type HTTPGetFunc ¶
HTTPGetFunc fetches a URL. Tests replace this to stub /openapi.json.
type LookPathFunc ¶
LookPathFunc locates an executable. Tests replace this to simulate air/pnpm.
type Options ¶
type Options struct {
WorkDir string
HTTPAddr string
APIPrefix string
FrontendHost string
FrontendPort int
ClientOut string
PollInterval time.Duration
Stdout io.Writer
Stderr io.Writer
LookPath LookPathFunc
Command CommandFunc
HTTPGet HTTPGetFunc
Generate GenerateFunc
ShutdownWait time.Duration
// AdminURL is printed in the service table when non-empty (cookie-mode
// apps that mount the framework admin SPA). JWT apps leave this empty.
AdminURL string
// contains filtered or unexported fields
}
Options configures `gombit dev`.