gs_app

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	C *gs_core.Container // IoC container
	P *gs_conf.AppConfig // Application configuration

	Runners []gs.Runner `autowire:"${spring.app.runners:=?}"`
	Jobs    []gs.Job    `autowire:"${spring.app.jobs:=?}"`
	Servers []gs.Server `autowire:"${spring.app.servers:=?}"`

	EnableJobs    bool `value:"${spring.app.enable-jobs:=true}"`
	EnableServers bool `value:"${spring.app.enable-servers:=true}"`
	// contains filtered or unexported fields
}

App represents the core application, managing its lifecycle, configuration, and dependency injection.

func NewApp

func NewApp() *App

NewApp creates and initializes a new application instance.

func (*App) Exiting

func (app *App) Exiting() bool

Exiting returns whether the application is currently in the process of shutting down.

func (*App) ShutDown

func (app *App) ShutDown()

ShutDown initiates a graceful shutdown of the application by setting the exiting flag and cancelling the root context.

func (*App) Start

func (app *App) Start() error

Start initializes and launches the application. It performs the following steps: 1. Registers the App itself as a root bean. 2. Loads application configuration. 3. Refreshes the IoC container to initialize and wire beans. 4. Runs all registered Runners. 5. Launches Jobs (if enabled) as background goroutines. 6. Starts all Servers (if enabled) and waits for readiness.

func (*App) WaitForShutdown added in v1.2.5

func (app *App) WaitForShutdown()

WaitForShutdown waits for the application to be signaled to shut down and then gracefully stops all servers and jobs.

type Boot

type Boot interface {
	// Config returns the boot configuration.
	Config() *gs_conf.BootConfig
	// Object registers an existing object as a bean in the container.
	Object(i any) *gs.RegisteredBean
	// Provide registers a bean using a constructor function and optional arguments.
	Provide(ctor any, args ...gs.Arg) *gs.RegisteredBean
	// Runner creates and registers a Runner from a given function.
	Runner(fn func() error) *gs.RegisteredBean
}

Boot defines the interface for application bootstrapping.

func NewBoot

func NewBoot() Boot

NewBoot creates and returns a new BootImpl instance.

type BootImpl

type BootImpl struct {
	Runners []gs.Runner `autowire:"${spring.boot.runners:=?}"`
	// contains filtered or unexported fields
}

BootImpl is the concrete implementation of the Boot interface. It manages the application's bootstrapping process.

func (*BootImpl) Config

func (b *BootImpl) Config() *gs_conf.BootConfig

Config returns the boot configuration.

func (*BootImpl) Object

func (b *BootImpl) Object(i any) *gs.RegisteredBean

Object registers an existing object as a bean in the container.

func (*BootImpl) Provide

func (b *BootImpl) Provide(ctor any, args ...gs.Arg) *gs.RegisteredBean

Provide registers a bean using a constructor function and optional arguments.

func (*BootImpl) Root added in v1.2.5

func (b *BootImpl) Root(x *gs.RegisteredBean)

Root registers a root bean definition in the container.

func (*BootImpl) Run

func (b *BootImpl) Run() error

Run executes the application's boot process.

func (*BootImpl) Runner added in v1.2.5

func (b *BootImpl) Runner(fn func() error) *gs.RegisteredBean

Runner creates a Runner from a function and registers it as a bean.

type ReadySignal

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

ReadySignal is a synchronization helper used to indicate when an application is ready to serve requests.

func NewReadySignal

func NewReadySignal() *ReadySignal

NewReadySignal creates and returns a new ReadySignal instance.

func (*ReadySignal) Add

func (s *ReadySignal) Add()

Add increments the WaitGroup counter.

func (*ReadySignal) Close

func (s *ReadySignal) Close()

Close closes the signal channel, notifying all goroutines waiting on it.

func (*ReadySignal) Intercept

func (s *ReadySignal) Intercept()

Intercept marks the signal as intercepted.

func (*ReadySignal) Intercepted

func (s *ReadySignal) Intercepted() bool

Intercepted returns true if the signal has been intercepted.

func (*ReadySignal) TriggerAndWait

func (s *ReadySignal) TriggerAndWait() <-chan struct{}

TriggerAndWait marks an operation as done by decrementing the WaitGroup counter, and then returns the readiness signal channel for waiting.

func (*ReadySignal) Wait

func (s *ReadySignal) Wait()

Wait blocks until all WaitGroup counters reach zero.

Jump to

Keyboard shortcuts

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