gs_app

package
v1.3.0-alpha 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: 14 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 {
	Runners []Runner `autowire:"${spring.app.runners:=?}"`
	Servers []Server `autowire:"${spring.app.servers:=?}"`
	// contains filtered or unexported fields
}

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

func NewApp

func NewApp() *App

NewApp creates a new App instance with an initialized root context.

func (*App) Context added in v1.3.0

func (app *App) Context() context.Context

Context returns the root context for the application.

func (*App) Exiting

func (app *App) Exiting() bool

Exiting indicates whether the application is currently shutting down.

func (*App) Property added in v1.3.0

func (app *App) Property(key string, val string)

Property sets an app-level property in the application's configuration. It associates the property with the caller file for traceability.

func (*App) Provide added in v1.3.0

func (app *App) Provide(objOrCtor any, args ...gs.Arg) *gs_bean.BeanDefinition

Provide registers a new bean definition in the IoC container. The parameter can be either an existing instance or a constructor function. Additional arguments can be passed for dependency injection.

func (*App) RefreshProperties added in v1.3.0

func (app *App) RefreshProperties() error

RefreshProperties reloads application properties from all sources and propagates the changes to the IoC container.

func (*App) ShutDown

func (app *App) ShutDown()

ShutDown initiates a graceful shutdown of the application. It sets the exiting flag and cancels the root context.

func (*App) Start

func (app *App) Start() error

Start initializes and launches the application. The startup sequence is:

  1. Initialize logging
  2. Register ContextAware and App beans
  3. Load configuration and refresh the container
  4. Execute all Runner beans
  5. Launch all servers in separate goroutines
  6. Wait for readiness signal from all servers

func (*App) WaitForShutdown added in v1.2.4

func (app *App) WaitForShutdown()

WaitForShutdown blocks until the application is signaled to shut down. It then gracefully stops all servers.

type ConfigRefresher

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

ConfigRefresher is an interface for components that need to refresh application properties after configuration changes.

func (*ConfigRefresher) RefreshProperties

func (c *ConfigRefresher) RefreshProperties() error

RefreshProperties refreshes application properties and propagates the changes to the IoC container.

type ContextAware

type ContextAware struct {
	Context context.Context
}

ContextAware provides access to the application's root context. Users can inject this bean to access the App's context.

type ReadySignal

type ReadySignal interface {
	TriggerAndWait() <-chan struct{}
}

ReadySignal defines an interface for signaling application readiness. Servers can use this to indicate when they are ready to accept requests.

type ReadySignalImpl added in v1.3.0

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

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

func NewReadySignal

func NewReadySignal() *ReadySignalImpl

NewReadySignal creates and returns a new ReadySignalImpl instance.

func (*ReadySignalImpl) Add added in v1.3.0

func (s *ReadySignalImpl) Add()

Add increments the WaitGroup counter.

func (*ReadySignalImpl) Close added in v1.3.0

func (s *ReadySignalImpl) Close()

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

func (*ReadySignalImpl) Intercept added in v1.3.0

func (s *ReadySignalImpl) Intercept()

Intercept marks the signal as intercepted.

func (*ReadySignalImpl) Intercepted added in v1.3.0

func (s *ReadySignalImpl) Intercepted() bool

Intercepted returns true if the signal has been intercepted.

func (*ReadySignalImpl) TriggerAndWait added in v1.3.0

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

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

func (*ReadySignalImpl) Wait added in v1.3.0

func (s *ReadySignalImpl) Wait()

Wait blocks until all WaitGroup counters reach zero.

type Runner added in v1.3.0

type Runner interface {
	Run(ctx context.Context) error
}

Runner defines an interface for components that need to be executed after all beans have been injected but before servers start.

type Server added in v1.3.0

type Server interface {
	Run(ctx context.Context, sig ReadySignal) error
	Stop() error
}

Server defines the lifecycle of application servers (e.g., HTTP, gRPC). It provides methods to start and gracefully stop the server.

type ServerMockImpl added in v1.3.0

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

ServerMockImpl is a generated mock implementation of the Server interface.

func NewServerMockImpl added in v1.3.0

func NewServerMockImpl(r *gsmock.Manager) *ServerMockImpl

NewServerMockImpl creates a new mock instance for Server with the given gsmock.Manager. Returns an initialized struct ready for registering mock behavior.

func (*ServerMockImpl) MockRun added in v1.3.0

MockRun returns a Mocker21 for registering mock behavior of Run with specific parameter and return types.

func (*ServerMockImpl) MockStop added in v1.3.0

func (impl *ServerMockImpl) MockStop() *gsmock.Mocker01[error]

MockStop returns a Mocker01 for registering mock behavior of Stop with specific parameter and return types.

func (*ServerMockImpl) Run added in v1.3.0

func (impl *ServerMockImpl) Run(ctx context.Context, sig ReadySignal) error

Run calls the registered mock for Run via gsmock.Invoke. If no matching mock is registered, it panics.

func (*ServerMockImpl) Stop added in v1.3.0

func (impl *ServerMockImpl) Stop() error

Stop calls the registered mock for Stop via gsmock.Invoke. If no matching mock is registered, it panics.

Jump to

Keyboard shortcuts

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