Documentation ¶
Index ¶
- Constants
- func DetectAddress(addr ...string) string
- func HostEnding(log xlog.ILogger, context *HostBuilderContext)
- func HostRunning(log xlog.ILogger, context *HostBuilderContext)
- func PrintLogo(l xlog.ILogger, env *HostEnvironment)
- func RegisterConfigurationProcessor(configure func(config IConfiguration, ...))
- func RunningHostEnvironmentSetting(hostEnv *HostEnvironment)
- type ApplicationChannel
- type ApplicationEvent
- type ApplicationEventPublisher
- type ApplicationLife
- type Configuration
- func (c *Configuration) Get(name string) interface{}
- func (c *Configuration) GetBool(name string) bool
- func (c *Configuration) GetConfDir() string
- func (c *Configuration) GetConfigObject(configTag string, configObject interface{})
- func (c *Configuration) GetInt(name string) int
- func (c *Configuration) GetProfile() string
- func (c *Configuration) GetSection(name string) IConfiguration
- func (c *Configuration) GetString(name string) string
- func (c *Configuration) Initialize()
- func (c *Configuration) OnWatchRemoteConfigChanged()
- func (c *Configuration) RefreshAll()
- func (c *Configuration) RefreshBy(name string)
- func (c *Configuration) Unmarshal(obj interface{})
- type ConfigurationBuilder
- func (builder *ConfigurationBuilder) AddEnvironment() *ConfigurationBuilder
- func (builder *ConfigurationBuilder) AddFlagArgs() *ConfigurationBuilder
- func (builder *ConfigurationBuilder) AddJsonFile(name string) *ConfigurationBuilder
- func (builder *ConfigurationBuilder) AddPropertiesFile(name string) *ConfigurationBuilder
- func (builder *ConfigurationBuilder) AddYamlFile(name string) *ConfigurationBuilder
- func (builder *ConfigurationBuilder) Build() *Configuration
- func (builder *ConfigurationBuilder) BuildEnv(env string) *Configuration
- type ConfigurationContext
- type ConfigurationProperties
- type DataChannelSlice
- type HostBuilder
- func (host *HostBuilder) Build() IServiceHost
- func (host *HostBuilder) Configure(configure interface{}) *HostBuilder
- func (host *HostBuilder) ConfigureServices(configure func(*dependencyinjection.ServiceCollection)) *HostBuilder
- func (host *HostBuilder) OnApplicationLifeEvent(lifeConfigure func(*ApplicationLife)) *HostBuilder
- func (host *HostBuilder) SetEnvironment(mode string) *HostBuilder
- func (host *HostBuilder) UseConfiguration(configuration IConfiguration) *HostBuilder
- func (host *HostBuilder) UseServer(server IServer) *HostBuilder
- func (host *HostBuilder) UseStartup(startupFunc func() IStartup) *HostBuilder
- type HostBuilderContext
- type HostEnvironment
- type IApplicationBuilder
- type IConfiguration
- type IConfigurationProperties
- type IConfigurationRemoteProvider
- type IDataSource
- type IHostBuilderDecorator
- type IHostService
- type IServer
- type IServiceHost
- type IStartup
- type ServiceHost
Constants ¶
View Source
const ( APPLICATION_LIFE_START = "APPLICATION_LIFE_START" APPLICATION_LIFE_STOP = "APPLICATION_LIFE_STOP" )
View Source
const (
// DefaultAddress is used if no other is specified.
DefaultAddress = ":8080"
)
Variables ¶
This section is empty.
Functions ¶
func DetectAddress ¶
func HostEnding ¶
func HostEnding(log xlog.ILogger, context *HostBuilderContext)
func HostRunning ¶
func HostRunning(log xlog.ILogger, context *HostBuilderContext)
func PrintLogo ¶
func PrintLogo(l xlog.ILogger, env *HostEnvironment)
func RegisterConfigurationProcessor ¶
func RegisterConfigurationProcessor(configure func(config IConfiguration, serviceCollection *dependencyinjection.ServiceCollection))
func RunningHostEnvironmentSetting ¶
func RunningHostEnvironmentSetting(hostEnv *HostEnvironment)
RunningHostEnvironmentSetting ,get running hostenv setting.
Types ¶
type ApplicationChannel ¶
type ApplicationChannel chan ApplicationEvent
ApplicationChannel 是一个能接收 ApplicationEvent 的 channel
type ApplicationEvent ¶
type ApplicationEvent struct { Data interface{} Topic string }
type ApplicationEventPublisher ¶
type ApplicationEventPublisher struct {
// contains filtered or unexported fields
}
ApplicationEventPublisher 存储有关订阅者感兴趣的特定主题的信息
func NewEventPublisher ¶
func NewEventPublisher() *ApplicationEventPublisher
func (*ApplicationEventPublisher) NewEvent ¶
func (eb *ApplicationEventPublisher) NewEvent() chan ApplicationEvent
func (*ApplicationEventPublisher) Publish ¶
func (eb *ApplicationEventPublisher) Publish(topic string, data interface{})
func (*ApplicationEventPublisher) Subscribe ¶
func (eb *ApplicationEventPublisher) Subscribe(topic string, ch ApplicationChannel)
type ApplicationLife ¶
type ApplicationLife struct { ApplicationStopped chan ApplicationEvent ApplicationStarted chan ApplicationEvent State string // contains filtered or unexported fields }
func NewApplicationLife ¶
func NewApplicationLife() *ApplicationLife
func (*ApplicationLife) StartApplication ¶
func (life *ApplicationLife) StartApplication()
func (*ApplicationLife) StopApplication ¶
func (life *ApplicationLife) StopApplication()
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
func NewConfiguration ¶
func NewConfiguration(configContext *ConfigurationContext) *Configuration
func (*Configuration) Get ¶
func (c *Configuration) Get(name string) interface{}
func (*Configuration) GetBool ¶
func (c *Configuration) GetBool(name string) bool
func (*Configuration) GetConfDir ¶
func (c *Configuration) GetConfDir() string
func (*Configuration) GetConfigObject ¶
func (c *Configuration) GetConfigObject(configTag string, configObject interface{})
func (*Configuration) GetInt ¶
func (c *Configuration) GetInt(name string) int
func (*Configuration) GetProfile ¶
func (c *Configuration) GetProfile() string
func (*Configuration) GetSection ¶
func (c *Configuration) GetSection(name string) IConfiguration
func (*Configuration) GetString ¶
func (c *Configuration) GetString(name string) string
func (*Configuration) Initialize ¶
func (c *Configuration) Initialize()
func (*Configuration) OnWatchRemoteConfigChanged ¶
func (c *Configuration) OnWatchRemoteConfigChanged()
func (*Configuration) RefreshAll ¶
func (c *Configuration) RefreshAll()
func (*Configuration) RefreshBy ¶
func (c *Configuration) RefreshBy(name string)
func (*Configuration) Unmarshal ¶
func (c *Configuration) Unmarshal(obj interface{})
type ConfigurationBuilder ¶
type ConfigurationBuilder struct {
Context *ConfigurationContext
}
func NewConfigurationBuilder ¶
func NewConfigurationBuilder() *ConfigurationBuilder
func (*ConfigurationBuilder) AddEnvironment ¶
func (builder *ConfigurationBuilder) AddEnvironment() *ConfigurationBuilder
func (*ConfigurationBuilder) AddFlagArgs ¶
func (builder *ConfigurationBuilder) AddFlagArgs() *ConfigurationBuilder
func (*ConfigurationBuilder) AddJsonFile ¶
func (builder *ConfigurationBuilder) AddJsonFile(name string) *ConfigurationBuilder
func (*ConfigurationBuilder) AddPropertiesFile ¶
func (builder *ConfigurationBuilder) AddPropertiesFile(name string) *ConfigurationBuilder
func (*ConfigurationBuilder) AddYamlFile ¶
func (builder *ConfigurationBuilder) AddYamlFile(name string) *ConfigurationBuilder
func (*ConfigurationBuilder) Build ¶
func (builder *ConfigurationBuilder) Build() *Configuration
func (*ConfigurationBuilder) BuildEnv ¶
func (builder *ConfigurationBuilder) BuildEnv(env string) *Configuration
type ConfigurationContext ¶
type ConfigurationContext struct { ConfigType string EnableRemote bool RemoteProvider IConfigurationRemoteProvider // contains filtered or unexported fields }
type ConfigurationProperties ¶
type ConfigurationProperties struct { }
type DataChannelSlice ¶
type DataChannelSlice []ApplicationChannel
DataChannelSlice 是一个包含 DataChannels 数据的切片
type HostBuilder ¶
type HostBuilder struct { Server IServer // Server Context *HostBuilderContext // context of Host builder Decorator IHostBuilderDecorator // host builder decorator or extension // contains filtered or unexported fields }
host builder
func (*HostBuilder) Configure ¶
func (host *HostBuilder) Configure(configure interface{}) *HostBuilder
Configure function func(IApplicationBuilder)
func (*HostBuilder) ConfigureServices ¶
func (host *HostBuilder) ConfigureServices(configure func(*dependencyinjection.ServiceCollection)) *HostBuilder
ConfigureServices configure function by ServiceCollection of DI.
func (*HostBuilder) OnApplicationLifeEvent ¶
func (host *HostBuilder) OnApplicationLifeEvent(lifeConfigure func(*ApplicationLife)) *HostBuilder
OnApplicationLifeEvent on application life event
func (*HostBuilder) SetEnvironment ¶
func (host *HostBuilder) SetEnvironment(mode string) *HostBuilder
SetEnvironment set value(Dev,tests,Prod) by environment
func (*HostBuilder) UseConfiguration ¶
func (host *HostBuilder) UseConfiguration(configuration IConfiguration) *HostBuilder
func (*HostBuilder) UseServer ¶
func (host *HostBuilder) UseServer(server IServer) *HostBuilder
UseServer set IServer to host builder
func (*HostBuilder) UseStartup ¶
func (host *HostBuilder) UseStartup(startupFunc func() IStartup) *HostBuilder
type HostBuilderContext ¶
type HostBuilderContext struct { RequestDelegate interface{} ApplicationCycle *ApplicationLife HostingEnvironment *HostEnvironment Configuration IConfiguration HostConfiguration *hostenv.HostConfig ApplicationServicesDef *dependencyinjection.ServiceCollection ApplicationServices dependencyinjection.IServiceProvider HostServices dependencyinjection.IServiceProvider }
type HostEnvironment ¶
type HostEnvironment struct { ApplicationName string Version string Profile string Args []string Addr string Port string Host string PID int Server string MetaData map[string]string }
func (HostEnvironment) IsDevelopment ¶
func (env HostEnvironment) IsDevelopment() bool
func (HostEnvironment) IsProduction ¶
func (env HostEnvironment) IsProduction() bool
func (HostEnvironment) IsStaging ¶
func (env HostEnvironment) IsStaging() bool
type IApplicationBuilder ¶
type IApplicationBuilder interface { Build() interface{} SetHostBuildContext(*HostBuilderContext) }
type IConfiguration ¶
type IConfiguration interface { Get(name string) interface{} GetString(name string) string GetBool(name string) bool GetInt(name string) int GetSection(name string) IConfiguration Unmarshal(interface{}) GetProfile() string GetConfDir() string GetConfigObject(configTag string, configObject interface{}) RefreshAll() RefreshBy(name string) }
type IConfigurationProperties ¶
type IConfigurationProperties interface {
GetSection() string
}
type IDataSource ¶
type IHostBuilderDecorator ¶
type IHostBuilderDecorator interface { // OverrideConfigure is configure function by application builder. OverrideConfigure(configureFunc interface{}, builder IApplicationBuilder) // OverrideNewApplicationBuilder create application builder. OverrideNewApplicationBuilder(context *HostBuilderContext) IApplicationBuilder // OverrideNewHost Create IServiceHost. OverrideNewHost(server IServer, context *HostBuilderContext) IServiceHost // OverrideInnerConfigures inner configures for IOC OverrideIOCInnerConfigures(serviceCollection *dependencyinjection.ServiceCollection) }
IHostBuilderDecorator Host Builder decorator or extension
type IHostService ¶
type IServer ¶
type IServer interface { GetAddr() string Run(context *HostBuilderContext) (e error) Shutdown() }
type IServiceHost ¶
type IServiceHost interface { Run() Shutdown() StopApplicationNotify() SetAppMode(mode string) }
type IStartup ¶
type IStartup interface {
ConfigureServices(collection *dependencyinjection.ServiceCollection)
}
type ServiceHost ¶
type ServiceHost struct { HostContext *HostBuilderContext Server IServer // contains filtered or unexported fields }
host base
func NewServiceHost ¶
func NewServiceHost(server IServer, hostContext *HostBuilderContext) ServiceHost
func (ServiceHost) Run ¶
func (host ServiceHost) Run()
func (ServiceHost) SetAppMode ¶
func (host ServiceHost) SetAppMode(mode string)
func (ServiceHost) Shutdown ¶
func (host ServiceHost) Shutdown()
func (ServiceHost) StopApplicationNotify ¶
func (host ServiceHost) StopApplicationNotify()
Source Files ¶
- applicationbuilder.go
- applicationeventpublisher.go
- applicationlife.go
- configuration.go
- configurationbuilder.go
- configurationpropertieser.go
- datasource.go
- default_viper_configuration.go
- di.go
- hostbuilder.go
- hostbuilder_context.go
- hostbuilder_decorator.go
- hostenvironment.go
- hostservice.go
- server.go
- servicehost.go
- startuper.go
Click to show internal directories.
Click to hide internal directories.