SpringBoot

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Modules = make([]ModuleFunc, 0)

定义 SpringBoot 模块数组

Functions

func RegisterModule

func RegisterModule(fn ModuleFunc)

注册 SpringBoot 模块

func RunApplication

func RunApplication(configLocation string)

启动 SpringBoot 应用对的快捷方式

Types

type Application

type Application struct {
	AppContext     ApplicationContext // 应用上下文
	ConfigLocation string             // 配置文件目录
	ConfigParsers  []ConfigParser     // 配置文件解析器
}

定义 SpringBoot 应用

func NewApplication

func NewApplication(configLocation string) *Application

工厂函数

func (*Application) ShutDown

func (app *Application) ShutDown()

停止 SpringBoot 应用

func (*Application) Start

func (app *Application) Start()

启动 SpringBoot 应用

type ApplicationContext

type ApplicationContext interface {
	// 继承 SpringContext 的功能
	SpringCore.SpringContext

	// 安全的启动一个 goroutine
	SafeGoroutine(fn GoFunc)

	// 等待所有 goroutine 退出
	Wait()
}

Application 上下文

type ApplicationEvent

type ApplicationEvent interface {
	// 应用启动的事件
	OnStartApplication(ctx ApplicationContext)

	// 应用停止的事件
	OnStopApplication(ctx ApplicationContext)
}

应用运行过程中产生的事件

type ConfigParser

type ConfigParser interface {
	// 文件扩展名
	FileExt() []string

	// 解析配置文件
	Parse(ctx ApplicationContext, filename string) error
}

配置文件解析器

type ConfigParserViper

type ConfigParserViper struct {
}

使用 spf13/viper 实现的解析器

func (*ConfigParserViper) FileExt

func (_ *ConfigParserViper) FileExt() []string

文件扩展名

func (*ConfigParserViper) Parse

func (parser *ConfigParserViper) Parse(ctx ApplicationContext, filename string) error

解析配置文件

type DefaultApplicationContext

type DefaultApplicationContext struct {
	*SpringCore.DefaultSpringContext
	// contains filtered or unexported fields
}

ApplicationContext 的默认版本

func NewDefaultApplicationContext

func NewDefaultApplicationContext() *DefaultApplicationContext

工厂函数

func (*DefaultApplicationContext) SafeGoroutine

func (ctx *DefaultApplicationContext) SafeGoroutine(fn GoFunc)

安全的启动一个 goroutine

func (*DefaultApplicationContext) Wait

func (ctx *DefaultApplicationContext) Wait()

等待所有 goroutine 退出

type GoFunc

type GoFunc func()

type ModuleFunc

type ModuleFunc func(SpringCore.SpringContext)

定义 SpringBoot 模块初始化函数,未来可能成为接口

Jump to

Keyboard shortcuts

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