gs_app

package
v1.2.2-rc Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GS = NewApp()

GS is the global application instance.

Functions

This section is empty.

Types

type App

type App struct {
	C *gs_core.Container
	P *gs_conf.AppConfig

	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}"`

	ShutDownTimeout time.Duration `value:"${spring.app.shutdown-timeout:=15s}"`
	// 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 a boolean indicating whether the application is exiting.

func (*App) Run

func (app *App) Run() error

Run starts the application and listens for termination signals (e.g., SIGINT, SIGTERM). Upon receiving a signal, it initiates a graceful shutdown.

func (*App) RunWith

func (app *App) RunWith(fn func(ctx context.Context) error) error

RunWith starts the application and listens for termination signals (e.g., SIGINT, SIGTERM). Upon receiving a signal, it initiates a graceful shutdown.

func (*App) ShutDown

func (app *App) ShutDown()

ShutDown gracefully terminates the application. This method should be called to trigger a proper shutdown process.

func (*App) Start

func (app *App) Start() error

Start initializes and starts the application. It performs configuration loading, IoC container refreshing, dependency injection, and runs runners, jobs and servers.

func (*App) Stop

func (app *App) Stop()

Stop gracefully shuts down the application, ensuring all servers and resources are properly closed.

type Boot

type Boot interface {
	// Config returns the boot configuration.
	Config() *gs_conf.BootConfig
	// Object registers an object bean.
	Object(i any) *gs.RegisteredBean
	// Provide registers a bean using a constructor function.
	Provide(ctor any, args ...gs.Arg) *gs.RegisteredBean
	// Register registers a BeanDefinition instance.
	Register(bd *gs.BeanDefinition) *gs.RegisteredBean
	// FuncRunner creates a Runner from a function.
	FuncRunner(fn func() error) *gs.RegisteredBean
}

Boot defines the interface for application bootstrapping.

func NewBoot

func NewBoot() Boot

NewBoot creates a new Boot instance.

type BootImpl

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

BootImpl is the bootstrapper of the application.

func (*BootImpl) Config

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

Config returns the boot configuration.

func (*BootImpl) FuncRunner

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

FuncRunner creates a Runner from a function.

func (*BootImpl) Object

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

Object registers an object bean.

func (*BootImpl) Provide

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

Provide registers a bean using a constructor function.

func (*BootImpl) Register

func (b *BootImpl) Register(bd *gs.BeanDefinition) *gs.RegisteredBean

Register registers a BeanDefinition instance.

func (*BootImpl) Run

func (b *BootImpl) Run() error

Run executes the application's boot process.

type ReadySignal

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

ReadySignal is used to notify that the application is ready to serve requests.

func NewReadySignal

func NewReadySignal() *ReadySignal

NewReadySignal creates 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