Documentation ¶
Index ¶
- Constants
- func WithCondition(init interface{}, onCondition interface{}) container.Conditional
- type Binder
- type CompleteService
- type DaemonProvider
- type FlagContext
- type Glacier
- type Graceful
- type Hook
- type Initializer
- type ListenerBuilder
- type Logger
- type Nameable
- type Priority
- type Provider
- type ProviderAggregate
- type ProviderBoot
- type Reloadable
- type Resolver
- type Service
- type Stoppable
Constants ¶
View Source
const ( VersionKey string = "version" StartupTimeKey string = "startup_time" )
Variables ¶
This section is empty.
Functions ¶
func WithCondition ¶
func WithCondition(init interface{}, onCondition interface{}) container.Conditional
Types ¶
type CompleteService ¶
type CompleteService interface { Service Initializer Stoppable Reloadable Nameable }
CompleteService is an interface for a service which implements all service interface
type DaemonProvider ¶
type FlagContext ¶
type Glacier ¶
type Glacier interface { SetLogger(logger Logger) Glacier // WithFlagContext 设置 FlagContext,支持覆盖 FlagContext 默认实现 // 参数 fn 只支持 `func(...) infra.FlagContext` 形式 WithFlagContext(fn interface{}) Glacier // Provider 注册一个模块 Provider(providers ...Provider) // Service 注册一个 Service Service(services ...Service) // Async 注册一个异步任务 Async(asyncJobs ...interface{}) // Graceful 设置优雅停机实现 Graceful(builder func() Graceful) Glacier // OnServerReady call a function a server ready OnServerReady(f interface{}) // Main 应用入口 Main(cliCtx FlagContext) error // BeforeInitialize Glacier 初始化之前执行,一般用于设置一些基本配置,比如日志等 BeforeInitialize(f func(fc FlagContext) error) Glacier // AfterInitialized Glacier 初始化之后执行,所有的实例绑定都可以使用了 AfterInitialized(f func(resolver Resolver) error) Glacier // BeforeServerStart 此时所有对象已经注册完毕,但是服务启动前执行 BeforeServerStart(f func(cc container.Container) error) Glacier // AfterServerStart 此时所有服务都已经启动(Main 除外) AfterServerStart(f func(resolver Resolver) error) Glacier // BeforeServerStop 服务停止前的回调 BeforeServerStop(f func(resolver Resolver) error) Glacier // AfterProviderBooted 所有的 providers 都已经完成 boot 之后执行 AfterProviderBooted(f interface{}) Glacier PreBind(fn func(binder Binder)) Glacier Singleton(ins ...interface{}) Glacier Prototype(ins ...interface{}) Glacier ResolveWithError(resolver interface{}) error MustResolve(resolver interface{}) Container() container.Container }
type Graceful ¶
type Graceful interface { AddReloadHandler(h func()) AddShutdownHandler(h func()) Reload() Shutdown() Start() error }
type Hook ¶
type Hook interface {
// OnServerReady call a function a server ready
OnServerReady(f interface{})
}
type Initializer ¶
Initializer is an interface for service initializer
type ListenerBuilder ¶
type Logger ¶
type Logger interface { Debug(v ...interface{}) Debugf(format string, v ...interface{}) Info(v ...interface{}) Infof(format string, v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Warning(v ...interface{}) Warningf(format string, v ...interface{}) // Critical 关键性错误,遇到该日志输出时,应用直接退出 Critical(v ...interface{}) // Criticalf 关键性错误,遇到该日志输出时,应用直接退出 Criticalf(format string, v ...interface{}) }
type Nameable ¶
type Nameable interface {
Name() string
}
Nameable is an interface for service/provider name
type Priority ¶
type Priority interface {
Priority() int
}
Priority 优先级接口 实现该接口后,在加载 Provider/Service 时,会按照 Priority 大小依次加载(值越小越先加载)
type Provider ¶
type Provider interface { // Register add some dependency for current module // this method is called one by one synchronous // service provider don't autowired in this stage Register(binder Binder) }
type ProviderAggregate ¶
type ProviderAggregate interface {
Aggregates() []Provider
}
ProviderAggregate Provider 聚合,所有实现该接口的 Provider 在加载之前将会先加载该集合中的 Provider
type ProviderBoot ¶
type ProviderBoot interface { // Boot starts the module // this method is called one by one synchronous after all register methods called // service provider has been autowired in this stage Boot(resolver Resolver) }
type Reloadable ¶
type Reloadable interface {
Reload()
}
Reloadable is an interface for reloadable service
Click to show internal directories.
Click to hide internal directories.