Documentation
¶
Overview ¶
Package run exposes the complete GoModel gateway lifecycle as an importable entry point. External modules build custom gateway binaries by registering extensions (see the ext package) and calling Run:
func main() {
ext.RegisterRewriter(myRewriter{})
err := run.Run(context.Background(), run.Options{ProductName: "my-gateway"})
if code := run.ExitCode(err); code != 0 {
os.Exit(code)
}
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExitCode ¶
ExitCode maps a Run error to a process exit code: nil is 0, CLI usage errors are 2, everything else is 1.
func Run ¶
Run executes the full gateway lifecycle: CLI parsing, --version and --health/--ready probe modes, dotenv loading, logging setup, config loading, provider registration, application construction (including registered extensions), signal handling, and start with graceful shutdown. Cancelling ctx triggers the same graceful shutdown as SIGINT/SIGTERM.
Types ¶
type Options ¶
type Options struct {
// ProductName names the binary in CLI usage output, the startup log line,
// and --version output. Default: "gomodel".
ProductName string
// Extensions is the extension registry snapshotted at server
// construction. Default: ext.Default.
Extensions *ext.Registry
// Args are the CLI arguments (without the program name). Default: os.Args[1:].
Args []string
// Stdout and Stderr default to os.Stdout and os.Stderr.
Stdout io.Writer
Stderr io.Writer
// ConfigureSwaggerDocs receives the configured server base path so the
// caller's generated swagger docs package can be aligned with it. The
// gomodel binary passes its build-tagged implementation. Default: no-op.
ConfigureSwaggerDocs func(basePath string)
// Setup, when set, runs once the process is committed to starting the
// gateway — after CLI parsing, --version/--health/--ready
// short-circuits, dotenv loading, and logging configuration, but before
// config loading. Register extensions here so operator tooling modes
// stay silent. A returned error aborts startup.
Setup func(ctx context.Context) error
}
Options configures a gateway run. The zero value runs the standard gomodel gateway on os.Args.