Documentation
¶
Index ¶
- Constants
- Variables
- func AllowCircularReferences(enable bool)
- func As[T any]() reflect.Type
- func Banner(banner string)
- func BindArg(fn any, args ...Arg) *gs_arg.BindArg
- func Component[T any](i T) T
- func Config() *gs_conf.AppConfig
- func EnableJobs(enable bool)
- func EnableServers(enable bool)
- func EnableSimpleHttpServer(enable bool)
- func EnableSimplePProfServer(enable bool)
- func Exiting() bool
- func ForceAutowireIsNullable(enable bool)
- func GroupRegister(fn func(p conf.Properties) ([]*BeanDefinition, error))
- func NewBean(objOrCtor any, ctorArgs ...gs.Arg) *gs.BeanDefinition
- func OnProperty(name string) gs_cond.OnPropertyInterface
- func Property(key string, val string)
- func RefreshProperties() error
- func RegisterExpressFunc(name string, fn any)
- func Run()
- func RunAsync() (func(), error)
- func RunWith(fn func(ctx context.Context) error)
- func SetActiveProfiles(profiles string)
- func ShutDown()
- type AppStarter
- type Arg
- type BeanDefinition
- type BeanDestroyFunc
- type BeanID
- type BeanInitFunc
- type BeanMock
- type BeanSelector
- type CondContext
- type Condition
- func And(conditions ...Condition) Condition
- func None(conditions ...Condition) Condition
- func Not(c Condition) Condition
- func OnBean[T any](name ...string) Condition
- func OnExpression(expression string) Condition
- func OnFunc(fn func(ctx CondContext) (bool, error)) Condition
- func OnMissingBean[T any](name ...string) Condition
- func OnMissingProperty(name string) Condition
- func OnSingleBean[T any](name ...string) Condition
- func Or(conditions ...Condition) Condition
- type Dync
- type HttpServerConfig
- type HttpServerOption
- func SetHttpServerAddr(addr string) HttpServerOption
- func SetHttpServerHeaderTimeout(timeout time.Duration) HttpServerOption
- func SetHttpServerIdleTimeout(timeout time.Duration) HttpServerOption
- func SetHttpServerReadTimeout(timeout time.Duration) HttpServerOption
- func SetHttpServerWriteTimeout(timeout time.Duration) HttpServerOption
- type Job
- type ReadySignal
- type RegisteredBean
- type Runner
- type Server
- type SimpleHttpServer
- type SimplePProfServer
Constants ¶
const ( Version = "go-spring@v1.2.0" Website = "https://go-spring.com/" )
const ( AllowCircularReferencesProp = "spring.allow-circular-references" ForceAutowireIsNullableProp = "spring.force-autowire-is-nullable" ActiveProfilesProp = "spring.profiles.active" EnableJobsProp = "spring.app.enable-jobs" EnableServersProp = "spring.app.enable-servers" EnableSimpleHttpServerProp = "spring.enable.simple-http-server" EnableSimplePProfServerProp = "spring.enable.simple-pprof-server" )
Variables ¶
var B = gs_app.NewBoot()
Functions ¶
func AllowCircularReferences ¶ added in v1.2.0
func AllowCircularReferences(enable bool)
AllowCircularReferences enables or disables circular references between beans.
func As ¶ added in v1.2.0
As returns the reflect.Type of the given interface type.
func BindArg ¶ added in v1.2.0
BindArg returns a BindArg for the specified function and arguments. Used to provide argument binding for option-style constructor parameters.
func Component ¶ added in v1.2.0
func Component[T any](i T) T
Component registers a bean definition for a given object.
func EnableJobs ¶ added in v1.2.0
func EnableJobs(enable bool)
EnableJobs enables or disables the app jobs.
func EnableServers ¶ added in v1.2.0
func EnableServers(enable bool)
EnableServers enables or disables the app servers.
func EnableSimpleHttpServer ¶ added in v1.2.0
func EnableSimpleHttpServer(enable bool)
EnableSimpleHttpServer enables or disables the simple HTTP server.
func EnableSimplePProfServer ¶ added in v1.2.0
func EnableSimplePProfServer(enable bool)
EnableSimplePProfServer enables or disables the simple pprof server.
func Exiting ¶ added in v1.2.0
func Exiting() bool
Exiting returns a boolean indicating whether the application is exiting.
func ForceAutowireIsNullable ¶ added in v1.2.0
func ForceAutowireIsNullable(enable bool)
ForceAutowireIsNullable forces autowire to be nullable.
func GroupRegister ¶ added in v1.2.0
func GroupRegister(fn func(p conf.Properties) ([]*BeanDefinition, error))
GroupRegister registers a group of bean definitions.
func NewBean ¶
func NewBean(objOrCtor any, ctorArgs ...gs.Arg) *gs.BeanDefinition
NewBean creates a new BeanDefinition.
func OnProperty ¶
func OnProperty(name string) gs_cond.OnPropertyInterface
OnProperty creates a Condition based on a property name and options.
func RefreshProperties ¶ added in v1.2.0
func RefreshProperties() error
RefreshProperties refreshes the app configuration.
func RegisterExpressFunc ¶ added in v1.2.0
RegisterExpressFunc registers a custom expression function.
func RunAsync ¶
func RunAsync() (func(), error)
RunAsync runs the app asynchronously and returns a function to stop the app.
func RunWith ¶
RunWith runs the app with a given function and waits for an interrupt signal to exit.
func SetActiveProfiles ¶ added in v1.2.0
func SetActiveProfiles(profiles string)
SetActiveProfiles sets the active profiles for the app.
Types ¶
type AppStarter ¶ added in v1.2.0
type AppStarter struct{}
func (*AppStarter) Run ¶ added in v1.2.0
func (s *AppStarter) Run()
Run runs the app and waits for an interrupt signal to exit.
func (*AppStarter) RunAsync ¶
func (s *AppStarter) RunAsync() (func(), error)
RunAsync runs the app asynchronously and returns a function to stop the app.
type Arg ¶ added in v1.2.0
func IndexArg ¶ added in v1.2.0
IndexArg returns an IndexArg with the specified index and argument. When most constructor parameters can use default values, IndexArg helps reduce configuration effort.
type BeanDefinition ¶
type BeanDefinition = gs.BeanDefinition
type BeanDestroyFunc ¶ added in v1.2.0
type BeanDestroyFunc = gs.BeanDestroyFunc
type BeanInitFunc ¶ added in v1.2.0
type BeanInitFunc = gs.BeanInitFunc
type BeanSelector ¶ added in v1.2.0
type BeanSelector = gs.BeanSelector
func BeanSelectorFor ¶ added in v1.2.0
func BeanSelectorFor[T any](name ...string) BeanSelector
BeanSelectorFor returns a BeanSelector for the given type.
type CondContext ¶ added in v1.2.0
type CondContext = gs.CondContext
type Condition ¶ added in v1.2.0
func And ¶ added in v1.2.0
And creates a Condition that is true if all the given Conditions are true.
func None ¶ added in v1.2.0
None creates a Condition that is true if none of the given Conditions are true.
func OnExpression ¶ added in v1.2.0
OnExpression creates a Condition based on a custom expression.
func OnFunc ¶ added in v1.2.0
func OnFunc(fn func(ctx CondContext) (bool, error)) Condition
OnFunc creates a Condition based on the provided function.
func OnMissingBean ¶ added in v1.2.0
OnMissingBean creates a Condition for when a specific bean is missing.
func OnMissingProperty ¶ added in v1.2.0
OnMissingProperty creates a Condition that checks for a missing property.
func OnSingleBean ¶ added in v1.2.0
OnSingleBean creates a Condition for when only one instance of a bean exists.
type HttpServerConfig ¶ added in v1.2.0
type HttpServerConfig struct { Address string // The address to bind the server to. ReadTimeout time.Duration // The read timeout duration. HeaderTimeout time.Duration // The header timeout duration. WriteTimeout time.Duration // The write timeout duration. IdleTimeout time.Duration // The idle timeout duration. }
HttpServerConfig holds configuration options for the HTTP server.
type HttpServerOption ¶ added in v1.2.0
type HttpServerOption func(arg *HttpServerConfig)
HttpServerOption is a function type for setting options on HttpServerConfig.
func SetHttpServerAddr ¶ added in v1.2.0
func SetHttpServerAddr(addr string) HttpServerOption
SetHttpServerAddr sets the address of the HTTP server.
func SetHttpServerHeaderTimeout ¶
func SetHttpServerHeaderTimeout(timeout time.Duration) HttpServerOption
SetHttpServerHeaderTimeout sets the header timeout for the HTTP server.
func SetHttpServerIdleTimeout ¶
func SetHttpServerIdleTimeout(timeout time.Duration) HttpServerOption
SetHttpServerIdleTimeout sets the idle timeout for the HTTP server.
func SetHttpServerReadTimeout ¶ added in v1.2.0
func SetHttpServerReadTimeout(timeout time.Duration) HttpServerOption
SetHttpServerReadTimeout sets the read timeout for the HTTP server.
func SetHttpServerWriteTimeout ¶ added in v1.2.0
func SetHttpServerWriteTimeout(timeout time.Duration) HttpServerOption
SetHttpServerWriteTimeout sets the write timeout for the HTTP server.
type ReadySignal ¶ added in v1.2.0
type ReadySignal = gs.ReadySignal
type RegisteredBean ¶ added in v1.2.0
type RegisteredBean = gs.RegisteredBean
func FuncJob ¶ added in v1.2.0
func FuncJob(fn func(ctx context.Context) error) *RegisteredBean
FuncJob creates a Job from a function.
func FuncRunner ¶ added in v1.2.0
func FuncRunner(fn func() error) *RegisteredBean
FuncRunner creates a Runner from a function.
func Object ¶
func Object(i any) *RegisteredBean
Object registers a bean definition for a given object.
func Provide ¶
func Provide(ctor any, args ...Arg) *RegisteredBean
Provide registers a bean definition for a given constructor.
func Register ¶ added in v1.2.0
func Register(b *BeanDefinition) *RegisteredBean
Register registers a bean definition.
type SimpleHttpServer ¶ added in v1.2.0
type SimpleHttpServer struct {
// contains filtered or unexported fields
}
SimpleHttpServer wraps a http.Server instance.
func NewSimpleHttpServer ¶ added in v1.2.0
func NewSimpleHttpServer(mux *http.ServeMux, opts ...HttpServerOption) *SimpleHttpServer
NewSimpleHttpServer creates a new instance of SimpleHttpServer.
func (*SimpleHttpServer) ListenAndServe ¶ added in v1.2.0
func (s *SimpleHttpServer) ListenAndServe(sig ReadySignal) error
ListenAndServe starts the HTTP server and listens for incoming connections.
type SimplePProfServer ¶ added in v1.2.0
type SimplePProfServer struct {
*SimpleHttpServer
}
SimplePProfServer is a simple pprof server.
func NewSimplePProfServer ¶ added in v1.2.0
func NewSimplePProfServer(addr string) *SimplePProfServer
NewSimplePProfServer creates a new SimplePProfServer.
Directories
¶
Path | Synopsis |
---|---|
Package gstest provides unit testing utilities for dependency injection in Go-Spring framework.
|
Package gstest provides unit testing utilities for dependency injection in Go-Spring framework. |
internal
|
|
gs_arg
Package gs_arg provides implementation for function argument resolution and binding
|
Package gs_arg provides implementation for function argument resolution and binding |
gs_bean
Package gs_bean provides core bean management for Go-Spring framework, featuring:
|
Package gs_bean provides core bean management for Go-Spring framework, featuring: |
gs_cond
Package gs_cond provides conditional component registration for Go-Spring framework, offering runtime decision-making through various condition types.
|
Package gs_cond provides conditional component registration for Go-Spring framework, offering runtime decision-making through various condition types. |
gs_conf
Package gs_conf provides hierarchical configuration management with multi-source support for Go-Spring framework.
|
Package gs_conf provides hierarchical configuration management with multi-source support for Go-Spring framework. |
gs_core
Package gs_core provides the core implementation of the Inversion of Control (IoC) container in the Go-Spring framework.
|
Package gs_core provides the core implementation of the Inversion of Control (IoC) container in the Go-Spring framework. |
gs_dync
Package gs_dync provides dynamic configuration binding and refresh capabilities for Go applications.
|
Package gs_dync provides dynamic configuration binding and refresh capabilities for Go applications. |