abstractions

package
v1.9.7 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

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 DetectAddress(addr ...string) string

func HostEnding

func HostEnding(log xlog.ILogger, context *HostBuilderContext)

func HostRunning

func HostRunning(log xlog.ILogger, context *HostBuilderContext)
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) Build

func (host *HostBuilder) Build() IServiceHost

Build host

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 IConfigurationRemoteProvider

type IConfigurationRemoteProvider interface {
	GetProvider(*viper.Viper) *viper.Viper
	WatchRemoteConfigOnChannel(remoteViper *viper.Viper) <-chan bool
}

type IDataSource

type IDataSource interface {
	GetName() string
	Open() (conn interface{}, put func(), err error)
	Close()
	Ping() bool
}

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 IHostService interface {
	Run() error
	Stop() error
}

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()

Directories

Path Synopsis
platform

Jump to

Keyboard shortcuts

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