commands

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 45

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoExit added in v0.1.7

func DoExit()

DoExit triggers graceful exit when the process was started with Run(inst). It has no effect if Run() was not used or has already returned. In new code, prefer holding the *Runner and calling r.Shutdown() so no global state is used.

func Run

func Run(inst MainInstance)

Run is a compatibility entry point: it creates a Runner for inst, sets it as the default runner (so DoExit() works), then runs until shutdown. Prefer using NewRunner(inst) and r.Run() in new code so no package-level state is used.

Types

type MainInstance

type MainInstance interface {
	Initialize() error
	RunLoop()
	Destroy()
}

MainInstance is the interface that application main instances must implement.

type Runner added in v0.1.23

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

Runner holds the main instance and signal channel for one application run. Use NewRunner and Run() to avoid package-level globals; Shutdown() triggers graceful exit.

func NewRunner added in v0.1.23

func NewRunner(inst MainInstance) *Runner

NewRunner returns a Runner for the given main instance. The caller can call r.Run() (blocks until shutdown) and r.Shutdown() from anywhere that holds the runner (e.g. inject r.Shutdown into the instance).

func (*Runner) Instance added in v0.1.23

func (r *Runner) Instance() MainInstance

Instance returns the main instance held by this runner. Prefer keeping a reference to your instance in application code instead of using this.

func (*Runner) Run added in v0.1.23

func (r *Runner) Run()

Run runs the main loop: flag parse, version, init, RunLoop in goroutine, then signal loop. It blocks until a quit signal is received or Shutdown() is called.

func (*Runner) Shutdown added in v0.1.23

func (r *Runner) Shutdown()

Shutdown triggers graceful exit (sends SIGQUIT to the runner's signal loop). Safe to call from any goroutine (e.g. from RunLoop or an HTTP handler).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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