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.